| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2012, Samsung Electronics. All rights reserved. | 4 * Copyright (C) 2012, Samsung Electronics. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "core/page/ChromeClient.h" | 23 #include "core/page/ChromeClient.h" |
| 24 | 24 |
| 25 #include "core/dom/Document.h" | 25 #include "core/dom/Document.h" |
| 26 #include "core/frame/LocalFrame.h" | 26 #include "core/frame/LocalFrame.h" |
| 27 #include "core/html/HTMLInputElement.h" | 27 #include "core/html/HTMLInputElement.h" |
| 28 #include "core/html/forms/ColorChooser.h" | |
| 29 #include "core/html/forms/DateTimeChooser.h" | |
| 30 #include "core/inspector/InspectorInstrumentation.h" | 28 #include "core/inspector/InspectorInstrumentation.h" |
| 31 #include "core/layout/HitTestResult.h" | 29 #include "core/layout/HitTestResult.h" |
| 32 #include "core/page/FrameTree.h" | 30 #include "core/page/FrameTree.h" |
| 33 #include "core/page/PopupOpeningObserver.h" | |
| 34 #include "core/page/ScopedPageLoadDeferrer.h" | 31 #include "core/page/ScopedPageLoadDeferrer.h" |
| 35 #include "core/page/WindowFeatures.h" | 32 #include "core/page/WindowFeatures.h" |
| 36 #include "platform/FileChooser.h" | |
| 37 #include "platform/geometry/IntRect.h" | 33 #include "platform/geometry/IntRect.h" |
| 38 #include "platform/network/NetworkHints.h" | 34 #include "platform/network/NetworkHints.h" |
| 39 #include "public/platform/WebScreenInfo.h" | 35 #include "public/platform/WebScreenInfo.h" |
| 40 #include "wtf/PassRefPtr.h" | |
| 41 #include "wtf/Vector.h" | |
| 42 #include <algorithm> | 36 #include <algorithm> |
| 43 | 37 |
| 44 namespace blink { | 38 namespace blink { |
| 45 | 39 |
| 46 void ChromeClient::setWindowRect(const IntRect& pendingRect) | 40 void ChromeClient::setWindowRect(const IntRect& pendingRect) |
| 47 { | 41 { |
| 48 IntRect screen = screenInfo().availableRect; | 42 IntRect screen = screenInfo().availableRect; |
| 49 IntRect window = pendingRect; | 43 IntRect window = pendingRect; |
| 50 | 44 |
| 51 IntSize minimumSize = minimumWindowSize(); | 45 IntSize minimumSize = minimumWindowSize(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 ReturnType(ChromeClient::*function)(LocalFrame*, const String& message, Para
ms&...), | 98 ReturnType(ChromeClient::*function)(LocalFrame*, const String& message, Para
ms&...), |
| 105 LocalFrame& frame, | 99 LocalFrame& frame, |
| 106 const String& message, | 100 const String& message, |
| 107 Params&... parameters) | 101 Params&... parameters) |
| 108 { | 102 { |
| 109 // Defer loads in case the client method runs a new event loop that would | 103 // Defer loads in case the client method runs a new event loop that would |
| 110 // otherwise cause the load to continue while we're in the middle of | 104 // otherwise cause the load to continue while we're in the middle of |
| 111 // executing JavaScript. | 105 // executing JavaScript. |
| 112 ScopedPageLoadDeferrer deferrer; | 106 ScopedPageLoadDeferrer deferrer; |
| 113 | 107 |
| 114 chromeClient->notifyPopupOpeningObservers(); | |
| 115 ScopedJavaScriptDialogInstrumentation instrumentation(frame, message); | 108 ScopedJavaScriptDialogInstrumentation instrumentation(frame, message); |
| 116 return (chromeClient->*function)(&frame, message, parameters...); | 109 return (chromeClient->*function)(&frame, message, parameters...); |
| 117 } | 110 } |
| 118 | 111 |
| 119 bool ChromeClient::runBeforeUnloadConfirmPanel(const String& message, LocalFrame
* frame) | 112 bool ChromeClient::runBeforeUnloadConfirmPanel(const String& message, LocalFrame
* frame) |
| 120 { | 113 { |
| 121 return openJavaScriptDialog(this, &ChromeClient::runBeforeUnloadConfirmPanel
Internal, *frame, message); | 114 return openJavaScriptDialog(this, &ChromeClient::runBeforeUnloadConfirmPanel
Internal, *frame, message); |
| 122 } | 115 } |
| 123 | 116 |
| 124 void ChromeClient::runJavaScriptAlert(LocalFrame* frame, const String& message) | 117 void ChromeClient::runJavaScriptAlert(LocalFrame* frame, const String& message) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 181 |
| 189 void ChromeClient::print(LocalFrame* frame) | 182 void ChromeClient::print(LocalFrame* frame) |
| 190 { | 183 { |
| 191 // Defer loads in case the client method runs a new event loop that would | 184 // Defer loads in case the client method runs a new event loop that would |
| 192 // otherwise cause the load to continue while we're in the middle of executi
ng JavaScript. | 185 // otherwise cause the load to continue while we're in the middle of executi
ng JavaScript. |
| 193 ScopedPageLoadDeferrer deferrer; | 186 ScopedPageLoadDeferrer deferrer; |
| 194 | 187 |
| 195 printInternal(frame); | 188 printInternal(frame); |
| 196 } | 189 } |
| 197 | 190 |
| 198 PassOwnPtrWillBeRawPtr<ColorChooser> ChromeClient::createColorChooser(LocalFrame
* frame, ColorChooserClient* client, const Color& initialColor) | |
| 199 { | |
| 200 notifyPopupOpeningObservers(); | |
| 201 return createColorChooserInternal(frame, client, initialColor); | |
| 202 } | |
| 203 | |
| 204 PassRefPtr<DateTimeChooser> ChromeClient::openDateTimeChooser(DateTimeChooserCli
ent* client, const DateTimeChooserParameters& parameters) | |
| 205 { | |
| 206 notifyPopupOpeningObservers(); | |
| 207 return openDateTimeChooserInternal(client, parameters); | |
| 208 } | |
| 209 | |
| 210 void ChromeClient::openTextDataListChooser(HTMLInputElement& input) | |
| 211 { | |
| 212 notifyPopupOpeningObservers(); | |
| 213 openTextDataListChooserInternal(input); | |
| 214 } | |
| 215 | |
| 216 void ChromeClient::runOpenPanel(LocalFrame* frame, PassRefPtr<FileChooser> fileC
hooser) | |
| 217 { | |
| 218 notifyPopupOpeningObservers(); | |
| 219 runOpenPanelInternal(frame, fileChooser); | |
| 220 } | |
| 221 | |
| 222 void ChromeClient::setCursor(const Cursor& cursor) | 191 void ChromeClient::setCursor(const Cursor& cursor) |
| 223 { | 192 { |
| 224 m_lastSetMouseCursorForTesting = cursor; | 193 m_lastSetMouseCursorForTesting = cursor; |
| 225 setCursorInternal(cursor); | 194 setCursorInternal(cursor); |
| 226 } | 195 } |
| 227 | 196 |
| 228 Cursor ChromeClient::getLastSetCursorForTesting() const | 197 Cursor ChromeClient::getLastSetCursorForTesting() const |
| 229 { | 198 { |
| 230 return m_lastSetMouseCursorForTesting; | 199 return m_lastSetMouseCursorForTesting; |
| 231 } | 200 } |
| 232 | 201 |
| 233 // -------- | |
| 234 | |
| 235 PassRefPtrWillBeRawPtr<PopupMenu> ChromeClient::createPopupMenu(LocalFrame& fram
e, PopupMenuClient* client) | |
| 236 { | |
| 237 notifyPopupOpeningObservers(); | |
| 238 return createPopupMenuInternal(frame, client); | |
| 239 } | |
| 240 | |
| 241 void ChromeClient::registerPopupOpeningObserver(PopupOpeningObserver* observer) | |
| 242 { | |
| 243 ASSERT(observer); | |
| 244 m_popupOpeningObservers.append(observer); | |
| 245 } | |
| 246 | |
| 247 void ChromeClient::unregisterPopupOpeningObserver(PopupOpeningObserver* observer
) | |
| 248 { | |
| 249 size_t index = m_popupOpeningObservers.find(observer); | |
| 250 ASSERT(index != kNotFound); | |
| 251 m_popupOpeningObservers.remove(index); | |
| 252 } | |
| 253 | |
| 254 void ChromeClient::notifyPopupOpeningObservers() const | |
| 255 { | |
| 256 const Vector<PopupOpeningObserver*> observers(m_popupOpeningObservers); | |
| 257 for (size_t i = 0; i < observers.size(); ++i) | |
| 258 observers[i]->willOpenPopup(); | |
| 259 } | |
| 260 | |
| 261 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |