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

Side by Side Diff: chrome/browser/extensions/extension_reenabler.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 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_REENABLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_REENABLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_REENABLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_REENABLER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
12 #include "base/scoped_observer.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 "chrome/browser/extensions/webstore_data_fetcher_delegate.h" 15 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h"
15 #include "extensions/browser/extension_registry_observer.h" 16 #include "extensions/browser/extension_registry_observer.h"
16 17
17 namespace content { 18 namespace content {
18 class BrowserContext; 19 class BrowserContext;
19 } 20 }
20 21
21 namespace extensions { 22 namespace extensions {
22 23
23 class Extension; 24 class Extension;
24 class ExtensionRegistry; 25 class ExtensionRegistry;
25 class WebstoreDataFetcher; 26 class WebstoreDataFetcher;
26 27
27 // A class to handle reenabling an extension disabled due to a permissions 28 // A class to handle reenabling an extension disabled due to a permissions
28 // increase. 29 // increase.
29 // TODO(devlin): Once we get the UI figured out, we should also have this handle 30 // TODO(devlin): Once we get the UI figured out, we should also have this handle
30 // other disable reasons. 31 // other disable reasons.
31 class ExtensionReenabler : public ExtensionInstallPrompt::Delegate, 32 class ExtensionReenabler : public ExtensionRegistryObserver,
32 public ExtensionRegistryObserver,
33 public WebstoreDataFetcherDelegate { 33 public WebstoreDataFetcherDelegate {
34 public: 34 public:
35 enum ReenableResult { 35 enum ReenableResult {
36 REENABLE_SUCCESS, // The extension has been successfully re-enabled. 36 REENABLE_SUCCESS, // The extension has been successfully re-enabled.
37 USER_CANCELED, // The user chose to not re-enable the extension. 37 USER_CANCELED, // The user chose to not re-enable the extension.
38 NOT_ALLOWED, // The re-enable is not allowed. 38 NOT_ALLOWED, // The re-enable is not allowed.
39 ABORTED, // The re-enable process was aborted due to, e.g., 39 ABORTED, // The re-enable process was aborted due to, e.g.,
40 // shutdown or a bad webstore response. 40 // shutdown or a bad webstore response.
41 }; 41 };
42 42
(...skipping 22 matching lines...) Expand all
65 65
66 private: 66 private:
67 ExtensionReenabler( 67 ExtensionReenabler(
68 const scoped_refptr<const Extension>& extension, 68 const scoped_refptr<const Extension>& extension,
69 content::BrowserContext* browser_context, 69 content::BrowserContext* browser_context,
70 const GURL& referrer_url, 70 const GURL& referrer_url,
71 const Callback& callback, 71 const Callback& callback,
72 content::WebContents* web_contents, 72 content::WebContents* web_contents,
73 const ExtensionInstallPrompt::ShowDialogCallback& show_callback); 73 const ExtensionInstallPrompt::ShowDialogCallback& show_callback);
74 74
75 // ExtensionInstallPrompt::Delegate: 75 void OnInstallPromptDone(ExtensionInstallPrompt::Result result);
76 void InstallUIProceed() override;
77 void InstallUIAbort(bool user_initiated) override;
78 76
79 // ExtensionRegistryObserver: 77 // ExtensionRegistryObserver:
80 void OnExtensionLoaded(content::BrowserContext* browser_context, 78 void OnExtensionLoaded(content::BrowserContext* browser_context,
81 const Extension* extension) override; 79 const Extension* extension) override;
82 void OnExtensionUninstalled(content::BrowserContext* browser_context, 80 void OnExtensionUninstalled(content::BrowserContext* browser_context,
83 const Extension* extension, 81 const Extension* extension,
84 UninstallReason reason) override; 82 UninstallReason reason) override;
85 83
86 // WebstoreDataFetcherDelegate: 84 // WebstoreDataFetcherDelegate:
87 void OnWebstoreRequestFailure() override; 85 void OnWebstoreRequestFailure() override;
(...skipping 25 matching lines...) Expand all
113 111
114 // Indicates whether the re-enable process finished. 112 // Indicates whether the re-enable process finished.
115 bool finished_; 113 bool finished_;
116 114
117 // The data fetcher for retrieving webstore data. 115 // The data fetcher for retrieving webstore data.
118 scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_; 116 scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_;
119 117
120 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 118 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
121 registry_observer_; 119 registry_observer_;
122 120
121 base::WeakPtrFactory<ExtensionReenabler> weak_factory_;
122
123 DISALLOW_COPY_AND_ASSIGN(ExtensionReenabler); 123 DISALLOW_COPY_AND_ASSIGN(ExtensionReenabler);
124 }; 124 };
125 125
126 } // namespace extensions 126 } // namespace extensions
127 127
128 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_REENABLER_H_ 128 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_REENABLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt_unittest.cc ('k') | chrome/browser/extensions/extension_reenabler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698