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

Side by Side Diff: chrome/browser/ui/extensions/extension_enable_flow.h

Issue 660643002: [Refactor] Move creating a browser if necessary to ExtensionInstallDialogView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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 virtual ~ExtensionEnableFlow(); 43 virtual ~ExtensionEnableFlow();
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const extensions::Extension* extension) override; 87 const extensions::Extension* extension) override;
91 virtual void OnExtensionUninstalled( 88 virtual void OnExtensionUninstalled(
92 content::BrowserContext* browser_context, 89 content::BrowserContext* browser_context,
93 const extensions::Extension* extension, 90 const extensions::Extension* extension,
94 extensions::UninstallReason reason) override; 91 extensions::UninstallReason reason) override;
95 92
96 // ExtensionInstallPrompt::Delegate overrides: 93 // ExtensionInstallPrompt::Delegate overrides:
97 virtual void InstallUIProceed() override; 94 virtual void InstallUIProceed() override;
98 virtual void InstallUIAbort(bool user_initiated) override; 95 virtual void InstallUIAbort(bool user_initiated) override;
99 96
100 // content::PageNavigator overrides:
101 virtual content::WebContents* OpenURL(
102 const content::OpenURLParams& params) override;
103
104 Profile* const profile_; 97 Profile* const profile_;
105 const std::string extension_id_; 98 const std::string extension_id_;
106 ExtensionEnableFlowDelegate* const delegate_; // Not owned. 99 ExtensionEnableFlowDelegate* const delegate_; // Not owned.
107 100
108 // Parent web contents for ExtensionInstallPrompt that may be created during 101 // Parent web contents for ExtensionInstallPrompt that may be created during
109 // the flow. Note this is mutually exclusive with |parent_window_| below. 102 // the flow. Note this is mutually exclusive with |parent_window_| below.
110 content::WebContents* parent_contents_; 103 content::WebContents* parent_contents_;
111 104
112 // Parent native window for ExtensionInstallPrompt. Note this is mutually 105 // Parent native window for ExtensionInstallPrompt. Note this is mutually
113 // exclusive with |parent_contents_| above. 106 // exclusive with |parent_contents_| above.
114 gfx::NativeWindow parent_window_; 107 gfx::NativeWindow parent_window_;
115 108
116 // Called to acquire a parent window for the prompt. This is used for clients 109 // Called to acquire a parent window for the prompt. This is used for clients
117 // who only want to create a window if it is required. 110 // who only want to create a window if it is required.
118 base::Callback<gfx::NativeWindow(void)> window_getter_; 111 base::Callback<gfx::NativeWindow(void)> window_getter_;
119 112
120 scoped_ptr<ExtensionInstallPrompt> prompt_; 113 scoped_ptr<ExtensionInstallPrompt> prompt_;
121 content::NotificationRegistrar registrar_; 114 content::NotificationRegistrar registrar_;
122 115
123 // Listen to extension load notification. 116 // Listen to extension load notification.
124 ScopedObserver<extensions::ExtensionRegistry, 117 ScopedObserver<extensions::ExtensionRegistry,
125 extensions::ExtensionRegistryObserver> 118 extensions::ExtensionRegistryObserver>
126 extension_registry_observer_; 119 extension_registry_observer_;
127 120
128 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow); 121 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow);
129 }; 122 };
130 123
131 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ 124 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698