Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1122)

Side by Side Diff: Source/web/ChromeClientImpl.cpp

Issue 226413004: Move modal dialogs from WebViewClient to WebFrameClient, part 2/3. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove redundancy Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | public/web/WebFrameClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 } 382 }
383 383
384 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() 384 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel()
385 { 385 {
386 return !!m_webView->client(); 386 return !!m_webView->client();
387 } 387 }
388 388
389 bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalF rame* frame) 389 bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalF rame* frame)
390 { 390 {
391 if (m_webView->client()) { 391 WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame);
392 return m_webView->client()->runModalBeforeUnloadDialog( 392
393 WebFrameImpl::fromFrame(frame), message); 393 bool isReload = false;
394 } 394 WebDataSource* ds = webframe->provisionalDataSource();
395 if (ds)
396 isReload = (ds->navigationType() == blink::WebNavigationTypeReload);
397
398 if (webframe->client())
399 return webframe->client()->runModalBeforeUnloadDialog(isReload, message) ;
395 return false; 400 return false;
396 } 401 }
397 402
398 void ChromeClientImpl::closeWindowSoon() 403 void ChromeClientImpl::closeWindowSoon()
399 { 404 {
400 // Make sure this Page can no longer be found by JS. 405 // Make sure this Page can no longer be found by JS.
401 Page::ordinaryPages().remove(m_webView->page()); 406 Page::ordinaryPages().remove(m_webView->page());
402 407
403 // Make sure that all loading is stopped. Ensures that JS stops executing! 408 // Make sure that all loading is stopped. Ensures that JS stops executing!
404 m_webView->mainFrame()->stopLoading(); 409 m_webView->mainFrame()->stopLoading();
405 410
406 if (m_webView->client()) 411 if (m_webView->client())
407 m_webView->client()->closeWidgetSoon(); 412 m_webView->client()->closeWidgetSoon();
408 } 413 }
409 414
410 // Although a LocalFrame is passed in, we don't actually use it, since we 415 // Although a LocalFrame is passed in, we don't actually use it, since we
411 // already know our own m_webView. 416 // already know our own m_webView.
412 void ChromeClientImpl::runJavaScriptAlert(LocalFrame* frame, const String& messa ge) 417 void ChromeClientImpl::runJavaScriptAlert(LocalFrame* frame, const String& messa ge)
413 { 418 {
414 if (m_webView->client()) { 419 WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame);
420 if (webframe->client()) {
415 if (WebUserGestureIndicator::isProcessingUserGesture()) 421 if (WebUserGestureIndicator::isProcessingUserGesture())
416 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); 422 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt();
417 m_webView->client()->runModalAlertDialog( 423 webframe->client()->runModalAlertDialog(message);
418 WebFrameImpl::fromFrame(frame), message);
419 } 424 }
420 } 425 }
421 426
422 // See comments for runJavaScriptAlert(). 427 // See comments for runJavaScriptAlert().
423 bool ChromeClientImpl::runJavaScriptConfirm(LocalFrame* frame, const String& mes sage) 428 bool ChromeClientImpl::runJavaScriptConfirm(LocalFrame* frame, const String& mes sage)
424 { 429 {
425 if (m_webView->client()) { 430 WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame);
431 if (webframe->client()) {
426 if (WebUserGestureIndicator::isProcessingUserGesture()) 432 if (WebUserGestureIndicator::isProcessingUserGesture())
427 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); 433 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt();
428 return m_webView->client()->runModalConfirmDialog( 434 return webframe->client()->runModalConfirmDialog(message);
429 WebFrameImpl::fromFrame(frame), message);
430 } 435 }
431 return false; 436 return false;
432 } 437 }
433 438
434 // See comments for runJavaScriptAlert(). 439 // See comments for runJavaScriptAlert().
435 bool ChromeClientImpl::runJavaScriptPrompt(LocalFrame* frame, 440 bool ChromeClientImpl::runJavaScriptPrompt(LocalFrame* frame,
436 const String& message, 441 const String& message,
437 const String& defaultValue, 442 const String& defaultValue,
438 String& result) 443 String& result)
439 { 444 {
440 if (m_webView->client()) { 445 WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame);
446 if (webframe->client()) {
441 if (WebUserGestureIndicator::isProcessingUserGesture()) 447 if (WebUserGestureIndicator::isProcessingUserGesture())
442 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt(); 448 WebUserGestureIndicator::currentUserGestureToken().setJavascriptProm pt();
443 WebString actualValue; 449 WebString actualValue;
444 bool ok = m_webView->client()->runModalPromptDialog( 450 bool ok = webframe->client()->runModalPromptDialog(
445 WebFrameImpl::fromFrame(frame),
446 message, 451 message,
447 defaultValue, 452 defaultValue,
448 &actualValue); 453 &actualValue);
449 if (ok) 454 if (ok)
450 result = actualValue; 455 result = actualValue;
451 return ok; 456 return ok;
452 } 457 }
453 return false; 458 return false;
454 } 459 }
455 460
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 { 968 {
964 return static_cast<NavigatorContentUtilsClient::CustomHandlersState>(m_webVi ew->client()->isProtocolHandlerRegistered(scheme, baseURL, url)); 969 return static_cast<NavigatorContentUtilsClient::CustomHandlersState>(m_webVi ew->client()->isProtocolHandlerRegistered(scheme, baseURL, url));
965 } 970 }
966 971
967 void NavigatorContentUtilsClientImpl::unregisterProtocolHandler(const String& sc heme, const WebCore::KURL& baseURL, const WebCore::KURL& url) 972 void NavigatorContentUtilsClientImpl::unregisterProtocolHandler(const String& sc heme, const WebCore::KURL& baseURL, const WebCore::KURL& url)
968 { 973 {
969 m_webView->client()->unregisterProtocolHandler(scheme, baseURL, url); 974 m_webView->client()->unregisterProtocolHandler(scheme, baseURL, url);
970 } 975 }
971 976
972 } // namespace blink 977 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/web/WebFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698