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

Side by Side Diff: chrome/browser/extensions/unpacked_installer.cc

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced + mac fix Created 8 years, 6 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 | Annotate | Revision Log
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 #include "chrome/browser/extensions/unpacked_installer.h" 5 #include "chrome/browser/extensions/unpacked_installer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "chrome/browser/extensions/extension_install_ui.h" 10 #include "chrome/browser/extensions/extension_install_prompt.h"
11 #include "chrome/browser/extensions/extension_prefs.h" 11 #include "chrome/browser/extensions/extension_prefs.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/permissions_updater.h" 13 #include "chrome/browser/extensions/permissions_updater.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/extensions/extension_file_util.h" 15 #include "chrome/common/extensions/extension_file_util.h"
16 #include "chrome/common/string_ordinal.h" 16 #include "chrome/common/string_ordinal.h"
17 17
18 using content::BrowserThread; 18 using content::BrowserThread;
19 using extensions::Extension; 19 using extensions::Extension;
20 20
21 namespace { 21 namespace {
22 22
23 const char kUnpackedExtensionsBlacklistedError[] = 23 const char kUnpackedExtensionsBlacklistedError[] =
24 "Loading of unpacked extensions is disabled by the administrator."; 24 "Loading of unpacked extensions is disabled by the administrator.";
25 25
26 // Manages an ExtensionInstallUI for a particular extension. 26 // Manages an ExtensionInstallPrompt for a particular extension.
27 class SimpleExtensionLoadPrompt : public ExtensionInstallUI::Delegate { 27 class SimpleExtensionLoadPrompt : public ExtensionInstallPrompt::Delegate {
28 public: 28 public:
29 SimpleExtensionLoadPrompt(Profile* profile, 29 SimpleExtensionLoadPrompt(Profile* profile,
30 base::WeakPtr<ExtensionService> extension_service, 30 base::WeakPtr<ExtensionService> extension_service,
31 const Extension* extension); 31 const Extension* extension);
32 ~SimpleExtensionLoadPrompt(); 32 ~SimpleExtensionLoadPrompt();
33 33
34 void ShowPrompt(); 34 void ShowPrompt();
35 35
36 // ExtensionInstallUI::Delegate 36 // ExtensionInstallUI::Delegate
37 virtual void InstallUIProceed() OVERRIDE; 37 virtual void InstallUIProceed() OVERRIDE;
38 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 38 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
39 39
40 private: 40 private:
41 base::WeakPtr<ExtensionService> service_weak_; 41 base::WeakPtr<ExtensionService> service_weak_;
42 scoped_ptr<ExtensionInstallUI> install_ui_; 42 scoped_ptr<ExtensionInstallPrompt> install_ui_;
43 scoped_refptr<const Extension> extension_; 43 scoped_refptr<const Extension> extension_;
44 }; 44 };
45 45
46 SimpleExtensionLoadPrompt::SimpleExtensionLoadPrompt( 46 SimpleExtensionLoadPrompt::SimpleExtensionLoadPrompt(
47 Profile* profile, 47 Profile* profile,
48 base::WeakPtr<ExtensionService> extension_service, 48 base::WeakPtr<ExtensionService> extension_service,
49 const Extension* extension) 49 const Extension* extension)
50 : service_weak_(extension_service), 50 : service_weak_(extension_service),
51 install_ui_(new ExtensionInstallUI(profile)), 51 install_ui_(new ExtensionInstallPrompt(profile)),
52 extension_(extension) { 52 extension_(extension) {
53 } 53 }
54 54
55 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { 55 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() {
56 } 56 }
57 57
58 void SimpleExtensionLoadPrompt::ShowPrompt() { 58 void SimpleExtensionLoadPrompt::ShowPrompt() {
59 install_ui_->ConfirmInstall(this, extension_); 59 install_ui_->ConfirmInstall(this, extension_);
60 } 60 }
61 61
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 service_weak_->disabled_extensions(); 224 service_weak_->disabled_extensions();
225 if (service_weak_->show_extensions_prompts() && 225 if (service_weak_->show_extensions_prompts() &&
226 prompt_for_plugins_ && 226 prompt_for_plugins_ &&
227 !extension->plugins().empty() && 227 !extension->plugins().empty() &&
228 !disabled_extensions->Contains(extension->id())) { 228 !disabled_extensions->Contains(extension->id())) {
229 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( 229 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
230 service_weak_->profile(), 230 service_weak_->profile(),
231 service_weak_, 231 service_weak_,
232 extension); 232 extension);
233 prompt->ShowPrompt(); 233 prompt->ShowPrompt();
234 return; // continues in SimpleExtensionLoadPrompt::InstallUI* 234 return; // continues in SimpleExtensionLoadPrompt::InstallPrompt*
235 } 235 }
236 236
237 PermissionsUpdater perms_updater(service_weak_->profile()); 237 PermissionsUpdater perms_updater(service_weak_->profile());
238 perms_updater.GrantActivePermissions(extension); 238 perms_updater.GrantActivePermissions(extension);
239 service_weak_->OnExtensionInstalled(extension, 239 service_weak_->OnExtensionInstalled(extension,
240 false, // Not from web store. 240 false, // Not from web store.
241 StringOrdinal()); 241 StringOrdinal());
242 } 242 }
243 243
244 } // namespace extensions 244 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/webstore_inline_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698