| 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 "chrome/browser/extensions/extension_install_prompt.h" | 14 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/page_navigator.h" | 17 #include "content/public/browser/page_navigator.h" |
| 18 #include "extensions/browser/extension_registry_observer.h" |
| 17 | 19 |
| 18 class ExtensionEnableFlowDelegate; | 20 class ExtensionEnableFlowDelegate; |
| 19 | 21 |
| 20 namespace content { | 22 namespace content { |
| 21 class PageNavigator; | 23 class PageNavigator; |
| 22 class WebContents; | 24 class WebContents; |
| 23 } | 25 } |
| 24 | 26 |
| 27 namespace extensions { |
| 28 class ExtensionRegistry; |
| 29 } |
| 30 |
| 25 // ExtensionEnableFlow performs an UI flow to enable a disabled/terminated | 31 // ExtensionEnableFlow performs an UI flow to enable a disabled/terminated |
| 26 // extension. It calls its delegate when enabling is done or is aborted. | 32 // extension. It calls its delegate when enabling is done or is aborted. |
| 27 // Callback on the delegate might be called synchronously if there is no | 33 // Callback on the delegate might be called synchronously if there is no |
| 28 // permission change while the extension is disabled/terminated (or the | 34 // permission change while the extension is disabled/terminated (or the |
| 29 // extension is enabled already). Otherwise, a re-enable install prompt is | 35 // extension is enabled already). Otherwise, a re-enable install prompt is |
| 30 // shown to user. The extension is enabled when user acknowledges it or the | 36 // shown to user. The extension is enabled when user acknowledges it or the |
| 31 // flow is aborted when user declines it. | 37 // flow is aborted when user declines it. |
| 32 class ExtensionEnableFlow : public ExtensionInstallPrompt::Delegate, | 38 class ExtensionEnableFlow : public ExtensionInstallPrompt::Delegate, |
| 33 public content::PageNavigator, | 39 public content::PageNavigator, |
| 34 public content::NotificationObserver { | 40 public content::NotificationObserver, |
| 41 public extensions::ExtensionRegistryObserver { |
| 35 public: | 42 public: |
| 36 ExtensionEnableFlow(Profile* profile, | 43 ExtensionEnableFlow(Profile* profile, |
| 37 const std::string& extension_id, | 44 const std::string& extension_id, |
| 38 ExtensionEnableFlowDelegate* delegate); | 45 ExtensionEnableFlowDelegate* delegate); |
| 39 virtual ~ExtensionEnableFlow(); | 46 virtual ~ExtensionEnableFlow(); |
| 40 | 47 |
| 41 // Starts the flow and the logic continues on |delegate_| after enabling is | 48 // Starts the flow and the logic continues on |delegate_| after enabling is |
| 42 // finished or aborted. Note that |delegate_| could be called synchronously | 49 // finished or aborted. Note that |delegate_| could be called synchronously |
| 43 // before this call returns when there is no need to show UI to finish the | 50 // before this call returns when there is no need to show UI to finish the |
| 44 // enabling flow. Three variations of the flow are supported: | 51 // enabling flow. Three variations of the flow are supported: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 | 77 |
| 71 // Starts/stops observing extension load notifications. | 78 // Starts/stops observing extension load notifications. |
| 72 void StartObserving(); | 79 void StartObserving(); |
| 73 void StopObserving(); | 80 void StopObserving(); |
| 74 | 81 |
| 75 // content::NotificationObserver overrides: | 82 // content::NotificationObserver overrides: |
| 76 virtual void Observe(int type, | 83 virtual void Observe(int type, |
| 77 const content::NotificationSource& source, | 84 const content::NotificationSource& source, |
| 78 const content::NotificationDetails& details) OVERRIDE; | 85 const content::NotificationDetails& details) OVERRIDE; |
| 79 | 86 |
| 87 // extensions::ExtensionRegistryObserver overrides: |
| 88 virtual void OnExtensionLoaded( |
| 89 content::BrowserContext* browser_context, |
| 90 const extensions::Extension* extension) OVERRIDE; |
| 91 |
| 80 // ExtensionInstallPrompt::Delegate overrides: | 92 // ExtensionInstallPrompt::Delegate overrides: |
| 81 virtual void InstallUIProceed() OVERRIDE; | 93 virtual void InstallUIProceed() OVERRIDE; |
| 82 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 94 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
| 83 | 95 |
| 84 // content::PageNavigator overrides: | 96 // content::PageNavigator overrides: |
| 85 virtual content::WebContents* OpenURL( | 97 virtual content::WebContents* OpenURL( |
| 86 const content::OpenURLParams& params) OVERRIDE; | 98 const content::OpenURLParams& params) OVERRIDE; |
| 87 | 99 |
| 88 Profile* const profile_; | 100 Profile* const profile_; |
| 89 const std::string extension_id_; | 101 const std::string extension_id_; |
| 90 ExtensionEnableFlowDelegate* const delegate_; // Not owned. | 102 ExtensionEnableFlowDelegate* const delegate_; // Not owned. |
| 91 | 103 |
| 92 // Parent web contents for ExtensionInstallPrompt that may be created during | 104 // Parent web contents for ExtensionInstallPrompt that may be created during |
| 93 // the flow. Note this is mutually exclusive with |parent_window_| below. | 105 // the flow. Note this is mutually exclusive with |parent_window_| below. |
| 94 content::WebContents* parent_contents_; | 106 content::WebContents* parent_contents_; |
| 95 | 107 |
| 96 // Parent native window for ExtensionInstallPrompt. Note this is mutually | 108 // Parent native window for ExtensionInstallPrompt. Note this is mutually |
| 97 // exclusive with |parent_contents_| above. | 109 // exclusive with |parent_contents_| above. |
| 98 gfx::NativeWindow parent_window_; | 110 gfx::NativeWindow parent_window_; |
| 99 | 111 |
| 100 // Called to acquire a parent window for the prompt. This is used for clients | 112 // Called to acquire a parent window for the prompt. This is used for clients |
| 101 // who only want to create a window if it is required. | 113 // who only want to create a window if it is required. |
| 102 base::Callback<gfx::NativeWindow(void)> window_getter_; | 114 base::Callback<gfx::NativeWindow(void)> window_getter_; |
| 103 | 115 |
| 104 scoped_ptr<ExtensionInstallPrompt> prompt_; | 116 scoped_ptr<ExtensionInstallPrompt> prompt_; |
| 105 content::NotificationRegistrar registrar_; | 117 content::NotificationRegistrar registrar_; |
| 106 | 118 |
| 119 // Listen to extension load notification. |
| 120 ScopedObserver<extensions::ExtensionRegistry, |
| 121 extensions::ExtensionRegistryObserver> |
| 122 extension_registry_observer_; |
| 123 |
| 107 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow); | 124 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow); |
| 108 }; | 125 }; |
| 109 | 126 |
| 110 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ | 127 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ |
| OLD | NEW |