| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/command_line.h" | |
| 10 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 12 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
| 13 #include "chrome/browser/extensions/extension_error_reporter.h" | 12 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 14 #include "chrome/browser/extensions/extension_install_prompt.h" | 13 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 15 #include "chrome/browser/extensions/extension_install_ui.h" | 14 #include "chrome/browser/extensions/extension_install_ui.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/permissions_updater.h" | 16 #include "chrome/browser/extensions/permissions_updater.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_switches.h" | |
| 20 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 18 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 21 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 22 #include "extensions/browser/extension_prefs.h" | 20 #include "extensions/browser/extension_prefs.h" |
| 23 #include "extensions/browser/extension_registry.h" | 21 #include "extensions/browser/extension_registry.h" |
| 24 #include "extensions/browser/install_flag.h" | 22 #include "extensions/browser/install_flag.h" |
| 25 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/extension_l10n_util.h" | 24 #include "extensions/common/extension_l10n_util.h" |
| 27 #include "extensions/common/file_util.h" | 25 #include "extensions/common/file_util.h" |
| 28 #include "extensions/common/id_util.h" | 26 #include "extensions/common/id_util.h" |
| 29 #include "extensions/common/manifest.h" | 27 #include "extensions/common/manifest.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 : install_ui_(ExtensionInstallUI::CreateInstallPromptWithProfile( | 62 : install_ui_(ExtensionInstallUI::CreateInstallPromptWithProfile( |
| 65 profile)), | 63 profile)), |
| 66 extension_(extension), | 64 extension_(extension), |
| 67 callback_(callback) { | 65 callback_(callback) { |
| 68 } | 66 } |
| 69 | 67 |
| 70 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { | 68 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { |
| 71 } | 69 } |
| 72 | 70 |
| 73 void SimpleExtensionLoadPrompt::ShowPrompt() { | 71 void SimpleExtensionLoadPrompt::ShowPrompt() { |
| 74 std::string confirm = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 72 switch (ExtensionInstallPrompt::g_auto_confirm_for_tests) { |
| 75 switches::kAppsGalleryInstallAutoConfirmForTests); | 73 case ExtensionInstallPrompt::NONE: |
| 76 if (confirm == "accept") { | 74 install_ui_->ConfirmInstall( |
| 77 InstallUIProceed(); | 75 this, |
| 78 return; | 76 extension_.get(), |
| 77 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
| 78 break; |
| 79 case ExtensionInstallPrompt::ACCEPT: |
| 80 InstallUIProceed(); |
| 81 break; |
| 82 case ExtensionInstallPrompt::CANCEL: |
| 83 InstallUIAbort(false); |
| 79 } | 84 } |
| 80 if (confirm == "cancel") { | |
| 81 InstallUIAbort(false); | |
| 82 return; | |
| 83 } | |
| 84 | |
| 85 install_ui_->ConfirmInstall( | |
| 86 this, | |
| 87 extension_.get(), | |
| 88 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | |
| 89 } | 85 } |
| 90 | 86 |
| 91 void SimpleExtensionLoadPrompt::InstallUIProceed() { | 87 void SimpleExtensionLoadPrompt::InstallUIProceed() { |
| 92 callback_.Run(); | 88 callback_.Run(); |
| 93 delete this; | 89 delete this; |
| 94 } | 90 } |
| 95 | 91 |
| 96 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) { | 92 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) { |
| 97 delete this; | 93 delete this; |
| 98 } | 94 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 309 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 314 | 310 |
| 315 PermissionsUpdater perms_updater(service_weak_->profile()); | 311 PermissionsUpdater perms_updater(service_weak_->profile()); |
| 316 perms_updater.GrantActivePermissions(extension()); | 312 perms_updater.GrantActivePermissions(extension()); |
| 317 | 313 |
| 318 service_weak_->OnExtensionInstalled( | 314 service_weak_->OnExtensionInstalled( |
| 319 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); | 315 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); |
| 320 } | 316 } |
| 321 | 317 |
| 322 } // namespace extensions | 318 } // namespace extensions |
| OLD | NEW |