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

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: 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 341
341 if (frontend_weak_->extension_prefs() 342 if (frontend_weak_->extension_prefs()
342 ->IsExtensionBlacklisted(extension_->id())) { 343 ->IsExtensionBlacklisted(extension_->id())) {
343 VLOG(1) << "This extension: " << extension_->id() 344 VLOG(1) << "This extension: " << extension_->id()
344 << " is blacklisted. Install failed."; 345 << " is blacklisted. Install failed.";
345 ReportFailureFromUIThread( 346 ReportFailureFromUIThread(
346 l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED)); 347 l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED));
347 return; 348 return;
348 } 349 }
349 350
350 if (!frontend_weak_->extension_prefs()->IsExtensionAllowedByPolicy( 351 string16 error;
351 extension_->id(), install_source_)) { 352 if (!ExtensionSystem::Get(profile_)->management_policy()->UserMayLoad(
Pam (message me for reviews) 2012/05/22 12:51:07 On 2012/05/17 22:41:06, Aaron Boodman wrote: > Ext
352 ReportFailureFromUIThread(l10n_util::GetStringFUTF16( 353 extension_, install_source_, &error)) {
353 IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST, 354 ReportFailureFromUIThread(error);
354 UTF8ToUTF16(extension_->name()),
355 UTF8ToUTF16(extension_->id())));
356 return; 355 return;
357 } 356 }
358 357
359 GURL overlapping_url; 358 GURL overlapping_url;
360 const Extension* overlapping_extension = 359 const Extension* overlapping_extension =
361 frontend_weak_->extensions()-> 360 frontend_weak_->extensions()->
362 GetHostedAppByOverlappingWebExtent(extension_->web_extent()); 361 GetHostedAppByOverlappingWebExtent(extension_->web_extent());
363 if (overlapping_extension && 362 if (overlapping_extension &&
364 overlapping_extension->id() != extension_->id()) { 363 overlapping_extension->id() != extension_->id()) {
365 ReportFailureFromUIThread(l10n_util::GetStringFUTF16( 364 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 550 // Some users (such as the download shelf) need to know when a
552 // CRXInstaller is done. Listening for the EXTENSION_* events 551 // CRXInstaller is done. Listening for the EXTENSION_* events
553 // is problematic because they don't know anything about the 552 // is problematic because they don't know anything about the
554 // extension before it is unpacked, so they cannot filter based 553 // extension before it is unpacked, so they cannot filter based
555 // on the extension. 554 // on the extension.
556 content::NotificationService::current()->Notify( 555 content::NotificationService::current()->Notify(
557 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 556 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
558 content::Source<CrxInstaller>(this), 557 content::Source<CrxInstaller>(this),
559 content::Details<const Extension>(extension)); 558 content::Details<const Extension>(extension));
560 } 559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698