1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "android_webview/browser/aw_javascript_dialog_manager.h" 6 7 #include "android_webview/browser/aw_contents_client_bridge_base.h" 8 #include "content/public/browser/javascript_dialog_manager.h" 9 #include "content/public/browser/web_contents.h" 10 11 namespace android_webview { 12 13 AwJavaScriptDialogManager::AwJavaScriptDialogManager() {} 14 15 AwJavaScriptDialogManager::~AwJavaScriptDialogManager() {} 16 17 void AwJavaScriptDialogManager::RunJavaScriptDialog( 18 content::WebContents* web_contents, 19 const GURL& origin_url, 20 const std::string& accept_lang, 21 content::JavaScriptMessageType message_type, 22 const base::string16& message_text, 23 const base::string16& default_prompt_text, 24 const DialogClosedCallback& callback, 25 bool* did_suppress_message) { 26 AwContentsClientBridgeBase* bridge = 27 AwContentsClientBridgeBase::FromWebContents(web_contents); 28 if (!bridge) { 29 callback.Run(false, base::string16()); 30 return; 31 } 32 33 bridge->RunJavaScriptDialog(message_type, 34 origin_url, 35 message_text, 36 default_prompt_text, 37 callback); 38 } 39 40 void AwJavaScriptDialogManager::RunBeforeUnloadDialog( 41 content::WebContents* web_contents, 42 const base::string16& message_text, 43 bool is_reload, 44 const DialogClosedCallback& callback) { 45 AwContentsClientBridgeBase* bridge = 46 AwContentsClientBridgeBase::FromWebContents(web_contents); 47 if (!bridge) { 48 callback.Run(false, base::string16()); 49 return; 50 } 51 52 bridge->RunBeforeUnloadDialog(web_contents->GetURL(), 53 message_text, 54 callback); 55 } 56 57 void AwJavaScriptDialogManager::CancelActiveAndPendingDialogs( 58 content::WebContents* web_contents) { 59 } 60 61 void AwJavaScriptDialogManager::WebContentsDestroyed( 62 content::WebContents* web_contents) { 63 } 64 65 } // namespace android_webview 66