| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(localFrame); | 363 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(localFrame); |
| 364 if (frame && frame->client()) { | 364 if (frame && frame->client()) { |
| 365 frame->client()->didAddMessageToConsole( | 365 frame->client()->didAddMessageToConsole( |
| 366 WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), mess
age), | 366 WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), mess
age), |
| 367 sourceID, | 367 sourceID, |
| 368 lineNumber, | 368 lineNumber, |
| 369 stackTrace); | 369 stackTrace); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() | 373 bool ChromeClientImpl::canOpenBeforeUnloadConfirmPanel() |
| 374 { | 374 { |
| 375 return !!m_webView->client(); | 375 return !!m_webView->client(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 bool ChromeClientImpl::runBeforeUnloadConfirmPanelInternal(LocalFrame* frame, co
nst String& message) | 378 bool ChromeClientImpl::openBeforeUnloadConfirmPanelDelegate(LocalFrame* frame, c
onst String& message) |
| 379 { | 379 { |
| 380 notifyPopupOpeningObservers(); | 380 notifyPopupOpeningObservers(); |
| 381 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 381 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 382 | 382 |
| 383 WebDataSource* ds = webframe->provisionalDataSource(); | 383 WebDataSource* ds = webframe->provisionalDataSource(); |
| 384 bool isReload = ds && (ds->navigationType() == WebNavigationTypeReload); | 384 bool isReload = ds && (ds->navigationType() == WebNavigationTypeReload); |
| 385 | 385 |
| 386 if (webframe->client()) | 386 if (webframe->client()) |
| 387 return webframe->client()->runModalBeforeUnloadDialog(isReload, message)
; | 387 return webframe->client()->runModalBeforeUnloadDialog(isReload, message)
; |
| 388 return false; | 388 return false; |
| 389 } | 389 } |
| 390 | 390 |
| 391 void ChromeClientImpl::closeWindowSoon() | 391 void ChromeClientImpl::closeWindowSoon() |
| 392 { | 392 { |
| 393 // Make sure this Page can no longer be found by JS. | 393 // Make sure this Page can no longer be found by JS. |
| 394 Page::ordinaryPages().remove(m_webView->page()); | 394 Page::ordinaryPages().remove(m_webView->page()); |
| 395 | 395 |
| 396 // Make sure that all loading is stopped. Ensures that JS stops executing! | 396 // Make sure that all loading is stopped. Ensures that JS stops executing! |
| 397 m_webView->mainFrame()->stopLoading(); | 397 m_webView->mainFrame()->stopLoading(); |
| 398 | 398 |
| 399 if (m_webView->client()) | 399 if (m_webView->client()) |
| 400 m_webView->client()->closeWidgetSoon(); | 400 m_webView->client()->closeWidgetSoon(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 // Although a LocalFrame is passed in, we don't actually use it, since we | 403 // Although a LocalFrame is passed in, we don't actually use it, since we |
| 404 // already know our own m_webView. | 404 // already know our own m_webView. |
| 405 void ChromeClientImpl::runJavaScriptAlertInternal(LocalFrame* frame, const Strin
g& message) | 405 void ChromeClientImpl::openJavaScriptAlertDelegate(LocalFrame* frame, const Stri
ng& message) |
| 406 { | 406 { |
| 407 notifyPopupOpeningObservers(); | 407 notifyPopupOpeningObservers(); |
| 408 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 408 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 409 if (webframe->client()) { | 409 if (webframe->client()) { |
| 410 if (WebUserGestureIndicator::isProcessingUserGesture()) | 410 if (WebUserGestureIndicator::isProcessingUserGesture()) |
| 411 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm
pt(); | 411 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm
pt(); |
| 412 webframe->client()->runModalAlertDialog(message); | 412 webframe->client()->runModalAlertDialog(message); |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 // See comments for runJavaScriptAlert(). | 416 // See comments for openJavaScriptAlertDelegate(). |
| 417 bool ChromeClientImpl::runJavaScriptConfirmInternal(LocalFrame* frame, const Str
ing& message) | 417 bool ChromeClientImpl::openJavaScriptConfirmDelegate(LocalFrame* frame, const St
ring& message) |
| 418 { | 418 { |
| 419 notifyPopupOpeningObservers(); | 419 notifyPopupOpeningObservers(); |
| 420 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 420 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 421 if (webframe->client()) { | 421 if (webframe->client()) { |
| 422 if (WebUserGestureIndicator::isProcessingUserGesture()) | 422 if (WebUserGestureIndicator::isProcessingUserGesture()) |
| 423 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm
pt(); | 423 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm
pt(); |
| 424 return webframe->client()->runModalConfirmDialog(message); | 424 return webframe->client()->runModalConfirmDialog(message); |
| 425 } | 425 } |
| 426 return false; | 426 return false; |
| 427 } | 427 } |
| 428 | 428 |
| 429 // See comments for runJavaScriptAlert(). | 429 // See comments for openJavaScriptAlertDelegate(). |
| 430 bool ChromeClientImpl::runJavaScriptPromptInternal(LocalFrame* frame, const Stri
ng& message, const String& defaultValue, String& result) | 430 bool ChromeClientImpl::openJavaScriptPromptDelegate(LocalFrame* frame, const Str
ing& message, const String& defaultValue, String& result) |
| 431 { | 431 { |
| 432 notifyPopupOpeningObservers(); | 432 notifyPopupOpeningObservers(); |
| 433 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 433 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 434 if (webframe->client()) { | 434 if (webframe->client()) { |
| 435 if (WebUserGestureIndicator::isProcessingUserGesture()) | 435 if (WebUserGestureIndicator::isProcessingUserGesture()) |
| 436 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm
pt(); | 436 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm
pt(); |
| 437 WebString actualValue; | 437 WebString actualValue; |
| 438 bool ok = webframe->client()->runModalPromptDialog(message, defaultValue
, &actualValue); | 438 bool ok = webframe->client()->runModalPromptDialog(message, defaultValue
, &actualValue); |
| 439 if (ok) | 439 if (ok) |
| 440 result = actualValue; | 440 result = actualValue; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 { | 554 { |
| 555 if (m_webView->client()) | 555 if (m_webView->client()) |
| 556 m_webView->client()->setToolTipText(tooltipText, toWebTextDirection(dir)
); | 556 m_webView->client()->setToolTipText(tooltipText, toWebTextDirection(dir)
); |
| 557 } | 557 } |
| 558 | 558 |
| 559 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportDescrip
tion& description) const | 559 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportDescrip
tion& description) const |
| 560 { | 560 { |
| 561 m_webView->updatePageDefinedViewportConstraints(description); | 561 m_webView->updatePageDefinedViewportConstraints(description); |
| 562 } | 562 } |
| 563 | 563 |
| 564 void ChromeClientImpl::printInternal(LocalFrame* frame) | 564 void ChromeClientImpl::printDelegate(LocalFrame* frame) |
| 565 { | 565 { |
| 566 if (m_webView->client()) | 566 if (m_webView->client()) |
| 567 m_webView->client()->printPage(WebLocalFrameImpl::fromFrame(frame)); | 567 m_webView->client()->printPage(WebLocalFrameImpl::fromFrame(frame)); |
| 568 } | 568 } |
| 569 | 569 |
| 570 PassOwnPtrWillBeRawPtr<ColorChooser> ChromeClientImpl::createColorChooser(LocalF
rame* frame, ColorChooserClient* chooserClient, const Color&) | 570 PassOwnPtrWillBeRawPtr<ColorChooser> ChromeClientImpl::openColorChooser(LocalFra
me* frame, ColorChooserClient* chooserClient, const Color&) |
| 571 { | 571 { |
| 572 notifyPopupOpeningObservers(); | 572 notifyPopupOpeningObservers(); |
| 573 OwnPtrWillBeRawPtr<ColorChooserUIController> controller = nullptr; | 573 OwnPtrWillBeRawPtr<ColorChooserUIController> controller = nullptr; |
| 574 if (RuntimeEnabledFeatures::pagePopupEnabled()) | 574 if (RuntimeEnabledFeatures::pagePopupEnabled()) |
| 575 controller = ColorChooserPopupUIController::create(frame, this, chooserC
lient); | 575 controller = ColorChooserPopupUIController::create(frame, this, chooserC
lient); |
| 576 else | 576 else |
| 577 controller = ColorChooserUIController::create(frame, chooserClient); | 577 controller = ColorChooserUIController::create(frame, chooserClient); |
| 578 controller->openUI(); | 578 controller->openUI(); |
| 579 return controller.release(); | 579 return controller.release(); |
| 580 } | 580 } |
| 581 | 581 |
| 582 PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChoose
rClient* pickerClient, const DateTimeChooserParameters& parameters) | 582 PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChoose
rClient* pickerClient, const DateTimeChooserParameters& parameters) |
| 583 { | 583 { |
| 584 notifyPopupOpeningObservers(); | 584 notifyPopupOpeningObservers(); |
| 585 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 585 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 586 return DateTimeChooserImpl::create(this, pickerClient, parameters); | 586 return DateTimeChooserImpl::create(this, pickerClient, parameters); |
| 587 #else | 587 #else |
| 588 return ExternalDateTimeChooser::create(this, m_webView->client(), pickerClie
nt, parameters); | 588 return ExternalDateTimeChooser::create(this, m_webView->client(), pickerClie
nt, parameters); |
| 589 #endif | 589 #endif |
| 590 } | 590 } |
| 591 | 591 |
| 592 void ChromeClientImpl::runOpenPanel(LocalFrame* frame, PassRefPtr<FileChooser> f
ileChooser) | 592 void ChromeClientImpl::openFileChooser(LocalFrame* frame, PassRefPtr<FileChooser
> fileChooser) |
| 593 { | 593 { |
| 594 notifyPopupOpeningObservers(); | 594 notifyPopupOpeningObservers(); |
| 595 WebViewClient* client = m_webView->client(); | 595 WebViewClient* client = m_webView->client(); |
| 596 if (!client) | 596 if (!client) |
| 597 return; | 597 return; |
| 598 | 598 |
| 599 WebFileChooserParams params; | 599 WebFileChooserParams params; |
| 600 params.multiSelect = fileChooser->settings().allowsMultipleFiles; | 600 params.multiSelect = fileChooser->settings().allowsMultipleFiles; |
| 601 params.directory = fileChooser->settings().allowsDirectoryUpload; | 601 params.directory = fileChooser->settings().allowsDirectoryUpload; |
| 602 params.acceptTypes = fileChooser->settings().acceptTypes(); | 602 params.acceptTypes = fileChooser->settings().acceptTypes(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 void ChromeClientImpl::updateCompositedSelection(const CompositedSelection& sele
ction) | 760 void ChromeClientImpl::updateCompositedSelection(const CompositedSelection& sele
ction) |
| 761 { | 761 { |
| 762 m_webView->updateCompositedSelection(WebSelection(selection)); | 762 m_webView->updateCompositedSelection(WebSelection(selection)); |
| 763 } | 763 } |
| 764 | 764 |
| 765 bool ChromeClientImpl::hasOpenedPopup() const | 765 bool ChromeClientImpl::hasOpenedPopup() const |
| 766 { | 766 { |
| 767 return m_webView->hasOpenedPopup(); | 767 return m_webView->hasOpenedPopup(); |
| 768 } | 768 } |
| 769 | 769 |
| 770 PassRefPtrWillBeRawPtr<PopupMenu> ChromeClientImpl::createPopupMenu(LocalFrame&
frame, PopupMenuClient* client) | 770 PassRefPtrWillBeRawPtr<PopupMenu> ChromeClientImpl::openPopupMenu(LocalFrame& fr
ame, PopupMenuClient* client) |
| 771 { | 771 { |
| 772 notifyPopupOpeningObservers(); | 772 notifyPopupOpeningObservers(); |
| 773 if (WebViewImpl::useExternalPopupMenus()) | 773 if (WebViewImpl::useExternalPopupMenus()) |
| 774 return adoptRefWillBeNoop(new ExternalPopupMenu(frame, client, *m_webVie
w)); | 774 return adoptRefWillBeNoop(new ExternalPopupMenu(frame, client, *m_webVie
w)); |
| 775 | 775 |
| 776 if (RuntimeEnabledFeatures::htmlPopupMenuEnabled() && RuntimeEnabledFeatures
::pagePopupEnabled()) | 776 if (RuntimeEnabledFeatures::htmlPopupMenuEnabled() && RuntimeEnabledFeatures
::pagePopupEnabled()) |
| 777 return PopupMenuImpl::create(this, client); | 777 return PopupMenuImpl::create(this, client); |
| 778 | 778 |
| 779 return adoptRefWillBeNoop(new PopupMenuChromium(frame, client)); | 779 return adoptRefWillBeNoop(new PopupMenuChromium(frame, client)); |
| 780 } | 780 } |
| 781 | 781 |
| 782 PagePopup* ChromeClientImpl::openPagePopup(PagePopupClient* client) | 782 PagePopup* ChromeClientImpl::openPagePopup(PagePopupClient* client) |
| 783 { | 783 { |
| 784 return m_webView->openPagePopup(client); | 784 return m_webView->openPagePopup(client); |
| 785 } | 785 } |
| 786 | 786 |
| 787 void ChromeClientImpl::closePagePopup(PagePopup* popup) | 787 void ChromeClientImpl::closePagePopup(PagePopup* popup) |
| 788 { | 788 { |
| 789 m_webView->closePagePopup(popup); | 789 m_webView->closePagePopup(popup); |
| 790 } | 790 } |
| 791 | 791 |
| 792 DOMWindow* ChromeClientImpl::pagePopupWindowForTesting() const | 792 DOMWindow* ChromeClientImpl::pagePopupWindowForTesting() const |
| 793 { | 793 { |
| 794 return m_webView->pagePopupWindow(); | 794 return m_webView->pagePopupWindow(); |
| 795 } | 795 } |
| 796 | 796 |
| 797 bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType&
dialogType, const String& dialogMessage, Document::PageDismissalType dismissalT
ype) const | 797 bool ChromeClientImpl::shouldOpenModalDialogDuringPageDismissal(const DialogType
& dialogType, const String& dialogMessage, Document::PageDismissalType dismissal
Type) const |
| 798 { | 798 { |
| 799 const char* kDialogs[] = {"alert", "confirm", "prompt"}; | 799 const char* kDialogs[] = {"alert", "confirm", "prompt"}; |
| 800 int dialog = static_cast<int>(dialogType); | 800 int dialog = static_cast<int>(dialogType); |
| 801 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog); | 801 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog); |
| 802 ASSERT_WITH_SECURITY_IMPLICATION(dialog < static_cast<int>(arraysize(kDialog
s))); | 802 ASSERT_WITH_SECURITY_IMPLICATION(dialog < static_cast<int>(arraysize(kDialog
s))); |
| 803 | 803 |
| 804 const char* kDismissals[] = {"beforeunload", "pagehide", "unload"}; | 804 const char* kDismissals[] = {"beforeunload", "pagehide", "unload"}; |
| 805 int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal. | 805 int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal. |
| 806 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal); | 806 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal); |
| 807 ASSERT_WITH_SECURITY_IMPLICATION(dismissal < static_cast<int>(arraysize(kDis
missals))); | 807 ASSERT_WITH_SECURITY_IMPLICATION(dismissal < static_cast<int>(arraysize(kDis
missals))); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 } | 946 } |
| 947 | 947 |
| 948 void ChromeClientImpl::notifyPopupOpeningObservers() const | 948 void ChromeClientImpl::notifyPopupOpeningObservers() const |
| 949 { | 949 { |
| 950 const Vector<PopupOpeningObserver*> observers(m_popupOpeningObservers); | 950 const Vector<PopupOpeningObserver*> observers(m_popupOpeningObservers); |
| 951 for (const auto& observer : observers) | 951 for (const auto& observer : observers) |
| 952 observer->willOpenPopup(); | 952 observer->willOpenPopup(); |
| 953 } | 953 } |
| 954 | 954 |
| 955 } // namespace blink | 955 } // namespace blink |
| OLD | NEW |