OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/protector/protector.h" | 5 #include "chrome/browser/protector/protector.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/protector/settings_change_global_error.h" | 9 #include "chrome/browser/protector/settings_change_global_error.h" |
10 #include "chrome/browser/protector/keys.h" | 10 #include "chrome/browser/protector/keys.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 void Protector::OnDiscardChanges() { | 52 void Protector::OnDiscardChanges() { |
53 OnChangesAction(&SettingChange::Revert); | 53 OnChangesAction(&SettingChange::Revert); |
54 } | 54 } |
55 | 55 |
56 void Protector::OnDecisionTimeout() { | 56 void Protector::OnDecisionTimeout() { |
57 OnChangesAction(&SettingChange::DoDefault); | 57 OnChangesAction(&SettingChange::DoDefault); |
58 } | 58 } |
59 | 59 |
| 60 void Protector::OnRemovedFromProfile() { |
| 61 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); |
| 62 } |
| 63 |
60 void Protector::OnChangesAction(SettingChangeAction action) { | 64 void Protector::OnChangesAction(SettingChangeAction action) { |
61 DCHECK(error_.get()); | 65 DCHECK(error_.get()); |
62 SettingChangeVector* changes = error_->mutable_changes(); | 66 SettingChangeVector* changes = error_->mutable_changes(); |
63 for (SettingChangeVector::iterator it = changes->begin(); | 67 for (SettingChangeVector::iterator it = changes->begin(); |
64 it != changes->end(); ++it) | 68 it != changes->end(); ++it) |
65 ((*it)->*action)(this); | 69 ((*it)->*action)(this); |
66 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); | |
67 } | 70 } |
68 | 71 |
69 | 72 |
70 std::string SignSetting(const std::string& value) { | 73 std::string SignSetting(const std::string& value) { |
71 crypto::HMAC hmac(crypto::HMAC::SHA256); | 74 crypto::HMAC hmac(crypto::HMAC::SHA256); |
72 DCHECK(hmac.Init(kProtectorSigningKey)); | 75 DCHECK(hmac.Init(kProtectorSigningKey)); |
73 | 76 |
74 std::vector<unsigned char> digest(hmac.DigestLength()); | 77 std::vector<unsigned char> digest(hmac.DigestLength()); |
75 DCHECK(hmac.Sign(value, &digest[0], digest.size())); | 78 DCHECK(hmac.Sign(value, &digest[0], digest.size())); |
76 | 79 |
77 return std::string(&digest[0], &digest[0] + digest.size()); | 80 return std::string(&digest[0], &digest[0] + digest.size()); |
78 } | 81 } |
79 | 82 |
80 } // namespace protector | 83 } // namespace protector |
OLD | NEW |