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

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

Issue 93513006: Allow re-enabling of DISABLE_NOT_VERIFIED extensions if appropriate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated to auto-recheck on settings page load when appropriate Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/install_verifier.h" 5 #include "chrome/browser/extensions/install_verifier.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DVLOG(1) << "Init - ignoring invalid signature"; 75 DVLOG(1) << "Init - ignoring invalid signature";
76 } else { 76 } else {
77 signature_ = signature_from_prefs.Pass(); 77 signature_ = signature_from_prefs.Pass();
78 UMA_HISTOGRAM_COUNTS("InstallVerifier.InitGoodSignature", 78 UMA_HISTOGRAM_COUNTS("InstallVerifier.InitGoodSignature",
79 signature_->ids.size()); 79 signature_->ids.size());
80 GarbageCollect(); 80 GarbageCollect();
81 } 81 }
82 } else { 82 } else {
83 UMA_HISTOGRAM_BOOLEAN("InstallVerifier.InitNoSignature", true); 83 UMA_HISTOGRAM_BOOLEAN("InstallVerifier.InitNoSignature", true);
84 } 84 }
85 }
85 86
86 if (!signature_.get() && ShouldFetchSignature()) { 87 bool InstallVerifier::NeedsBootstrap() {
87 // We didn't have any signature but are in fetch mode, so do a request for 88 return signature_.get() == NULL && ShouldFetchSignature();
88 // a signature if needed.
89 scoped_ptr<ExtensionPrefs::ExtensionsInfo> all_info =
90 prefs_->GetInstalledExtensionsInfo();
91 ExtensionIdSet to_add;
92 if (all_info.get()) {
93 for (ExtensionPrefs::ExtensionsInfo::const_iterator i = all_info->begin();
94 i != all_info->end(); ++i) {
95 const ExtensionInfo& info = **i;
96 const base::DictionaryValue* dictionary = info.extension_manifest.get();
97 if (dictionary && ManifestURL::UpdatesFromGallery(dictionary)) {
98 Manifest manifest(info.extension_location,
99 scoped_ptr<DictionaryValue>(
100 dictionary->DeepCopy()));
101 if (manifest.is_extension())
102 to_add.insert(info.extension_id);
103 }
104 }
105 }
106 if (to_add.empty()) {
107 // Write an empty signature so we don't have to redo this at next Init.
108 signature_.reset(new InstallSignature());
109 SaveToPrefs();
110 } else {
111 AddMany(to_add, AddResultCallback());
112 }
113 }
114 } 89 }
115 90
116 void InstallVerifier::Add(const std::string& id, 91 void InstallVerifier::Add(const std::string& id,
117 const AddResultCallback& callback) { 92 const AddResultCallback& callback) {
118 ExtensionIdSet ids; 93 ExtensionIdSet ids;
119 ids.insert(id); 94 ids.insert(id);
120 AddMany(ids, callback); 95 AddMany(ids, callback);
121 } 96 }
122 97
123 void InstallVerifier::AddMany(const ExtensionIdSet& ids, 98 void InstallVerifier::AddMany(const ExtensionIdSet& ids,
124 const AddResultCallback& callback) { 99 const AddResultCallback& callback) {
125 if (!ShouldFetchSignature()) 100 if (!ShouldFetchSignature()) {
101 if (!callback.is_null())
102 callback.Run(true);
126 return; 103 return;
104 }
127 105
128 if (signature_.get()) { 106 if (signature_.get()) {
129 ExtensionIdSet not_allowed_yet = 107 ExtensionIdSet not_allowed_yet =
130 base::STLSetDifference<ExtensionIdSet>(ids, signature_->ids); 108 base::STLSetDifference<ExtensionIdSet>(ids, signature_->ids);
131 if (not_allowed_yet.empty()) { 109 if (not_allowed_yet.empty()) {
132 if (!callback.is_null()) 110 if (!callback.is_null())
133 callback.Run(true); 111 callback.Run(true);
134 return; 112 return;
135 } 113 }
136 } 114 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 bool InstallVerifier::MustRemainDisabled(const Extension* extension, 173 bool InstallVerifier::MustRemainDisabled(const Extension* extension,
196 Extension::DisableReason* reason, 174 Extension::DisableReason* reason,
197 base::string16* error) const { 175 base::string16* error) const {
198 if (!ShouldEnforce() || !extension->is_extension() || 176 if (!ShouldEnforce() || !extension->is_extension() ||
199 Manifest::IsUnpackedLocation(extension->location()) || 177 Manifest::IsUnpackedLocation(extension->location()) ||
200 AllowedByEnterprisePolicy(extension->id())) 178 AllowedByEnterprisePolicy(extension->id()))
201 return false; 179 return false;
202 180
203 bool verified = 181 bool verified =
204 FromStore(extension) && 182 FromStore(extension) &&
205 IsVerified(extension->id()) && 183 (signature_.get() == NULL || IsVerified(extension->id())) &&
Finnur 2013/12/16 14:21:51 Wait... it is verified if there's no signature? Wh
asargent_no_longer_on_chrome 2013/12/16 18:47:10 It's temporarily allowed - the idea is that if som
206 !ContainsKey(InstallSigner::GetForcedNotFromWebstore(), extension->id()); 184 !ContainsKey(InstallSigner::GetForcedNotFromWebstore(), extension->id());
207 185
208 if (!verified) { 186 if (!verified) {
209 if (reason) 187 if (reason)
210 *reason = Extension::DISABLE_NOT_VERIFIED; 188 *reason = Extension::DISABLE_NOT_VERIFIED;
211 if (error) 189 if (error)
212 *error = l10n_util::GetStringFUTF16( 190 *error = l10n_util::GetStringFUTF16(
213 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE, 191 IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE,
214 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)); 192 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE));
215 } 193 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } else { 318 } else {
341 signature_ = signature.Pass(); 319 signature_ = signature.Pass();
342 SaveToPrefs(); 320 SaveToPrefs();
343 321
344 if (!provisional_.empty()) { 322 if (!provisional_.empty()) {
345 // Update |provisional_| to remove ids that were successfully signed. 323 // Update |provisional_| to remove ids that were successfully signed.
346 provisional_ = base::STLSetDifference<ExtensionIdSet>( 324 provisional_ = base::STLSetDifference<ExtensionIdSet>(
347 provisional_, signature_->ids); 325 provisional_, signature_->ids);
348 } 326 }
349 327
350 // See if we were able to sign all of |ids|.
351 ExtensionIdSet not_allowed =
352 base::STLSetDifference<ExtensionIdSet>(operation->ids,
353 signature_->ids);
354
355 UMA_HISTOGRAM_COUNTS_100("InstallVerifier.CallbackNotAllowed",
356 not_allowed.size());
asargent_no_longer_on_chrome 2013/12/14 00:42:39 note: I removed this block of code because it was
357
358 if (!operation->callback.is_null()) 328 if (!operation->callback.is_null())
359 operation->callback.Run(not_allowed.empty()); 329 operation->callback.Run(success);
asargent_no_longer_on_chrome 2013/12/14 00:42:39 This got updated to return the success of the netw
360 } 330 }
361 331
362 if (!operation_queue_.empty()) 332 if (!operation_queue_.empty())
363 BeginFetch(); 333 BeginFetch();
364 } 334 }
365 335
366 336
367 } // namespace extensions 337 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698