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

Side by Side Diff: chrome/browser/signin/about_signin_internals.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
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/signin/about_signin_internals.h" 5 #include "chrome/browser/signin/about_signin_internals.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/signin_internals_util.h" 14 #include "chrome/browser/signin/signin_internals_util.h"
15 #include "chrome/browser/signin/signin_manager.h" 15 #include "chrome/browser/signin/signin_manager.h"
16 #include "chrome/browser/signin/token_service.h" 16 #include "chrome/browser/signin/token_service.h"
17 #include "chrome/browser/signin/token_service_factory.h" 17 #include "chrome/browser/signin/token_service_factory.h"
18 #include "chrome/browser/ui/webui/signin_internals_ui.h" 18 #include "chrome/browser/ui/webui/signin_internals_ui.h"
19 #include "google_apis/gaia/gaia_constants.h" 19 #include "google_apis/gaia/gaia_constants.h"
20 20
21 using namespace signin_internals_util; 21 using namespace signin_internals_util;
22 22
23 AboutSigninInternals::AboutSigninInternals() : profile_(NULL) { 23 AboutSigninInternals::AboutSigninInternals() : profile_(NULL) {
24 // Initialize default values for tokens. 24 // Initialize default values for tokens.
25 for (size_t i = 0; i < kNumTokenPrefs; ++i) { 25 for (size_t i = 0; i < kNumTokenPrefs; ++i) {
26 signin_status_.token_info_map.insert(std::pair<std::string, TokenInfo>( 26 signin_status_.token_info_map.insert(std::pair<std::string, TokenInfo>(
27 kTokenPrefsArray[i], 27 kTokenPrefsArray[i],
28 TokenInfo("", "Not Loaded", "", kTokenPrefsArray[i]))); 28 TokenInfo(
29 std::string(), "Not Loaded", std::string(), kTokenPrefsArray[i])));
29 } 30 }
30 } 31 }
31 32
32 AboutSigninInternals::~AboutSigninInternals() { 33 AboutSigninInternals::~AboutSigninInternals() {
33 } 34 }
34 35
35 void AboutSigninInternals::AddSigninObserver( 36 void AboutSigninInternals::AddSigninObserver(
36 AboutSigninInternals::Observer* observer) { 37 AboutSigninInternals::Observer* observer) {
37 signin_observers_.AddObserver(observer); 38 signin_observers_.AddObserver(observer);
38 } 39 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 DCHECK(signin_status_.token_info_map.count(token_name)); 164 DCHECK(signin_status_.token_info_map.count(token_name));
164 165
165 signin_status_.token_info_map[token_name].token.clear(); 166 signin_status_.token_info_map[token_name].token.clear();
166 signin_status_.token_info_map[token_name].status = error; 167 signin_status_.token_info_map[token_name].status = error;
167 signin_status_.token_info_map[token_name].time = time_as_str; 168 signin_status_.token_info_map[token_name].time = time_as_str;
168 169
169 // Also update preferences. 170 // Also update preferences.
170 const std::string value_pref = TokenPrefPath(token_name) + ".value"; 171 const std::string value_pref = TokenPrefPath(token_name) + ".value";
171 const std::string time_pref = TokenPrefPath(token_name) + ".time"; 172 const std::string time_pref = TokenPrefPath(token_name) + ".time";
172 const std::string status_pref = TokenPrefPath(token_name) + ".status"; 173 const std::string status_pref = TokenPrefPath(token_name) + ".status";
173 profile_->GetPrefs()->SetString(value_pref.c_str(), ""); 174 profile_->GetPrefs()->SetString(value_pref.c_str(), std::string());
174 profile_->GetPrefs()->SetString(time_pref.c_str(), time_as_str); 175 profile_->GetPrefs()->SetString(time_pref.c_str(), time_as_str);
175 profile_->GetPrefs()->SetString(status_pref.c_str(), error); 176 profile_->GetPrefs()->SetString(status_pref.c_str(), error);
176 177
177 NotifyObservers(); 178 NotifyObservers();
178 } 179 }
179 180
180 // While clearing tokens, we don't update the time or status. 181 // While clearing tokens, we don't update the time or status.
181 void AboutSigninInternals::NotifyClearStoredToken( 182 void AboutSigninInternals::NotifyClearStoredToken(
182 const std::string& token_name) { 183 const std::string& token_name) {
183 // This should have been initialized already. 184 // This should have been initialized already.
184 DCHECK(signin_status_.token_info_map.count(token_name)); 185 DCHECK(signin_status_.token_info_map.count(token_name));
185 186
186 signin_status_.token_info_map[token_name].token.clear(); 187 signin_status_.token_info_map[token_name].token.clear();
187 188
188 const std::string value_pref = TokenPrefPath(token_name) + ".value"; 189 const std::string value_pref = TokenPrefPath(token_name) + ".value";
189 profile_->GetPrefs()->SetString(value_pref.c_str(), ""); 190 profile_->GetPrefs()->SetString(value_pref.c_str(), std::string());
190 191
191 NotifyObservers(); 192 NotifyObservers();
192 } 193 }
193 194
194 void AboutSigninInternals::Initialize(Profile* profile) { 195 void AboutSigninInternals::Initialize(Profile* profile) {
195 DCHECK(!profile_); 196 DCHECK(!profile_);
196 profile_ = profile; 197 profile_ = profile;
197 198
198 RefreshSigninPrefs(); 199 RefreshSigninPrefs();
199 200
(...skipping 12 matching lines...) Expand all
212 213
213 void AboutSigninInternals::NotifyObservers() { 214 void AboutSigninInternals::NotifyObservers() {
214 FOR_EACH_OBSERVER(AboutSigninInternals::Observer, 215 FOR_EACH_OBSERVER(AboutSigninInternals::Observer,
215 signin_observers_, 216 signin_observers_,
216 OnSigninStateChanged(signin_status_.ToValue())); 217 OnSigninStateChanged(signin_status_.ToValue()));
217 } 218 }
218 219
219 scoped_ptr<DictionaryValue> AboutSigninInternals::GetSigninStatus() { 220 scoped_ptr<DictionaryValue> AboutSigninInternals::GetSigninStatus() {
220 return signin_status_.ToValue().Pass(); 221 return signin_status_.ToValue().Pass();
221 } 222 }
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_unittest.cc ('k') | chrome/browser/signin/about_signin_internals_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698