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 #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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 service_weak_->disabled_extensions(); | 228 service_weak_->disabled_extensions(); |
229 if (service_weak_->show_extensions_prompts() && | 229 if (service_weak_->show_extensions_prompts() && |
230 prompt_for_plugins_ && | 230 prompt_for_plugins_ && |
231 !extension->plugins().empty() && | 231 !extension->plugins().empty() && |
232 !disabled_extensions->Contains(extension->id())) { | 232 !disabled_extensions->Contains(extension->id())) { |
233 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( | 233 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( |
234 service_weak_->profile(), | 234 service_weak_->profile(), |
235 service_weak_, | 235 service_weak_, |
236 extension); | 236 extension); |
237 prompt->ShowPrompt(); | 237 prompt->ShowPrompt(); |
238 return; // continues in SimpleExtensionLoadPrompt::InstallUI* | 238 return; // continues in SimpleExtensionLoadPrompt::InstallPrompt* |
239 } | 239 } |
240 | 240 |
241 PermissionsUpdater perms_updater(service_weak_->profile()); | 241 PermissionsUpdater perms_updater(service_weak_->profile()); |
242 perms_updater.GrantActivePermissions(extension); | 242 perms_updater.GrantActivePermissions(extension); |
243 service_weak_->OnExtensionInstalled(extension, | 243 service_weak_->OnExtensionInstalled(extension, |
244 false, // Not from web store. | 244 false, // Not from web store. |
245 StringOrdinal()); | 245 StringOrdinal()); |
246 } | 246 } |
247 | 247 |
248 } // namespace extensions | 248 } // namespace extensions |
OLD | NEW |