2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "BrowserExtensionWin.h"
33 #include "FrameLoadRequest.h"
34 #include "FramePrivate.h"
36 #include "PlatformKeyboardEvent.h"
38 #include "RenderFrame.h"
39 #include "ResourceLoader.h"
44 FrameWin::FrameWin(Page* page, Element* ownerElement, FrameWinClient* client)
45 : Frame(page, ownerElement)
47 d->m_extension = new BrowserExtensionWin(this);
48 Settings* settings = new Settings();
49 settings->setAutoLoadImages(true);
50 settings->setMediumFixedFontSize(13);
51 settings->setMediumFontSize(16);
52 settings->setSerifFontName("Times New Roman");
53 settings->setFixedFontName("Courier New");
54 settings->setSansSerifFontName("Arial");
55 settings->setStdFontName("Times New Roman");
56 settings->setIsJavaScriptEnabled(true);
58 setSettings(settings);
65 clearRecordedFormValues();
68 void FrameWin::urlSelected(const FrameLoadRequest& request, const Event* /*triggeringEvent*/)
71 m_client->openURL(request.m_request.url().url(), request.lockHistory());
74 void FrameWin::submitForm(const FrameLoadRequest& request)
76 // FIXME: this is a hack inherited from FrameMac, and should be pushed into Frame
77 const ResourceRequest& resourceRequest = request.m_request;
78 if (d->m_submittedFormURL == resourceRequest.url())
80 d->m_submittedFormURL = resourceRequest.url();
83 m_client->submitForm(resourceRequest.doPost() ? "POST" : "GET", resourceRequest.url(), &resourceRequest.postData);
85 clearRecordedFormValues();
88 String FrameWin::userAgent() const
90 return "Mozilla/5.0 (PC; U; Intel; Windows; en) AppleWebKit/420+ (KHTML, like Gecko)";
93 void FrameWin::runJavaScriptAlert(String const& message)
95 String text = message;
96 text.replace('\\', backslashAsCurrencySymbol());
98 text += String(&nullChar, 1);
99 MessageBox(view()->containingWindow(), text.characters(), L"JavaScript Alert", MB_OK);
102 bool FrameWin::runJavaScriptConfirm(String const& message)
104 String text = message;
105 text.replace('\\', backslashAsCurrencySymbol());
107 text += String(&nullChar, 1);
108 return MessageBox(view()->containingWindow(), text.characters(), L"JavaScript Alert", MB_OKCANCEL) == IDOK;
111 // FIXME: This needs to be unified with the keyPress method on FrameMac
112 bool FrameWin::keyPress(const PlatformKeyboardEvent& keyEvent)
115 // Check for cases where we are too early for events -- possible unmatched key up
116 // from pressing return in the location bar.
117 Document *doc = document();
120 Node *node = doc->focusNode();
122 if (doc->isHTMLDocument())
125 node = doc->documentElement();
130 if (!keyEvent.isKeyUp())
131 prepareForUserAction();
133 result = !EventTargetNodeCast(node)->dispatchKeyEvent(keyEvent);
135 // FIXME: FrameMac has a keyDown/keyPress hack here which we are not copying.
140 void FrameWin::setTitle(const String &title)
143 text.replace('\\', backslashAsCurrencySymbol());
145 m_client->setTitle(text);
148 void FrameWin::setStatusBarText(const String& status)
150 String text = status;
151 text.replace('\\', backslashAsCurrencySymbol());
153 m_client->setStatusText(text);
156 void FrameWin::createNewWindow(const FrameLoadRequest& request, const WindowFeatures& features, Frame*& newFrame)
158 m_client->createNewWindow(request.m_request, features, newFrame);
161 } // namespace WebCore