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

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

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
13 #include "base/scoped_observer.h" 14 #include "base/scoped_observer.h"
14 #include "chrome/browser/extensions/extension_install_prompt.h" 15 #include "chrome/browser/extensions/extension_install_prompt.h"
15 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
17 #include "extensions/browser/extension_registry_observer.h" 18 #include "extensions/browser/extension_registry_observer.h"
18 19
19 class ExtensionEnableFlowDelegate; 20 class ExtensionEnableFlowDelegate;
20 21
21 namespace content { 22 namespace content {
22 class WebContents; 23 class WebContents;
23 } 24 }
24 25
25 namespace extensions { 26 namespace extensions {
26 class ExtensionRegistry; 27 class ExtensionRegistry;
27 } 28 }
28 29
29 // ExtensionEnableFlow performs an UI flow to enable a disabled/terminated 30 // ExtensionEnableFlow performs an UI flow to enable a disabled/terminated
30 // extension. It calls its delegate when enabling is done or is aborted. 31 // extension. It calls its delegate when enabling is done or is aborted.
31 // Callback on the delegate might be called synchronously if there is no 32 // Callback on the delegate might be called synchronously if there is no
32 // permission change while the extension is disabled/terminated (or the 33 // permission change while the extension is disabled/terminated (or the
33 // extension is enabled already). Otherwise, a re-enable install prompt is 34 // extension is enabled already). Otherwise, a re-enable install prompt is
34 // shown to user. The extension is enabled when user acknowledges it or the 35 // shown to user. The extension is enabled when user acknowledges it or the
35 // flow is aborted when user declines it. 36 // flow is aborted when user declines it.
36 class ExtensionEnableFlow : public ExtensionInstallPrompt::Delegate, 37 class ExtensionEnableFlow : public content::NotificationObserver,
37 public content::NotificationObserver,
38 public extensions::ExtensionRegistryObserver { 38 public extensions::ExtensionRegistryObserver {
39 public: 39 public:
40 ExtensionEnableFlow(Profile* profile, 40 ExtensionEnableFlow(Profile* profile,
41 const std::string& extension_id, 41 const std::string& extension_id,
42 ExtensionEnableFlowDelegate* delegate); 42 ExtensionEnableFlowDelegate* delegate);
43 ~ExtensionEnableFlow() override; 43 ~ExtensionEnableFlow() override;
44 44
45 // 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
46 // finished or aborted. Note that |delegate_| could be called synchronously 46 // finished or aborted. Note that |delegate_| could be called synchronously
47 // before this call returns when there is no need to show UI to finish the 47 // before this call returns when there is no need to show UI to finish the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const content::NotificationSource& source, 81 const content::NotificationSource& source,
82 const content::NotificationDetails& details) override; 82 const content::NotificationDetails& details) override;
83 83
84 // extensions::ExtensionRegistryObserver overrides: 84 // extensions::ExtensionRegistryObserver overrides:
85 void OnExtensionLoaded(content::BrowserContext* browser_context, 85 void OnExtensionLoaded(content::BrowserContext* browser_context,
86 const extensions::Extension* extension) override; 86 const extensions::Extension* extension) override;
87 void OnExtensionUninstalled(content::BrowserContext* browser_context, 87 void OnExtensionUninstalled(content::BrowserContext* browser_context,
88 const extensions::Extension* extension, 88 const extensions::Extension* extension,
89 extensions::UninstallReason reason) override; 89 extensions::UninstallReason reason) override;
90 90
91 // ExtensionInstallPrompt::Delegate overrides: 91 void InstallPromptDone(ExtensionInstallPrompt::Result result);
92 void InstallUIProceed() override;
93 void InstallUIAbort(bool user_initiated) override;
94 92
95 Profile* const profile_; 93 Profile* const profile_;
96 const std::string extension_id_; 94 const std::string extension_id_;
97 ExtensionEnableFlowDelegate* const delegate_; // Not owned. 95 ExtensionEnableFlowDelegate* const delegate_; // Not owned.
98 96
99 // Parent web contents for ExtensionInstallPrompt that may be created during 97 // Parent web contents for ExtensionInstallPrompt that may be created during
100 // the flow. Note this is mutually exclusive with |parent_window_| below. 98 // the flow. Note this is mutually exclusive with |parent_window_| below.
101 content::WebContents* parent_contents_; 99 content::WebContents* parent_contents_;
102 100
103 // Parent native window for ExtensionInstallPrompt. Note this is mutually 101 // Parent native window for ExtensionInstallPrompt. Note this is mutually
104 // exclusive with |parent_contents_| above. 102 // exclusive with |parent_contents_| above.
105 gfx::NativeWindow parent_window_; 103 gfx::NativeWindow parent_window_;
106 104
107 // Called to acquire a parent window for the prompt. This is used for clients 105 // Called to acquire a parent window for the prompt. This is used for clients
108 // who only want to create a window if it is required. 106 // who only want to create a window if it is required.
109 base::Callback<gfx::NativeWindow(void)> window_getter_; 107 base::Callback<gfx::NativeWindow(void)> window_getter_;
110 108
111 scoped_ptr<ExtensionInstallPrompt> prompt_; 109 scoped_ptr<ExtensionInstallPrompt> prompt_;
112 content::NotificationRegistrar registrar_; 110 content::NotificationRegistrar registrar_;
113 111
114 // Listen to extension load notification. 112 // Listen to extension load notification.
115 ScopedObserver<extensions::ExtensionRegistry, 113 ScopedObserver<extensions::ExtensionRegistry,
116 extensions::ExtensionRegistryObserver> 114 extensions::ExtensionRegistryObserver>
117 extension_registry_observer_; 115 extension_registry_observer_;
118 116
117 base::WeakPtrFactory<ExtensionEnableFlow> weak_ptr_factory_;
118
119 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow); 119 DISALLOW_COPY_AND_ASSIGN(ExtensionEnableFlow);
120 }; 120 };
121 121
122 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_ 122 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ENABLE_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698