| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/login/signed_settings.h" | 5 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
| 14 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 15 #include "chrome/browser/chromeos/cros/login_library.h" | 15 #include "chrome/browser/chromeos/cros/login_library.h" |
| 16 #include "chrome/browser/chromeos/login/authenticator.h" |
| 16 #include "chrome/browser/chromeos/login/ownership_service.h" | 17 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 17 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" | 18 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" |
| 18 | 19 |
| 19 namespace chromeos { | 20 namespace chromeos { |
| 20 | 21 |
| 21 SignedSettings::SignedSettings() | 22 SignedSettings::SignedSettings() |
| 22 : service_(OwnershipService::GetSharedInstance()) { | 23 : service_(OwnershipService::GetSharedInstance()) { |
| 23 } | 24 } |
| 24 | 25 |
| 25 SignedSettings::~SignedSettings() {} | 26 SignedSettings::~SignedSettings() {} |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 std::string name_; | 102 std::string name_; |
| 102 std::string value_; | 103 std::string value_; |
| 103 SignedSettings::Delegate<std::string>* d_; | 104 SignedSettings::Delegate<std::string>* d_; |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 // static | 107 // static |
| 107 SignedSettings* SignedSettings::CreateCheckWhitelistOp( | 108 SignedSettings* SignedSettings::CreateCheckWhitelistOp( |
| 108 const std::string& email, | 109 const std::string& email, |
| 109 SignedSettings::Delegate<bool>* d) { | 110 SignedSettings::Delegate<bool>* d) { |
| 110 DCHECK(d != NULL); | 111 DCHECK(d != NULL); |
| 111 return new CheckWhitelistOp(email, d); | 112 return new CheckWhitelistOp(Authenticator::Canonicalize(email), d); |
| 112 } | 113 } |
| 113 | 114 |
| 114 // static | 115 // static |
| 115 SignedSettings* SignedSettings::CreateWhitelistOp( | 116 SignedSettings* SignedSettings::CreateWhitelistOp( |
| 116 const std::string& email, | 117 const std::string& email, |
| 117 bool add_to_whitelist, | 118 bool add_to_whitelist, |
| 118 SignedSettings::Delegate<bool>* d) { | 119 SignedSettings::Delegate<bool>* d) { |
| 119 DCHECK(d != NULL); | 120 DCHECK(d != NULL); |
| 120 return new WhitelistOp(email, add_to_whitelist, d); | 121 return new WhitelistOp(Authenticator::Canonicalize(email), |
| 122 add_to_whitelist, |
| 123 d); |
| 121 } | 124 } |
| 122 | 125 |
| 123 // static | 126 // static |
| 124 SignedSettings* SignedSettings::CreateStorePropertyOp( | 127 SignedSettings* SignedSettings::CreateStorePropertyOp( |
| 125 const std::string& name, | 128 const std::string& name, |
| 126 const std::string& value, | 129 const std::string& value, |
| 127 SignedSettings::Delegate<bool>* d) { | 130 SignedSettings::Delegate<bool>* d) { |
| 128 DCHECK(d != NULL); | 131 DCHECK(d != NULL); |
| 129 return new StorePropertyOp(name, value, d); | 132 return new StorePropertyOp(name, value, d); |
| 130 } | 133 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Ensure we're on the UI thread, due to the need to send DBus traffic. | 165 // Ensure we're on the UI thread, due to the need to send DBus traffic. |
| 163 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 166 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 164 BrowserThread::PostTask( | 167 BrowserThread::PostTask( |
| 165 BrowserThread::UI, FROM_HERE, | 168 BrowserThread::UI, FROM_HERE, |
| 166 NewRunnableMethod(this, | 169 NewRunnableMethod(this, |
| 167 &CheckWhitelistOp::OnKeyOpComplete, | 170 &CheckWhitelistOp::OnKeyOpComplete, |
| 168 return_code, payload)); | 171 return_code, payload)); |
| 169 return; | 172 return; |
| 170 } | 173 } |
| 171 if (return_code == OwnerManager::SUCCESS) { | 174 if (return_code == OwnerManager::SUCCESS) { |
| 175 VLOG(2) << "Whitelist check was successful."; |
| 172 d_->OnSettingsOpCompleted(SUCCESS, true); | 176 d_->OnSettingsOpCompleted(SUCCESS, true); |
| 173 } else { | 177 } else { |
| 178 VLOG(2) << "Whitelist check failed."; |
| 174 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), false); | 179 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), false); |
| 175 } | 180 } |
| 176 } | 181 } |
| 177 | 182 |
| 178 WhitelistOp::WhitelistOp(const std::string& email, | 183 WhitelistOp::WhitelistOp(const std::string& email, |
| 179 bool add_to_whitelist, | 184 bool add_to_whitelist, |
| 180 SignedSettings::Delegate<bool>* d) | 185 SignedSettings::Delegate<bool>* d) |
| 181 : email_(email), | 186 : email_(email), |
| 182 add_to_whitelist_(add_to_whitelist), | 187 add_to_whitelist_(add_to_whitelist), |
| 183 d_(d) { | 188 d_(d) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 345 } |
| 341 // Now, sure we're on the UI thread. | 346 // Now, sure we're on the UI thread. |
| 342 if (return_code == OwnerManager::SUCCESS) | 347 if (return_code == OwnerManager::SUCCESS) |
| 343 d_->OnSettingsOpCompleted(SUCCESS, value_); | 348 d_->OnSettingsOpCompleted(SUCCESS, value_); |
| 344 else | 349 else |
| 345 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), | 350 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), |
| 346 std::string()); | 351 std::string()); |
| 347 } | 352 } |
| 348 | 353 |
| 349 } // namespace chromeos | 354 } // namespace chromeos |
| OLD | NEW |