| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/components/javascript_dialog_extensions_client/javascript_d
ialog_extension_client_impl.h" | 5 #include "extensions/components/javascript_dialog_extensions_client/javascript_d
ialog_extension_client_impl.h" |
| 6 | 6 |
| 7 #include "components/app_modal_dialogs/javascript_dialog_extensions_client.h" | 7 #include "components/app_modal_dialogs/javascript_dialog_extensions_client.h" |
| 8 #include "components/app_modal_dialogs/javascript_dialog_manager.h" | 8 #include "components/app_modal_dialogs/javascript_dialog_manager.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "extensions/browser/process_manager.h" | 10 #include "extensions/browser/process_manager.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 13 | 13 |
| 14 namespace javascript_dialog_extensions_client { |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 using extensions::Extension; | 17 using extensions::Extension; |
| 17 | 18 |
| 18 // Returns the ProcessManager for the browser context from |web_contents|. | 19 // Returns the ProcessManager for the browser context from |web_contents|. |
| 19 extensions::ProcessManager* GetProcessManager( | 20 extensions::ProcessManager* GetProcessManager( |
| 20 content::WebContents* web_contents) { | 21 content::WebContents* web_contents) { |
| 21 return extensions::ProcessManager::Get(web_contents->GetBrowserContext()); | 22 return extensions::ProcessManager::Get(web_contents->GetBrowserContext()); |
| 22 } | 23 } |
| 23 | 24 |
| 24 // Returns the extension associated with |web_contents| or NULL if there is no | 25 // Returns the extension associated with |web_contents| or NULL if there is no |
| 25 // associated extension (or extensions are not supported). | 26 // associated extension (or extensions are not supported). |
| 26 const Extension* GetExtensionForWebContents( | 27 const Extension* GetExtensionForWebContents( |
| 27 content::WebContents* web_contents) { | 28 content::WebContents* web_contents) { |
| 28 extensions::ProcessManager* pm = GetProcessManager(web_contents); | 29 extensions::ProcessManager* pm = GetProcessManager(web_contents); |
| 29 return pm->GetExtensionForRenderViewHost(web_contents->GetRenderViewHost()); | 30 return pm->GetExtensionForRenderViewHost(web_contents->GetRenderViewHost()); |
| 30 } | 31 } |
| 31 | 32 |
| 32 class JavaScriptDialogExtensionsClientImpl | 33 class JavaScriptDialogExtensionsClientImpl |
| 33 : public JavaScriptDialogExtensionsClient { | 34 : public app_modal_dialogs::JavaScriptDialogExtensionsClient { |
| 34 public: | 35 public: |
| 35 JavaScriptDialogExtensionsClientImpl() {} | 36 JavaScriptDialogExtensionsClientImpl() {} |
| 36 ~JavaScriptDialogExtensionsClientImpl() override {} | 37 ~JavaScriptDialogExtensionsClientImpl() override {} |
| 37 | 38 |
| 38 // JavaScriptDialogExtensionsClient: | 39 // JavaScriptDialogExtensionsClient: |
| 39 void OnDialogOpened(content::WebContents* web_contents) override { | 40 void OnDialogOpened(content::WebContents* web_contents) override { |
| 40 const Extension* extension = GetExtensionForWebContents(web_contents); | 41 const Extension* extension = GetExtensionForWebContents(web_contents); |
| 41 if (extension == nullptr) | 42 if (extension == nullptr) |
| 42 return; | 43 return; |
| 43 | 44 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 } | 68 } |
| 68 return false; | 69 return false; |
| 69 } | 70 } |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogExtensionsClientImpl); | 73 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogExtensionsClientImpl); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 } // namespace | 76 } // namespace |
| 76 | 77 |
| 77 void InstallJavaScriptDialogExtensionsClient() { | 78 void InstallClient() { |
| 78 SetJavaScriptDialogExtensionsClient( | 79 app_modal_dialogs::JavaScriptDialogManager::GetInstance()-> |
| 79 make_scoped_ptr(new JavaScriptDialogExtensionsClientImpl)); | 80 SetExtensionsClient( |
| 81 make_scoped_ptr(new JavaScriptDialogExtensionsClientImpl)); |
| 80 } | 82 } |
| 83 |
| 84 } // namespace javascript_dialog_extensions_client |
| OLD | NEW |