OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 namespace extensions { | 98 namespace extensions { |
99 | 99 |
100 InstallVerifier::InstallVerifier(ExtensionPrefs* prefs, | 100 InstallVerifier::InstallVerifier(ExtensionPrefs* prefs, |
101 net::URLRequestContextGetter* context_getter) | 101 net::URLRequestContextGetter* context_getter) |
102 : prefs_(prefs), context_getter_(context_getter) { | 102 : prefs_(prefs), context_getter_(context_getter) { |
103 } | 103 } |
104 | 104 |
105 InstallVerifier::~InstallVerifier() {} | 105 InstallVerifier::~InstallVerifier() {} |
106 | 106 |
107 void InstallVerifier::Init() { | 107 void InstallVerifier::Init() { |
108 const DictionaryValue* pref = prefs_->GetInstallSignature(); | 108 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); |
109 if (pref) { | 109 if (pref) { |
110 scoped_ptr<InstallSignature> signature_from_prefs = | 110 scoped_ptr<InstallSignature> signature_from_prefs = |
111 InstallSignature::FromValue(*pref); | 111 InstallSignature::FromValue(*pref); |
112 if (!signature_from_prefs.get()) { | 112 if (!signature_from_prefs.get()) { |
113 UMA_HISTOGRAM_BOOLEAN("InstallVerifier.InitUnparseablePref", true); | 113 UMA_HISTOGRAM_BOOLEAN("InstallVerifier.InitUnparseablePref", true); |
114 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { | 114 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { |
115 UMA_HISTOGRAM_BOOLEAN("InstallVerifier.InitInvalidSignature", true); | 115 UMA_HISTOGRAM_BOOLEAN("InstallVerifier.InitInvalidSignature", true); |
116 DVLOG(1) << "Init - ignoring invalid signature"; | 116 DVLOG(1) << "Init - ignoring invalid signature"; |
117 } else { | 117 } else { |
118 signature_ = signature_from_prefs.Pass(); | 118 signature_ = signature_from_prefs.Pass(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 325 } |
326 | 326 |
327 void InstallVerifier::SaveToPrefs() { | 327 void InstallVerifier::SaveToPrefs() { |
328 if (signature_.get()) | 328 if (signature_.get()) |
329 DCHECK(InstallSigner::VerifySignature(*signature_)); | 329 DCHECK(InstallSigner::VerifySignature(*signature_)); |
330 | 330 |
331 if (!signature_.get() || signature_->ids.empty()) { | 331 if (!signature_.get() || signature_->ids.empty()) { |
332 DVLOG(1) << "SaveToPrefs - saving NULL"; | 332 DVLOG(1) << "SaveToPrefs - saving NULL"; |
333 prefs_->SetInstallSignature(NULL); | 333 prefs_->SetInstallSignature(NULL); |
334 } else { | 334 } else { |
335 DictionaryValue pref; | 335 base::DictionaryValue pref; |
336 signature_->ToValue(&pref); | 336 signature_->ToValue(&pref); |
337 if (VLOG_IS_ON(1)) { | 337 if (VLOG_IS_ON(1)) { |
338 DVLOG(1) << "SaveToPrefs - saving"; | 338 DVLOG(1) << "SaveToPrefs - saving"; |
339 | 339 |
340 DCHECK(InstallSigner::VerifySignature(*signature_.get())); | 340 DCHECK(InstallSigner::VerifySignature(*signature_.get())); |
341 scoped_ptr<InstallSignature> rehydrated = | 341 scoped_ptr<InstallSignature> rehydrated = |
342 InstallSignature::FromValue(pref); | 342 InstallSignature::FromValue(pref); |
343 DCHECK(InstallSigner::VerifySignature(*rehydrated.get())); | 343 DCHECK(InstallSigner::VerifySignature(*rehydrated.get())); |
344 } | 344 } |
345 prefs_->SetInstallSignature(&pref); | 345 prefs_->SetInstallSignature(&pref); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (!operation->callback.is_null()) | 381 if (!operation->callback.is_null()) |
382 operation->callback.Run(success); | 382 operation->callback.Run(success); |
383 } | 383 } |
384 | 384 |
385 if (!operation_queue_.empty()) | 385 if (!operation_queue_.empty()) |
386 BeginFetch(); | 386 BeginFetch(); |
387 } | 387 } |
388 | 388 |
389 | 389 |
390 } // namespace extensions | 390 } // namespace extensions |
OLD | NEW |