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

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

Issue 10382149: Refactor the various ways to control what users can do to extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing comments from partial review Created 8 years, 7 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"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/scoped_temp_dir.h" 16 #include "base/scoped_temp_dir.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/threading/thread_restrictions.h" 19 #include "base/threading/thread_restrictions.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "base/version.h" 22 #include "base/version.h"
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/extensions/convert_user_script.h" 24 #include "chrome/browser/extensions/convert_user_script.h"
25 #include "chrome/browser/extensions/convert_web_app.h" 25 #include "chrome/browser/extensions/convert_web_app.h"
26 #include "chrome/browser/extensions/default_apps_trial.h" 26 #include "chrome/browser/extensions/default_apps_trial.h"
27 #include "chrome/browser/extensions/extension_error_reporter.h" 27 #include "chrome/browser/extensions/extension_error_reporter.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/extension_system.h"
29 #include "chrome/browser/extensions/permissions_updater.h" 30 #include "chrome/browser/extensions/permissions_updater.h"
30 #include "chrome/browser/extensions/webstore_installer.h" 31 #include "chrome/browser/extensions/webstore_installer.h"
31 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/shell_integration.h" 33 #include "chrome/browser/shell_integration.h"
33 #include "chrome/browser/web_applications/web_app.h" 34 #include "chrome/browser/web_applications/web_app.h"
34 #include "chrome/common/chrome_notification_types.h" 35 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_paths.h" 36 #include "chrome/common/chrome_paths.h"
36 #include "chrome/common/extensions/extension_constants.h" 37 #include "chrome/common/extensions/extension_constants.h"
37 #include "chrome/common/extensions/extension_file_util.h" 38 #include "chrome/common/extensions/extension_file_util.h"
38 #include "chrome/common/extensions/extension_icon_set.h" 39 #include "chrome/common/extensions/extension_icon_set.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 211
211 // Make sure the manifests match if we want to bypass the prompt. 212 // Make sure the manifests match if we want to bypass the prompt.
212 if (approved_ && 213 if (approved_ &&
213 (!expected_manifest_.get() || 214 (!expected_manifest_.get() ||
214 !expected_manifest_->Equals(original_manifest_.get()))) { 215 !expected_manifest_->Equals(original_manifest_.get()))) {
215 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_MANIFEST_INVALID); 216 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_MANIFEST_INVALID);
216 return false; 217 return false;
217 } 218 }
218 219
219 // The checks below are skipped for themes and external installs. 220 // The checks below are skipped for themes and external installs.
221 // TODO(pamg): After ManagementPolicy refactoring is complete, remove this
222 // and other uses of install_source_ that are no longer needed now that the
223 // SandboxedExtensionUnpacker sets extension->location.
Aaron Boodman 2012/05/29 03:03:08 Hooray.
220 if (extension->is_theme() || Extension::IsExternalLocation(install_source_)) 224 if (extension->is_theme() || Extension::IsExternalLocation(install_source_))
221 return true; 225 return true;
222 226
223 if (!extensions_enabled_) { 227 if (!extensions_enabled_) {
224 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_NOT_ENABLED); 228 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_NOT_ENABLED);
225 return false; 229 return false;
226 } 230 }
227 231
228 if (extension_->is_app()) { 232 if (extension_->is_app()) {
229 // If the app was downloaded, apps_require_extension_mime_type_ 233 // If the app was downloaded, apps_require_extension_mime_type_
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 344
341 if (frontend_weak_->extension_prefs() 345 if (frontend_weak_->extension_prefs()
342 ->IsExtensionBlacklisted(extension_->id())) { 346 ->IsExtensionBlacklisted(extension_->id())) {
343 VLOG(1) << "This extension: " << extension_->id() 347 VLOG(1) << "This extension: " << extension_->id()
344 << " is blacklisted. Install failed."; 348 << " is blacklisted. Install failed.";
345 ReportFailureFromUIThread( 349 ReportFailureFromUIThread(
346 l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED)); 350 l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED));
347 return; 351 return;
348 } 352 }
349 353
350 if (!frontend_weak_->extension_prefs()->IsExtensionAllowedByPolicy( 354 string16 error;
351 extension_->id(), install_source_)) { 355 if (!ExtensionSystem::Get(profile_)->management_policy()->UserMayLoad(
352 ReportFailureFromUIThread(l10n_util::GetStringFUTF16( 356 extension_, &error)) {
353 IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST, 357 ReportFailureFromUIThread(error);
354 UTF8ToUTF16(extension_->name()),
355 UTF8ToUTF16(extension_->id())));
356 return; 358 return;
357 } 359 }
358 360
359 GURL overlapping_url; 361 GURL overlapping_url;
360 const Extension* overlapping_extension = 362 const Extension* overlapping_extension =
361 frontend_weak_->extensions()-> 363 frontend_weak_->extensions()->
362 GetHostedAppByOverlappingWebExtent(extension_->web_extent()); 364 GetHostedAppByOverlappingWebExtent(extension_->web_extent());
363 if (overlapping_extension && 365 if (overlapping_extension &&
364 overlapping_extension->id() != extension_->id()) { 366 overlapping_extension->id() != extension_->id()) {
365 ReportFailureFromUIThread(l10n_util::GetStringFUTF16( 367 ReportFailureFromUIThread(l10n_util::GetStringFUTF16(
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 // Some users (such as the download shelf) need to know when a 553 // Some users (such as the download shelf) need to know when a
552 // CRXInstaller is done. Listening for the EXTENSION_* events 554 // CRXInstaller is done. Listening for the EXTENSION_* events
553 // is problematic because they don't know anything about the 555 // is problematic because they don't know anything about the
554 // extension before it is unpacked, so they cannot filter based 556 // extension before it is unpacked, so they cannot filter based
555 // on the extension. 557 // on the extension.
556 content::NotificationService::current()->Notify( 558 content::NotificationService::current()->Notify(
557 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 559 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
558 content::Source<CrxInstaller>(this), 560 content::Source<CrxInstaller>(this),
559 content::Details<const Extension>(extension)); 561 content::Details<const Extension>(extension));
560 } 562 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698