Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 #include "core/html/HTMLInputElement.h" | 46 #include "core/html/HTMLInputElement.h" |
| 47 #include "core/html/forms/ColorChooser.h" | 47 #include "core/html/forms/ColorChooser.h" |
| 48 #include "core/html/forms/ColorChooserClient.h" | 48 #include "core/html/forms/ColorChooserClient.h" |
| 49 #include "core/html/forms/DateTimeChooser.h" | 49 #include "core/html/forms/DateTimeChooser.h" |
| 50 #include "core/layout/HitTestResult.h" | 50 #include "core/layout/HitTestResult.h" |
| 51 #include "core/layout/LayoutPart.h" | 51 #include "core/layout/LayoutPart.h" |
| 52 #include "core/layout/compositing/CompositedSelection.h" | 52 #include "core/layout/compositing/CompositedSelection.h" |
| 53 #include "core/loader/DocumentLoader.h" | 53 #include "core/loader/DocumentLoader.h" |
| 54 #include "core/loader/FrameLoadRequest.h" | 54 #include "core/loader/FrameLoadRequest.h" |
| 55 #include "core/page/Page.h" | 55 #include "core/page/Page.h" |
| 56 #include "core/page/PopupOpeningObserver.h" | |
| 56 #include "modules/accessibility/AXObject.h" | 57 #include "modules/accessibility/AXObject.h" |
| 57 #include "platform/Cursor.h" | 58 #include "platform/Cursor.h" |
| 58 #include "platform/FileChooser.h" | 59 #include "platform/FileChooser.h" |
| 59 #include "platform/RuntimeEnabledFeatures.h" | 60 #include "platform/RuntimeEnabledFeatures.h" |
| 60 #include "platform/exported/WrappedResourceRequest.h" | 61 #include "platform/exported/WrappedResourceRequest.h" |
| 61 #include "platform/geometry/IntRect.h" | 62 #include "platform/geometry/IntRect.h" |
| 62 #include "platform/graphics/GraphicsLayer.h" | 63 #include "platform/graphics/GraphicsLayer.h" |
| 63 #include "platform/weborigin/SecurityOrigin.h" | 64 #include "platform/weborigin/SecurityOrigin.h" |
| 64 #include "public/platform/Platform.h" | 65 #include "public/platform/Platform.h" |
| 65 #include "public/platform/WebCursorInfo.h" | 66 #include "public/platform/WebCursorInfo.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 } | 374 } |
| 374 } | 375 } |
| 375 | 376 |
| 376 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() | 377 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() |
| 377 { | 378 { |
| 378 return !!m_webView->client(); | 379 return !!m_webView->client(); |
| 379 } | 380 } |
| 380 | 381 |
| 381 bool ChromeClientImpl::runBeforeUnloadConfirmPanelInternal(LocalFrame* frame, co nst String& message) | 382 bool ChromeClientImpl::runBeforeUnloadConfirmPanelInternal(LocalFrame* frame, co nst String& message) |
| 382 { | 383 { |
| 384 notifyPopupOpeningObservers(); | |
| 383 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 385 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 384 | 386 |
| 385 bool isReload = false; | 387 bool isReload = false; |
| 386 WebDataSource* ds = webframe->provisionalDataSource(); | 388 WebDataSource* ds = webframe->provisionalDataSource(); |
| 387 if (ds) | 389 if (ds) |
| 388 isReload = (ds->navigationType() == WebNavigationTypeReload); | 390 isReload = (ds->navigationType() == WebNavigationTypeReload); |
| 389 | 391 |
| 390 if (webframe->client()) | 392 if (webframe->client()) |
| 391 return webframe->client()->runModalBeforeUnloadDialog(isReload, message) ; | 393 return webframe->client()->runModalBeforeUnloadDialog(isReload, message) ; |
| 392 return false; | 394 return false; |
| 393 } | 395 } |
| 394 | 396 |
| 395 void ChromeClientImpl::closeWindowSoon() | 397 void ChromeClientImpl::closeWindowSoon() |
| 396 { | 398 { |
| 397 // Make sure this Page can no longer be found by JS. | 399 // Make sure this Page can no longer be found by JS. |
| 398 Page::ordinaryPages().remove(m_webView->page()); | 400 Page::ordinaryPages().remove(m_webView->page()); |
| 399 | 401 |
| 400 // Make sure that all loading is stopped. Ensures that JS stops executing! | 402 // Make sure that all loading is stopped. Ensures that JS stops executing! |
| 401 m_webView->mainFrame()->stopLoading(); | 403 m_webView->mainFrame()->stopLoading(); |
| 402 | 404 |
| 403 if (m_webView->client()) | 405 if (m_webView->client()) |
| 404 m_webView->client()->closeWidgetSoon(); | 406 m_webView->client()->closeWidgetSoon(); |
| 405 } | 407 } |
| 406 | 408 |
| 407 // Although a LocalFrame is passed in, we don't actually use it, since we | 409 // Although a LocalFrame is passed in, we don't actually use it, since we |
| 408 // already know our own m_webView. | 410 // already know our own m_webView. |
| 409 void ChromeClientImpl::runJavaScriptAlertInternal(LocalFrame* frame, const Strin g& message) | 411 void ChromeClientImpl::runJavaScriptAlertInternal(LocalFrame* frame, const Strin g& message) |
| 410 { | 412 { |
| 413 notifyPopupOpeningObservers(); | |
| 411 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 414 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 412 if (webframe->client()) { | 415 if (webframe->client()) { |
| 413 if (WebUserGestureIndicator::isProcessingUserGesture()) | 416 if (WebUserGestureIndicator::isProcessingUserGesture()) |
| 414 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); | 417 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); |
| 415 webframe->client()->runModalAlertDialog(message); | 418 webframe->client()->runModalAlertDialog(message); |
| 416 } | 419 } |
| 417 } | 420 } |
| 418 | 421 |
| 419 // See comments for runJavaScriptAlert(). | 422 // See comments for runJavaScriptAlert(). |
| 420 bool ChromeClientImpl::runJavaScriptConfirmInternal(LocalFrame* frame, const Str ing& message) | 423 bool ChromeClientImpl::runJavaScriptConfirmInternal(LocalFrame* frame, const Str ing& message) |
| 421 { | 424 { |
| 425 notifyPopupOpeningObservers(); | |
| 422 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 426 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 423 if (webframe->client()) { | 427 if (webframe->client()) { |
| 424 if (WebUserGestureIndicator::isProcessingUserGesture()) | 428 if (WebUserGestureIndicator::isProcessingUserGesture()) |
| 425 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); | 429 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); |
| 426 return webframe->client()->runModalConfirmDialog(message); | 430 return webframe->client()->runModalConfirmDialog(message); |
| 427 } | 431 } |
| 428 return false; | 432 return false; |
| 429 } | 433 } |
| 430 | 434 |
| 431 // See comments for runJavaScriptAlert(). | 435 // See comments for runJavaScriptAlert(). |
| 432 bool ChromeClientImpl::runJavaScriptPromptInternal(LocalFrame* frame, const Stri ng& message, const String& defaultValue, String& result) | 436 bool ChromeClientImpl::runJavaScriptPromptInternal(LocalFrame* frame, const Stri ng& message, const String& defaultValue, String& result) |
| 433 { | 437 { |
| 438 notifyPopupOpeningObservers(); | |
| 434 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 439 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 435 if (webframe->client()) { | 440 if (webframe->client()) { |
| 436 if (WebUserGestureIndicator::isProcessingUserGesture()) | 441 if (WebUserGestureIndicator::isProcessingUserGesture()) |
| 437 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); | 442 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); |
| 438 WebString actualValue; | 443 WebString actualValue; |
| 439 bool ok = webframe->client()->runModalPromptDialog( | 444 bool ok = webframe->client()->runModalPromptDialog( |
| 440 message, | 445 message, |
| 441 defaultValue, | 446 defaultValue, |
| 442 &actualValue); | 447 &actualValue); |
| 443 if (ok) | 448 if (ok) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 { | 571 { |
| 567 m_webView->updatePageDefinedViewportConstraints(description); | 572 m_webView->updatePageDefinedViewportConstraints(description); |
| 568 } | 573 } |
| 569 | 574 |
| 570 void ChromeClientImpl::printInternal(LocalFrame* frame) | 575 void ChromeClientImpl::printInternal(LocalFrame* frame) |
| 571 { | 576 { |
| 572 if (m_webView->client()) | 577 if (m_webView->client()) |
| 573 m_webView->client()->printPage(WebLocalFrameImpl::fromFrame(frame)); | 578 m_webView->client()->printPage(WebLocalFrameImpl::fromFrame(frame)); |
| 574 } | 579 } |
| 575 | 580 |
| 576 PassOwnPtrWillBeRawPtr<ColorChooser> ChromeClientImpl::createColorChooserInterna l(LocalFrame* frame, ColorChooserClient* chooserClient, const Color&) | 581 PassOwnPtrWillBeRawPtr<ColorChooser> ChromeClientImpl::createColorChooser(LocalF rame* frame, ColorChooserClient* chooserClient, const Color&) |
| 577 { | 582 { |
| 583 notifyPopupOpeningObservers(); | |
| 578 OwnPtrWillBeRawPtr<ColorChooserUIController> controller = nullptr; | 584 OwnPtrWillBeRawPtr<ColorChooserUIController> controller = nullptr; |
| 579 if (RuntimeEnabledFeatures::pagePopupEnabled()) | 585 if (RuntimeEnabledFeatures::pagePopupEnabled()) |
| 580 controller = ColorChooserPopupUIController::create(frame, this, chooserC lient); | 586 controller = ColorChooserPopupUIController::create(frame, this, chooserC lient); |
| 581 else | 587 else |
| 582 controller = ColorChooserUIController::create(frame, chooserClient); | 588 controller = ColorChooserUIController::create(frame, chooserClient); |
| 583 controller->openUI(); | 589 controller->openUI(); |
| 584 return controller.release(); | 590 return controller.release(); |
| 585 } | 591 } |
| 586 | 592 |
| 587 PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooserInternal(DateTi meChooserClient* pickerClient, const DateTimeChooserParameters& parameters) | 593 PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChoose rClient* pickerClient, const DateTimeChooserParameters& parameters) |
| 588 { | 594 { |
| 595 notifyPopupOpeningObservers(); | |
| 589 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 596 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 590 return DateTimeChooserImpl::create(this, pickerClient, parameters); | 597 return DateTimeChooserImpl::create(this, pickerClient, parameters); |
| 591 #else | 598 #else |
| 592 return ExternalDateTimeChooser::create(this, m_webView->client(), pickerClie nt, parameters); | 599 return ExternalDateTimeChooser::create(this, m_webView->client(), pickerClie nt, parameters); |
| 593 #endif | 600 #endif |
| 594 } | 601 } |
| 595 | 602 |
| 596 void ChromeClientImpl::runOpenPanelInternal(LocalFrame* frame, PassRefPtr<FileCh ooser> fileChooser) | 603 void ChromeClientImpl::runOpenPanel(LocalFrame* frame, PassRefPtr<FileChooser> f ileChooser) |
| 597 { | 604 { |
| 605 notifyPopupOpeningObservers(); | |
| 598 WebViewClient* client = m_webView->client(); | 606 WebViewClient* client = m_webView->client(); |
| 599 if (!client) | 607 if (!client) |
| 600 return; | 608 return; |
| 601 | 609 |
| 602 WebFileChooserParams params; | 610 WebFileChooserParams params; |
| 603 params.multiSelect = fileChooser->settings().allowsMultipleFiles; | 611 params.multiSelect = fileChooser->settings().allowsMultipleFiles; |
| 604 params.directory = fileChooser->settings().allowsDirectoryUpload; | 612 params.directory = fileChooser->settings().allowsDirectoryUpload; |
| 605 params.acceptTypes = fileChooser->settings().acceptTypes(); | 613 params.acceptTypes = fileChooser->settings().acceptTypes(); |
| 606 params.selectedFiles = fileChooser->settings().selectedFiles; | 614 params.selectedFiles = fileChooser->settings().selectedFiles; |
| 607 if (params.selectedFiles.size() > 0) | 615 if (params.selectedFiles.size() > 0) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 void ChromeClientImpl::updateCompositedSelection(const CompositedSelection& sele ction) | 765 void ChromeClientImpl::updateCompositedSelection(const CompositedSelection& sele ction) |
| 758 { | 766 { |
| 759 m_webView->updateCompositedSelection(WebSelection(selection)); | 767 m_webView->updateCompositedSelection(WebSelection(selection)); |
| 760 } | 768 } |
| 761 | 769 |
| 762 bool ChromeClientImpl::hasOpenedPopup() const | 770 bool ChromeClientImpl::hasOpenedPopup() const |
| 763 { | 771 { |
| 764 return m_webView->hasOpenedPopup(); | 772 return m_webView->hasOpenedPopup(); |
| 765 } | 773 } |
| 766 | 774 |
| 767 PassRefPtrWillBeRawPtr<PopupMenu> ChromeClientImpl::createPopupMenuInternal(Loca lFrame& frame, PopupMenuClient* client) | 775 PassRefPtrWillBeRawPtr<PopupMenu> ChromeClientImpl::createPopupMenu(LocalFrame& frame, PopupMenuClient* client) |
| 768 { | 776 { |
| 777 notifyPopupOpeningObservers(); | |
| 769 if (WebViewImpl::useExternalPopupMenus()) | 778 if (WebViewImpl::useExternalPopupMenus()) |
| 770 return adoptRefWillBeNoop(new ExternalPopupMenu(frame, client, *m_webVie w)); | 779 return adoptRefWillBeNoop(new ExternalPopupMenu(frame, client, *m_webVie w)); |
| 771 | 780 |
| 772 if (RuntimeEnabledFeatures::htmlPopupMenuEnabled() && RuntimeEnabledFeatures ::pagePopupEnabled()) | 781 if (RuntimeEnabledFeatures::htmlPopupMenuEnabled() && RuntimeEnabledFeatures ::pagePopupEnabled()) |
| 773 return PopupMenuImpl::create(this, client); | 782 return PopupMenuImpl::create(this, client); |
| 774 | 783 |
| 775 return adoptRefWillBeNoop(new PopupMenuChromium(frame, client)); | 784 return adoptRefWillBeNoop(new PopupMenuChromium(frame, client)); |
| 776 } | 785 } |
| 777 | 786 |
| 778 PagePopup* ChromeClientImpl::openPagePopup(PagePopupClient* client) | 787 PagePopup* ChromeClientImpl::openPagePopup(PagePopupClient* client) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 webframe->autofillClient()->textFieldDidChange(WebFormControlElement(&el ement)); | 898 webframe->autofillClient()->textFieldDidChange(WebFormControlElement(&el ement)); |
| 890 } | 899 } |
| 891 | 900 |
| 892 void ChromeClientImpl::didEndEditingOnTextField(HTMLInputElement& inputElement) | 901 void ChromeClientImpl::didEndEditingOnTextField(HTMLInputElement& inputElement) |
| 893 { | 902 { |
| 894 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(inputElement.docu ment().frame()); | 903 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(inputElement.docu ment().frame()); |
| 895 if (webframe->autofillClient()) | 904 if (webframe->autofillClient()) |
| 896 webframe->autofillClient()->textFieldDidEndEditing(WebInputElement(&inpu tElement)); | 905 webframe->autofillClient()->textFieldDidEndEditing(WebInputElement(&inpu tElement)); |
| 897 } | 906 } |
| 898 | 907 |
| 899 void ChromeClientImpl::openTextDataListChooserInternal(HTMLInputElement& input) | 908 void ChromeClientImpl::openTextDataListChooser(HTMLInputElement& input) |
| 900 { | 909 { |
| 910 notifyPopupOpeningObservers(); | |
| 901 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(input.document(). frame()); | 911 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(input.document(). frame()); |
| 902 if (webframe->autofillClient()) | 912 if (webframe->autofillClient()) |
| 903 webframe->autofillClient()->openTextDataListChooser(WebInputElement(&inp ut)); | 913 webframe->autofillClient()->openTextDataListChooser(WebInputElement(&inp ut)); |
| 904 } | 914 } |
| 905 | 915 |
| 906 void ChromeClientImpl::textFieldDataListChanged(HTMLInputElement& input) | 916 void ChromeClientImpl::textFieldDataListChanged(HTMLInputElement& input) |
| 907 { | 917 { |
| 908 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(input.document(). frame()); | 918 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(input.document(). frame()); |
| 909 if (webframe->autofillClient()) | 919 if (webframe->autofillClient()) |
| 910 webframe->autofillClient()->dataListOptionsChanged(WebInputElement(&inpu t)); | 920 webframe->autofillClient()->dataListOptionsChanged(WebInputElement(&inpu t)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 921 { | 931 { |
| 922 if (m_webView->rootGraphicsLayer() && m_webView->layerTreeView()) | 932 if (m_webView->rootGraphicsLayer() && m_webView->layerTreeView()) |
| 923 m_webView->page()->frameHost().pinchViewport().registerLayersWithTreeVie w(m_webView->layerTreeView()); | 933 m_webView->page()->frameHost().pinchViewport().registerLayersWithTreeVie w(m_webView->layerTreeView()); |
| 924 } | 934 } |
| 925 | 935 |
| 926 void ChromeClientImpl::didUpdateTopControls() const | 936 void ChromeClientImpl::didUpdateTopControls() const |
| 927 { | 937 { |
| 928 m_webView->didUpdateTopControls(); | 938 m_webView->didUpdateTopControls(); |
| 929 } | 939 } |
| 930 | 940 |
| 941 void ChromeClientImpl::registerPopupOpeningObserver(PopupOpeningObserver* observ er) | |
| 942 { | |
| 943 ASSERT(observer); | |
| 944 m_popupOpeningObservers.append(observer); | |
| 945 } | |
| 946 | |
| 947 void ChromeClientImpl::unregisterPopupOpeningObserver(PopupOpeningObserver* obse rver) | |
| 948 { | |
| 949 size_t index = m_popupOpeningObservers.find(observer); | |
| 950 ASSERT(index != kNotFound); | |
| 951 m_popupOpeningObservers.remove(index); | |
| 952 } | |
| 953 | |
| 954 void ChromeClientImpl::notifyPopupOpeningObservers() const | |
| 955 { | |
| 956 const Vector<PopupOpeningObserver*> observers(m_popupOpeningObservers); | |
| 957 for (size_t i = 0; i < observers.size(); ++i) | |
|
yosin_UTC9
2015/06/03 01:03:42
Can we use range-for?
It seems there are some of t
tkent
2015/06/03 01:21:01
Yes, we can. I'll make a general style fix CL lat
| |
| 958 observers[i]->willOpenPopup(); | |
| 959 } | |
| 960 | |
| 931 } // namespace blink | 961 } // namespace blink |
| OLD | NEW |