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

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

Issue 10689097: Enforce the 'requirements' field in manifests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
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/installed_loader.h" 5 #include "chrome/browser/extensions/installed_loader.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) { 69 void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) {
70 std::string error; 70 std::string error;
71 scoped_refptr<const Extension> extension(NULL); 71 scoped_refptr<const Extension> extension(NULL);
72 if (info.extension_manifest.get()) { 72 if (info.extension_manifest.get()) {
73 extension = Extension::Create( 73 extension = Extension::Create(
74 info.extension_path, 74 info.extension_path,
75 info.extension_location, 75 info.extension_location,
76 *info.extension_manifest, 76 *info.extension_manifest,
77 GetCreationFlags(&info), 77 GetCreationFlags(&info),
78 &error); 78 &error);
79 if (extension_prefs_->HasUnsupportedRequirements(extension->id())) {
Aaron Boodman 2012/08/01 03:58:54 Won't the extension be disabled if it is installed
eaugusti 2012/08/03 01:06:26 The extension will remain disabled, but I think th
80 std::vector<std::string> requirement_errors =
81 extension_prefs_->GetUnsupportedRequirements(extension->id());
82 extensions::Extension::InstallWarningVector install_warnings;
83 std::vector<std::string>::iterator it;
84 for (it = requirement_errors.begin(); it != requirement_errors.end();
85 ++it) {
86 install_warnings.push_back(Extension::InstallWarning(
87 Extension::InstallWarning::FORMAT_TEXT, *it));
88 }
89 const_cast<Extension*>(extension.get())->AddInstallWarnings(
90 install_warnings);
91 }
79 } else { 92 } else {
80 error = errors::kManifestUnreadable; 93 error = errors::kManifestUnreadable;
81 } 94 }
82 95
83 // Once installed, non-unpacked extensions cannot change their IDs (e.g., by 96 // Once installed, non-unpacked extensions cannot change their IDs (e.g., by
84 // updating the 'key' field in their manifest). 97 // updating the 'key' field in their manifest).
85 // TODO(jstritar): migrate preferences when unpacked extensions change IDs. 98 // TODO(jstritar): migrate preferences when unpacked extensions change IDs.
86 if (extension && 99 if (extension &&
87 extension->location() != Extension::LOAD && 100 extension->location() != Extension::LOAD &&
88 info.extension_id != extension->id()) { 101 info.extension_id != extension->id()) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (extension_prefs_->AllowFileAccess(info->extension_id)) 315 if (extension_prefs_->AllowFileAccess(info->extension_id))
303 flags |= Extension::ALLOW_FILE_ACCESS; 316 flags |= Extension::ALLOW_FILE_ACCESS;
304 if (extension_prefs_->IsFromWebStore(info->extension_id)) 317 if (extension_prefs_->IsFromWebStore(info->extension_id))
305 flags |= Extension::FROM_WEBSTORE; 318 flags |= Extension::FROM_WEBSTORE;
306 if (extension_prefs_->IsFromBookmark(info->extension_id)) 319 if (extension_prefs_->IsFromBookmark(info->extension_id))
307 flags |= Extension::FROM_BOOKMARK; 320 flags |= Extension::FROM_BOOKMARK;
308 return flags; 321 return flags;
309 } 322 }
310 323
311 } // namespace extensions 324 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698