2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "BrowserExtensionWin.h"
32 #include "FrameLoadRequest.h"
33 #include "FramePrivate.h"
35 #include "PlatformKeyboardEvent.h"
37 #include "RenderFrame.h"
38 #include "ResourceLoader.h"
43 FrameWin::FrameWin(Page* page, Element* ownerElement, FrameWinClient* client)
44 : Frame(page, ownerElement)
46 d->m_extension = new BrowserExtensionWin(this);
47 Settings* settings = new Settings();
48 settings->setAutoLoadImages(true);
49 settings->setMediumFixedFontSize(13);
50 settings->setMediumFontSize(16);
51 settings->setSerifFontName("Times New Roman");
52 settings->setFixedFontName("Courier New");
53 settings->setSansSerifFontName("Arial");
54 settings->setStdFontName("Times New Roman");
55 settings->setIsJavaScriptEnabled(true);
57 setSettings(settings);
64 clearRecordedFormValues();
67 void FrameWin::urlSelected(const FrameLoadRequest& request)
70 m_client->openURL(request.m_request.url().url(), request.lockHistory());
73 void FrameWin::submitForm(const FrameLoadRequest& request)
75 // FIXME: this is a hack inherited from FrameMac, and should be pushed into Frame
76 const ResourceRequest& resourceRequest = request.m_request;
77 if (d->m_submittedFormURL == resourceRequest.url())
79 d->m_submittedFormURL = resourceRequest.url();
82 m_client->submitForm(resourceRequest.doPost() ? "POST" : "GET", resourceRequest.url(), &resourceRequest.postData);
84 clearRecordedFormValues();
87 String FrameWin::userAgent() const
89 return "Mozilla/5.0 (PC; U; Intel; Windows; en) AppleWebKit/420+ (KHTML, like Gecko)";
92 void FrameWin::runJavaScriptAlert(String const& message)
94 String text = message;
95 text.replace('\\', backslashAsCurrencySymbol());
97 text += String(&nullChar, 1);
98 MessageBox(view()->containingWindow(), text.characters(), L"JavaScript Alert", MB_OK);
101 bool FrameWin::runJavaScriptConfirm(String const& message)
103 String text = message;
104 text.replace('\\', backslashAsCurrencySymbol());
106 text += String(&nullChar, 1);
107 return MessageBox(view()->containingWindow(), text.characters(), L"JavaScript Alert", MB_OKCANCEL) == IDOK;
110 // FIXME: This needs to be unified with the keyPress method on FrameMac
111 bool FrameWin::keyPress(const PlatformKeyboardEvent& keyEvent)
114 // Check for cases where we are too early for events -- possible unmatched key up
115 // from pressing return in the location bar.
116 Document *doc = document();
119 Node *node = doc->focusNode();
121 if (doc->isHTMLDocument())
124 node = doc->documentElement();
129 if (!keyEvent.isKeyUp())
130 prepareForUserAction();
132 result = !EventTargetNodeCast(node)->dispatchKeyEvent(keyEvent);
134 // FIXME: FrameMac has a keyDown/keyPress hack here which we are not copying.
139 void FrameWin::setTitle(const String &title)
142 text.replace('\\', backslashAsCurrencySymbol());
144 m_client->setTitle(text);
147 void FrameWin::setStatusBarText(const String& status)
149 String text = status;
150 text.replace('\\', backslashAsCurrencySymbol());
152 m_client->setStatusText(text);
155 void FrameWin::createNewWindow(const FrameLoadRequest& request)
157 m_client->createNewWindow(request.m_request);
160 void FrameWin::createNewWindow(const FrameLoadRequest& request,
161 const WindowFeatures& args,
164 m_client->createNewWindow(request.m_request, args, part);