| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ |
| 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
| 14 #include "chrome/browser/extensions/extension_install_prompt.h" | 14 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/page_navigator.h" | |
| 18 #include "extensions/browser/extension_registry_observer.h" | 17 #include "extensions/browser/extension_registry_observer.h" |
| 19 | 18 |
| 20 class ExtensionEnableFlowDelegate; | 19 class ExtensionEnableFlowDelegate; |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 class PageNavigator; | |
| 24 class WebContents; | 22 class WebContents; |
| 25 } | 23 } |
| 26 | 24 |
| 27 namespace extensions { | 25 namespace extensions { |
| 28 class ExtensionRegistry; | 26 class ExtensionRegistry; |
| 29 } | 27 } |
| 30 | 28 |
| 31 // ExtensionEnableFlow performs an UI flow to enable a disabled/terminated | 29 // ExtensionEnableFlow performs an UI flow to enable a disabled/terminated |
| 32 // extension. It calls its delegate when enabling is done or is aborted. | 30 // extension. It calls its delegate when enabling is done or is aborted. |
| 33 // Callback on the delegate might be called synchronously if there is no | 31 // Callback on the delegate might be called synchronously if there is no |
| 34 // permission change while the extension is disabled/terminated (or the | 32 // permission change while the extension is disabled/terminated (or the |
| 35 // extension is enabled already). Otherwise, a re-enable install prompt is | 33 // extension is enabled already). Otherwise, a re-enable install prompt is |
| 36 // shown to user. The extension is enabled when user acknowledges it or the | 34 // shown to user. The extension is enabled when user acknowledges it or the |
| 37 // flow is aborted when user declines it. | 35 // flow is aborted when user declines it. |
| 38 class ExtensionEnableFlow : public ExtensionInstallPrompt::Delegate, | 36 class ExtensionEnableFlow : public ExtensionInstallPrompt::Delegate, |
| 39 public content::PageNavigator, | |
| 40 public content::NotificationObserver, | 37 public content::NotificationObserver, |
| 41 public extensions::ExtensionRegistryObserver { | 38 public extensions::ExtensionRegistryObserver { |
| 42 public: | 39 public: |
| 43 ExtensionEnableFlow(Profile* profile, | 40 ExtensionEnableFlow(Profile* profile, |
| 44 const std::string& extension_id, | 41 const std::string& extension_id, |
| 45 ExtensionEnableFlowDelegate* delegate); | 42 ExtensionEnableFlowDelegate* delegate); |
| 46 ~ExtensionEnableFlow() override; | 43 ~ExtensionEnableFlow() override; |
| 47 | 44 |
| 48 // Starts the flow and the logic continues on |delegate_| after enabling is | 45 // Starts the flow and the logic continues on |delegate_| after enabling is |
| 49 // finished or aborted. Note that |delegate_| could be called synchronously | 46 // finished or aborted. Note that |delegate_| could be called synchronously |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void OnExtensionLoaded(content::BrowserContext* browser_context, | 85 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 89 const extensions::Extension* extension) override; | 86 const extensions::Extension* extension) override; |
| 90 void OnExtensionUninstalled(content::BrowserContext* browser_context, | 87 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 91 const extensions::Extension* extension, | 88 const extensions::Extension* extension, |
| 92 extensions::UninstallReason reason) override; | 89 extensions::UninstallReason reason) override; |
| 93 | 90 |
| 94 // ExtensionInstallPrompt::Delegate overrides: | 91 // ExtensionInstallPrompt::Delegate overrides: |
| 95 void InstallUIProceed() override; | 92 void InstallUIProceed() override; |
| 96 void InstallUIAbort(bool user_initiated) override; | 93 void InstallUIAbort(bool user_initiated) override; |
| 97 | 94 |
| 98 // content::PageNavigator overrides: | |
| 99 content::WebContents* OpenURL(const content::OpenURLParams& params) override; | |
| 100 | |
| 101 Profile* const profile_; | 95 Profile* const profile_; |
| 102 const std::string extension_id_; | 96 const std::string extension_id_; |
| 103 ExtensionEnableFlowDelegate* const delegate_; // Not owned. | 97 ExtensionEnableFlowDelegate* const delegate_; // Not owned. |
| 104 | 98 |
| 105 // Parent web contents for ExtensionInstallPrompt that may be created during | 99 // Parent web contents for ExtensionInstallPrompt that may be created during |
| 106 // the flow. Note this is mutually exclusive with |parent_window_| below. | 100 // the flow. Note this is mutually exclusive with |parent_window_| below. |
| 107 content::WebContents* parent_contents_; | 101 content::WebContents* parent_contents_; |
| 108 | 102 |
| 109 // Parent native window for ExtensionInstallPrompt. Note this is mutually | 103 // Parent native window for ExtensionInstallPrompt. Note this is mutually |
| 110 // exclusive with |parent_contents_| above. | 104 // exclusive with |parent_contents_| above. |
| 111 gfx::NativeWindow parent_window_; | 105 gfx::NativeWindow parent_window_; |
| 112 | 106 |
| 113 // Called to acquire a parent window for the prompt. This is used for clients | 107 // Called to acquire a parent window for the prompt. This is used for clients |
| 114 // who only want to create a window if it is required. | 108 // who only want to create a window if it is required. |
| 115 base::Callback<gfx::NativeWindow(void)> window_getter_; | 109 base::Callback<gfx::NativeWindow(void)> window_getter_; |
| 116 | 110 |
| 117 scoped_ptr<ExtensionInstallPrompt> prompt_; | 111 scoped_ptr<ExtensionInstallPrompt> prompt_; |
| 118 content::NotificationRegistrar registrar_; | 112 content::NotificationRegistrar registrar_; |
| 119 | 113 |
| 120 // Listen to extension load notification. | 114 // Listen to extension load notification. |
| 121 ScopedObserver<extensions::ExtensionRegistry, | 115 ScopedObserver<extensions::ExtensionRegistry, |
| 122 extensions::ExtensionRegistryObserver> | 116 extensions::ExtensionRegistryObserver> |
| 123 extension_registry_observer_; | 117 extension_registry_observer_; |
| 124 | 118 |
| 125 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow); | 119 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow); |
| 126 }; | 120 }; |
| 127 | 121 |
| 128 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ | 122 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ |
| OLD | NEW |