| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 #include "web/WebLocalFrameImpl.h" | 101 #include "web/WebLocalFrameImpl.h" |
| 102 #include "web/WebPluginContainerImpl.h" | 102 #include "web/WebPluginContainerImpl.h" |
| 103 #include "web/WebPopupMenuImpl.h" | 103 #include "web/WebPopupMenuImpl.h" |
| 104 #include "web/WebSettingsImpl.h" | 104 #include "web/WebSettingsImpl.h" |
| 105 #include "web/WebViewImpl.h" | 105 #include "web/WebViewImpl.h" |
| 106 #include "wtf/text/CString.h" | 106 #include "wtf/text/CString.h" |
| 107 #include "wtf/text/StringBuilder.h" | 107 #include "wtf/text/StringBuilder.h" |
| 108 #include "wtf/text/StringConcatenate.h" | 108 #include "wtf/text/StringConcatenate.h" |
| 109 #include "wtf/unicode/CharacterNames.h" | 109 #include "wtf/unicode/CharacterNames.h" |
| 110 | 110 |
| 111 using namespace blink; | |
| 112 | |
| 113 namespace blink { | 111 namespace blink { |
| 114 | 112 |
| 115 // Converts a blink::AXObjectCache::AXNotification to a blink::WebAXEvent | 113 // Converts a AXObjectCache::AXNotification to a WebAXEvent |
| 116 static WebAXEvent toWebAXEvent(AXObjectCache::AXNotification notification) | 114 static WebAXEvent toWebAXEvent(AXObjectCache::AXNotification notification) |
| 117 { | 115 { |
| 118 // These enums have the same values; enforced in AssertMatchingEnums.cpp. | 116 // These enums have the same values; enforced in AssertMatchingEnums.cpp. |
| 119 return static_cast<WebAXEvent>(notification); | 117 return static_cast<WebAXEvent>(notification); |
| 120 } | 118 } |
| 121 | 119 |
| 122 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView) | 120 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView) |
| 123 : m_webView(webView) | 121 : m_webView(webView) |
| 124 , m_toolbarsVisible(true) | 122 , m_toolbarsVisible(true) |
| 125 , m_statusbarVisible(true) | 123 , m_statusbarVisible(true) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 void ChromeClientImpl::focusedNodeChanged(Node* node) | 197 void ChromeClientImpl::focusedNodeChanged(Node* node) |
| 200 { | 198 { |
| 201 m_webView->client()->focusedNodeChanged(WebNode(node)); | 199 m_webView->client()->focusedNodeChanged(WebNode(node)); |
| 202 | 200 |
| 203 WebURL focusURL; | 201 WebURL focusURL; |
| 204 if (node && node->isElementNode() && toElement(node)->isLiveLink()) | 202 if (node && node->isElementNode() && toElement(node)->isLiveLink()) |
| 205 focusURL = toElement(node)->hrefURL(); | 203 focusURL = toElement(node)->hrefURL(); |
| 206 m_webView->client()->setKeyboardFocusURL(focusURL); | 204 m_webView->client()->setKeyboardFocusURL(focusURL); |
| 207 } | 205 } |
| 208 | 206 |
| 209 void ChromeClientImpl::focusedFrameChanged(blink::LocalFrame* frame) | 207 void ChromeClientImpl::focusedFrameChanged(LocalFrame* frame) |
| 210 { | 208 { |
| 211 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 209 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 212 if (webframe && webframe->client()) | 210 if (webframe && webframe->client()) |
| 213 webframe->client()->frameFocused(); | 211 webframe->client()->frameFocused(); |
| 214 } | 212 } |
| 215 | 213 |
| 216 Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest&
r, const WindowFeatures& features, | 214 Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest&
r, const WindowFeatures& features, |
| 217 NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) | 215 NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) |
| 218 { | 216 { |
| 219 if (!m_webView->client()) | 217 if (!m_webView->client()) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 return !!m_webView->client(); | 377 return !!m_webView->client(); |
| 380 } | 378 } |
| 381 | 379 |
| 382 bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalF
rame* frame) | 380 bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalF
rame* frame) |
| 383 { | 381 { |
| 384 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 382 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 385 | 383 |
| 386 bool isReload = false; | 384 bool isReload = false; |
| 387 WebDataSource* ds = webframe->provisionalDataSource(); | 385 WebDataSource* ds = webframe->provisionalDataSource(); |
| 388 if (ds) | 386 if (ds) |
| 389 isReload = (ds->navigationType() == blink::WebNavigationTypeReload); | 387 isReload = (ds->navigationType() == WebNavigationTypeReload); |
| 390 | 388 |
| 391 if (webframe->client()) | 389 if (webframe->client()) |
| 392 return webframe->client()->runModalBeforeUnloadDialog(isReload, message)
; | 390 return webframe->client()->runModalBeforeUnloadDialog(isReload, message)
; |
| 393 return false; | 391 return false; |
| 394 } | 392 } |
| 395 | 393 |
| 396 void ChromeClientImpl::closeWindowSoon() | 394 void ChromeClientImpl::closeWindowSoon() |
| 397 { | 395 { |
| 398 // Make sure this Page can no longer be found by JS. | 396 // Make sure this Page can no longer be found by JS. |
| 399 Page::ordinaryPages().remove(m_webView->page()); | 397 Page::ordinaryPages().remove(m_webView->page()); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 WebFileChooserCompletionImpl* chooserCompletion = | 630 WebFileChooserCompletionImpl* chooserCompletion = |
| 633 new WebFileChooserCompletionImpl(fileChooser); | 631 new WebFileChooserCompletionImpl(fileChooser); |
| 634 | 632 |
| 635 ASSERT(fileChooser && fileChooser->settings().selectedFiles.size()); | 633 ASSERT(fileChooser && fileChooser->settings().selectedFiles.size()); |
| 636 | 634 |
| 637 // If the enumeration can't happen, call the callback with an empty list. | 635 // If the enumeration can't happen, call the callback with an empty list. |
| 638 if (!client->enumerateChosenDirectory(fileChooser->settings().selectedFiles[
0], chooserCompletion)) | 636 if (!client->enumerateChosenDirectory(fileChooser->settings().selectedFiles[
0], chooserCompletion)) |
| 639 chooserCompletion->didChooseFile(WebVector<WebString>()); | 637 chooserCompletion->didChooseFile(WebVector<WebString>()); |
| 640 } | 638 } |
| 641 | 639 |
| 642 void ChromeClientImpl::setCursor(const blink::Cursor& cursor) | 640 void ChromeClientImpl::setCursor(const Cursor& cursor) |
| 643 { | 641 { |
| 644 setCursor(WebCursorInfo(cursor)); | 642 setCursor(WebCursorInfo(cursor)); |
| 645 } | 643 } |
| 646 | 644 |
| 647 void ChromeClientImpl::setCursor(const WebCursorInfo& cursor) | 645 void ChromeClientImpl::setCursor(const WebCursorInfo& cursor) |
| 648 { | 646 { |
| 649 #if OS(MACOSX) | 647 #if OS(MACOSX) |
| 650 // On Mac the mousemove event propagates to both the popup and main window. | 648 // On Mac the mousemove event propagates to both the popup and main window. |
| 651 // If a popup is open we don't want the main window to change the cursor. | 649 // If a popup is open we don't want the main window to change the cursor. |
| 652 if (m_webView->hasOpenedPopup()) | 650 if (m_webView->hasOpenedPopup()) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType&
dialogType, const String& dialogMessage, Document::PageDismissalType dismissalT
ype) const | 746 bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType&
dialogType, const String& dialogMessage, Document::PageDismissalType dismissalT
ype) const |
| 749 { | 747 { |
| 750 const char* kDialogs[] = {"alert", "confirm", "prompt", "showModalDialog"}; | 748 const char* kDialogs[] = {"alert", "confirm", "prompt", "showModalDialog"}; |
| 751 int dialog = static_cast<int>(dialogType); | 749 int dialog = static_cast<int>(dialogType); |
| 752 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog && dialog < static_cast<int>(ar
raysize(kDialogs))); | 750 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog && dialog < static_cast<int>(ar
raysize(kDialogs))); |
| 753 | 751 |
| 754 const char* kDismissals[] = {"beforeunload", "pagehide", "unload"}; | 752 const char* kDismissals[] = {"beforeunload", "pagehide", "unload"}; |
| 755 int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal. | 753 int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal. |
| 756 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal && dismissal < static_cast<i
nt>(arraysize(kDismissals))); | 754 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal && dismissal < static_cast<i
nt>(arraysize(kDismissals))); |
| 757 | 755 |
| 758 blink::Platform::current()->histogramEnumeration("Renderer.ModalDialogsDurin
gPageDismissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) *
arraysize(kDismissals)); | 756 Platform::current()->histogramEnumeration("Renderer.ModalDialogsDuringPageDi
smissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) * arrays
ize(kDismissals)); |
| 759 | 757 |
| 760 String message = String("Blocked ") + kDialogs[dialog] + "('" + dialogMessag
e + "') during " + kDismissals[dismissal] + "."; | 758 String message = String("Blocked ") + kDialogs[dialog] + "('" + dialogMessag
e + "') during " + kDismissals[dismissal] + "."; |
| 761 m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMess
age::LevelError, message)); | 759 m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMess
age::LevelError, message)); |
| 762 | 760 |
| 763 return false; | 761 return false; |
| 764 } | 762 } |
| 765 | 763 |
| 766 void ChromeClientImpl::needTouchEvents(bool needsTouchEvents) | 764 void ChromeClientImpl::needTouchEvents(bool needsTouchEvents) |
| 767 { | 765 { |
| 768 m_webView->hasTouchEventHandlers(needsTouchEvents); | 766 m_webView->hasTouchEventHandlers(needsTouchEvents); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 void ChromeClientImpl::handleKeyboardEventOnTextField(HTMLInputElement& inputEle
ment, KeyboardEvent& event) | 824 void ChromeClientImpl::handleKeyboardEventOnTextField(HTMLInputElement& inputEle
ment, KeyboardEvent& event) |
| 827 { | 825 { |
| 828 if (!m_webView->autofillClient()) | 826 if (!m_webView->autofillClient()) |
| 829 return; | 827 return; |
| 830 m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement(&inp
utElement), WebKeyboardEventBuilder(event)); | 828 m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement(&inp
utElement), WebKeyboardEventBuilder(event)); |
| 831 } | 829 } |
| 832 | 830 |
| 833 // FIXME: Remove this code once we have input routing in the browser | 831 // FIXME: Remove this code once we have input routing in the browser |
| 834 // process. See http://crbug.com/339659. | 832 // process. See http://crbug.com/339659. |
| 835 void ChromeClientImpl::forwardInputEvent( | 833 void ChromeClientImpl::forwardInputEvent( |
| 836 blink::Frame* frame, blink::Event* event) | 834 Frame* frame, Event* event) |
| 837 { | 835 { |
| 838 // FIXME: Input event forwarding to out-of-process frames is broken until | 836 // FIXME: Input event forwarding to out-of-process frames is broken until |
| 839 // WebRemoteFrameImpl has a WebFrameClient. | 837 // WebRemoteFrameImpl has a WebFrameClient. |
| 840 if (frame->isRemoteFrame()) | 838 if (frame->isRemoteFrame()) |
| 841 return; | 839 return; |
| 842 | 840 |
| 843 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(fram
e)); | 841 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(fram
e)); |
| 844 | 842 |
| 845 // This is only called when we have out-of-process iframes, which | 843 // This is only called when we have out-of-process iframes, which |
| 846 // need to forward input events across processes. | 844 // need to forward input events across processes. |
| 847 // FIXME: Add a check for out-of-process iframes enabled. | 845 // FIXME: Add a check for out-of-process iframes enabled. |
| 848 if (event->isKeyboardEvent()) { | 846 if (event->isKeyboardEvent()) { |
| 849 WebKeyboardEventBuilder webEvent(*static_cast<blink::KeyboardEvent*>(eve
nt)); | 847 WebKeyboardEventBuilder webEvent(*static_cast<KeyboardEvent*>(event)); |
| 850 webFrame->client()->forwardInputEvent(&webEvent); | 848 webFrame->client()->forwardInputEvent(&webEvent); |
| 851 } else if (event->isMouseEvent()) { | 849 } else if (event->isMouseEvent()) { |
| 852 WebMouseEventBuilder webEvent(webFrame->frameView(), frame->ownerRendere
r(), *static_cast<blink::MouseEvent*>(event)); | 850 WebMouseEventBuilder webEvent(webFrame->frameView(), frame->ownerRendere
r(), *static_cast<MouseEvent*>(event)); |
| 853 // Internal Blink events should not be forwarded. | 851 // Internal Blink events should not be forwarded. |
| 854 if (webEvent.type == WebInputEvent::Undefined) | 852 if (webEvent.type == WebInputEvent::Undefined) |
| 855 return; | 853 return; |
| 856 | 854 |
| 857 webFrame->client()->forwardInputEvent(&webEvent); | 855 webFrame->client()->forwardInputEvent(&webEvent); |
| 858 } else if (event->isWheelEvent()) { | 856 } else if (event->isWheelEvent()) { |
| 859 WebMouseWheelEventBuilder webEvent(webFrame->frameView(), frame->ownerRe
nderer(), *static_cast<blink::WheelEvent*>(event)); | 857 WebMouseWheelEventBuilder webEvent(webFrame->frameView(), frame->ownerRe
nderer(), *static_cast<WheelEvent*>(event)); |
| 860 if (webEvent.type == WebInputEvent::Undefined) | 858 if (webEvent.type == WebInputEvent::Undefined) |
| 861 return; | 859 return; |
| 862 webFrame->client()->forwardInputEvent(&webEvent); | 860 webFrame->client()->forwardInputEvent(&webEvent); |
| 863 } | 861 } |
| 864 } | 862 } |
| 865 | 863 |
| 866 void ChromeClientImpl::didChangeValueInTextField(HTMLFormControlElement& element
) | 864 void ChromeClientImpl::didChangeValueInTextField(HTMLFormControlElement& element
) |
| 867 { | 865 { |
| 868 if (!m_webView->autofillClient()) | 866 if (!m_webView->autofillClient()) |
| 869 return; | 867 return; |
| 870 m_webView->autofillClient()->textFieldDidChange(WebFormControlElement(&eleme
nt)); | 868 m_webView->autofillClient()->textFieldDidChange(WebFormControlElement(&eleme
nt)); |
| 871 } | 869 } |
| 872 | 870 |
| 873 void ChromeClientImpl::didEndEditingOnTextField(HTMLInputElement& inputElement) | 871 void ChromeClientImpl::didEndEditingOnTextField(HTMLInputElement& inputElement) |
| 874 { | 872 { |
| 875 if (m_webView->autofillClient()) | 873 if (m_webView->autofillClient()) |
| 876 m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(&inp
utElement)); | 874 m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(&inp
utElement)); |
| 877 } | 875 } |
| 878 | 876 |
| 879 void ChromeClientImpl::openTextDataListChooser(HTMLInputElement& input) | 877 void ChromeClientImpl::openTextDataListChooser(HTMLInputElement& input) |
| 880 { | 878 { |
| 881 if (m_webView->autofillClient()) | 879 if (m_webView->autofillClient()) |
| 882 m_webView->autofillClient()->openTextDataListChooser(WebInputElement(&in
put)); | 880 m_webView->autofillClient()->openTextDataListChooser(WebInputElement(&in
put)); |
| 883 } | 881 } |
| 884 | 882 |
| 885 } // namespace blink | 883 } // namespace blink |
| OLD | NEW |