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

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

Issue 11087071: Making ShowExtensionInstallDialog a callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android build Created 8 years, 2 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/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 apps_require_extension_mime_type_(false), 99 apps_require_extension_mime_type_(false),
100 allow_silent_install_(false), 100 allow_silent_install_(false),
101 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), 101 install_cause_(extension_misc::INSTALL_CAUSE_UNSET),
102 creation_flags_(Extension::NO_FLAGS), 102 creation_flags_(Extension::NO_FLAGS),
103 off_store_install_allow_reason_(OffStoreInstallDisallowed), 103 off_store_install_allow_reason_(OffStoreInstallDisallowed),
104 did_handle_successfully_(true), 104 did_handle_successfully_(true),
105 record_oauth2_grant_(false), 105 record_oauth2_grant_(false),
106 error_on_unsupported_requirements_(false), 106 error_on_unsupported_requirements_(false),
107 requirements_checker_(new extensions::RequirementsChecker()), 107 requirements_checker_(new extensions::RequirementsChecker()),
108 has_requirement_errors_(false) { 108 has_requirement_errors_(false) {
109 show_dialog_callback_ =
110 ExtensionInstallPrompt::GetDefaultShowDialogCallback();
109 if (!approval) 111 if (!approval)
110 return; 112 return;
111 113
112 CHECK(profile_->IsSameProfile(approval->profile)); 114 CHECK(profile_->IsSameProfile(approval->profile));
113 if (client_) { 115 if (client_) {
114 client_->install_ui()->SetUseAppInstalledBubble( 116 client_->install_ui()->SetUseAppInstalledBubble(
115 approval->use_app_installed_bubble); 117 approval->use_app_installed_bubble);
116 client_->install_ui()->SetSkipPostInstallUI(approval->skip_post_install_ui); 118 client_->install_ui()->SetSkipPostInstallUI(approval->skip_post_install_ui);
117 } 119 }
118 120
119 if (approval->skip_install_dialog) { 121 if (approval->skip_install_dialog) {
120 // Mark the extension as approved, but save the expected manifest and ID 122 // Mark the extension as approved, but save the expected manifest and ID
121 // so we can check that they match the CRX's. 123 // so we can check that they match the CRX's.
122 approved_ = true; 124 approved_ = true;
123 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); 125 expected_manifest_.reset(approval->parsed_manifest->DeepCopy());
124 expected_id_ = approval->extension_id; 126 expected_id_ = approval->extension_id;
125 record_oauth2_grant_ = approval->record_oauth2_grant; 127 record_oauth2_grant_ = approval->record_oauth2_grant;
126 } 128 }
129
130 show_dialog_callback_ = approval->show_dialog_callback;
127 } 131 }
128 132
129 CrxInstaller::~CrxInstaller() { 133 CrxInstaller::~CrxInstaller() {
130 // Delete the temp directory and crx file as necessary. Note that the 134 // Delete the temp directory and crx file as necessary. Note that the
131 // destructor might be called on any thread, so we post a task to the file 135 // destructor might be called on any thread, so we post a task to the file
132 // thread to make sure the delete happens there. This is a best effort 136 // thread to make sure the delete happens there. This is a best effort
133 // operation since the browser can be shutting down so there might not 137 // operation since the browser can be shutting down so there might not
134 // be a file thread to post to. 138 // be a file thread to post to.
135 if (!temp_dir_.value().empty()) { 139 if (!temp_dir_.value().empty()) {
136 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 140 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 IDS_EXTENSION_OVERLAPPING_WEB_EXTENT, 450 IDS_EXTENSION_OVERLAPPING_WEB_EXTENT,
447 UTF8ToUTF16(overlapping_extension->name())))); 451 UTF8ToUTF16(overlapping_extension->name()))));
448 return; 452 return;
449 } 453 }
450 454
451 current_version_ = 455 current_version_ =
452 frontend_weak_->extension_prefs()->GetVersionString(extension_->id()); 456 frontend_weak_->extension_prefs()->GetVersionString(extension_->id());
453 457
454 if (client_ && (!allow_silent_install_ || !approved_)) { 458 if (client_ && (!allow_silent_install_ || !approved_)) {
455 AddRef(); // Balanced in Proceed() and Abort(). 459 AddRef(); // Balanced in Proceed() and Abort().
456 client_->ConfirmInstall(this, extension_.get()); 460 client_->ConfirmInstall(this, extension_.get(), show_dialog_callback_);
457 } else { 461 } else {
458 if (!BrowserThread::PostTask( 462 if (!BrowserThread::PostTask(
459 BrowserThread::FILE, FROM_HERE, 463 BrowserThread::FILE, FROM_HERE,
460 base::Bind(&CrxInstaller::CompleteInstall, this))) 464 base::Bind(&CrxInstaller::CompleteInstall, this)))
461 NOTREACHED(); 465 NOTREACHED();
462 } 466 }
463 return; 467 return;
464 } 468 }
465 469
466 void CrxInstaller::InstallUIProceed() { 470 void CrxInstaller::InstallUIProceed() {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 // is problematic because they don't know anything about the 654 // is problematic because they don't know anything about the
651 // extension before it is unpacked, so they cannot filter based 655 // extension before it is unpacked, so they cannot filter based
652 // on the extension. 656 // on the extension.
653 content::NotificationService::current()->Notify( 657 content::NotificationService::current()->Notify(
654 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 658 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
655 content::Source<CrxInstaller>(this), 659 content::Source<CrxInstaller>(this),
656 content::Details<const Extension>(extension)); 660 content::Details<const Extension>(extension));
657 } 661 }
658 662
659 } // namespace extensions 663 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698