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

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, 6 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 248
248 // Make sure the manifests match if we want to bypass the prompt. 249 // Make sure the manifests match if we want to bypass the prompt.
249 if (approved_ && 250 if (approved_ &&
250 (!expected_manifest_.get() || 251 (!expected_manifest_.get() ||
251 !expected_manifest_->Equals(original_manifest_.get()))) { 252 !expected_manifest_->Equals(original_manifest_.get()))) {
252 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_MANIFEST_INVALID); 253 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_MANIFEST_INVALID);
253 return false; 254 return false;
254 } 255 }
255 256
256 // The checks below are skipped for themes and external installs. 257 // The checks below are skipped for themes and external installs.
258 // TODO(pamg): After ManagementPolicy refactoring is complete, remove this
259 // and other uses of install_source_ that are no longer needed now that the
260 // SandboxedExtensionUnpacker sets extension->location.
257 if (extension->is_theme() || Extension::IsExternalLocation(install_source_)) 261 if (extension->is_theme() || Extension::IsExternalLocation(install_source_))
258 return true; 262 return true;
259 263
260 if (!extensions_enabled_) { 264 if (!extensions_enabled_) {
261 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_NOT_ENABLED); 265 *error = l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_NOT_ENABLED);
262 return false; 266 return false;
263 } 267 }
264 268
265 if (extension_->is_app()) { 269 if (extension_->is_app()) {
266 // If the app was downloaded, apps_require_extension_mime_type_ 270 // If the app was downloaded, apps_require_extension_mime_type_
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 380
377 if (frontend_weak_->extension_prefs() 381 if (frontend_weak_->extension_prefs()
378 ->IsExtensionBlacklisted(extension_->id())) { 382 ->IsExtensionBlacklisted(extension_->id())) {
379 VLOG(1) << "This extension: " << extension_->id() 383 VLOG(1) << "This extension: " << extension_->id()
380 << " is blacklisted. Install failed."; 384 << " is blacklisted. Install failed.";
381 ReportFailureFromUIThread( 385 ReportFailureFromUIThread(
382 l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED)); 386 l10n_util::GetStringUTF16(IDS_EXTENSION_CANT_INSTALL_BLACKLISTED));
383 return; 387 return;
384 } 388 }
385 389
386 if (!frontend_weak_->extension_prefs()->IsExtensionAllowedByPolicy( 390 string16 error;
387 extension_->id(), install_source_)) { 391 if (!ExtensionSystem::Get(profile_)->management_policy()->UserMayLoad(
388 ReportFailureFromUIThread(l10n_util::GetStringFUTF16( 392 extension_, &error)) {
389 IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST, 393 ReportFailureFromUIThread(error);
390 UTF8ToUTF16(extension_->name()),
391 UTF8ToUTF16(extension_->id())));
392 return; 394 return;
393 } 395 }
394 396
395 GURL overlapping_url; 397 GURL overlapping_url;
396 const Extension* overlapping_extension = 398 const Extension* overlapping_extension =
397 frontend_weak_->extensions()-> 399 frontend_weak_->extensions()->
398 GetHostedAppByOverlappingWebExtent(extension_->web_extent()); 400 GetHostedAppByOverlappingWebExtent(extension_->web_extent());
399 if (overlapping_extension && 401 if (overlapping_extension &&
400 overlapping_extension->id() != extension_->id()) { 402 overlapping_extension->id() != extension_->id()) {
401 ReportFailureFromUIThread(l10n_util::GetStringFUTF16( 403 ReportFailureFromUIThread(l10n_util::GetStringFUTF16(
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // Some users (such as the download shelf) need to know when a 589 // Some users (such as the download shelf) need to know when a
588 // CRXInstaller is done. Listening for the EXTENSION_* events 590 // CRXInstaller is done. Listening for the EXTENSION_* events
589 // is problematic because they don't know anything about the 591 // is problematic because they don't know anything about the
590 // extension before it is unpacked, so they cannot filter based 592 // extension before it is unpacked, so they cannot filter based
591 // on the extension. 593 // on the extension.
592 content::NotificationService::current()->Notify( 594 content::NotificationService::current()->Notify(
593 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 595 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
594 content::Source<CrxInstaller>(this), 596 content::Source<CrxInstaller>(this),
595 content::Details<const Extension>(extension)); 597 content::Details<const Extension>(extension));
596 } 598 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/extension_context_menu_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698