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

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 8801034: Revert 112856 - Making profile avatars and names sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.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/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 // static 204 // static
205 void ProfileImpl::RegisterUserPrefs(PrefService* prefs) { 205 void ProfileImpl::RegisterUserPrefs(PrefService* prefs) {
206 prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled, 206 prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled,
207 false, 207 false,
208 PrefService::UNSYNCABLE_PREF); 208 PrefService::UNSYNCABLE_PREF);
209 prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit, 209 prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
210 false, 210 false,
211 PrefService::SYNCABLE_PREF); 211 PrefService::SYNCABLE_PREF);
212 prefs->RegisterIntegerPref(prefs::kProfileAvatarIndex,
213 -1,
214 PrefService::SYNCABLE_PREF);
215 prefs->RegisterStringPref(prefs::kProfileName,
216 "",
217 PrefService::SYNCABLE_PREF);
218 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) 212 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
219 prefs->RegisterIntegerPref(prefs::kLocalProfileId, 213 prefs->RegisterIntegerPref(prefs::kLocalProfileId,
220 kInvalidLocalProfileId, 214 kInvalidLocalProfileId,
221 PrefService::UNSYNCABLE_PREF); 215 PrefService::UNSYNCABLE_PREF);
222 // Notice that the preprocessor conditions above are exactly those that will 216 // Notice that the preprocessor conditions above are exactly those that will
223 // result in using PasswordStoreX in CreatePasswordStore() below. 217 // result in using PasswordStoreX in CreatePasswordStore() below.
224 PasswordStoreX::RegisterUserPrefs(prefs); 218 PasswordStoreX::RegisterUserPrefs(prefs);
225 #endif 219 #endif
226 } 220 }
227 221
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 void ProfileImpl::DoFinalInit() { 277 void ProfileImpl::DoFinalInit() {
284 PrefService* prefs = GetPrefs(); 278 PrefService* prefs = GetPrefs();
285 pref_change_registrar_.Init(prefs); 279 pref_change_registrar_.Init(prefs);
286 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); 280 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this);
287 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); 281 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this);
288 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); 282 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this);
289 pref_change_registrar_.Add(prefs::kSpeechInputFilterProfanities, this); 283 pref_change_registrar_.Add(prefs::kSpeechInputFilterProfanities, this);
290 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); 284 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this);
291 pref_change_registrar_.Add(prefs::kGoogleServicesUsername, this); 285 pref_change_registrar_.Add(prefs::kGoogleServicesUsername, this);
292 pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this); 286 pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this);
293 pref_change_registrar_.Add(prefs::kProfileAvatarIndex, this);
294 pref_change_registrar_.Add(prefs::kProfileName, this);
295 287
296 // It would be nice to use PathService for fetching this directory, but 288 // It would be nice to use PathService for fetching this directory, but
297 // the cache directory depends on the profile directory, which isn't available 289 // the cache directory depends on the profile directory, which isn't available
298 // to PathService. 290 // to PathService.
299 chrome::GetUserCacheDirectory(path_, &base_cache_path_); 291 chrome::GetUserCacheDirectory(path_, &base_cache_path_);
300 if (!delegate_) { 292 if (!delegate_) {
301 if (!file_util::CreateDirectory(base_cache_path_)) 293 if (!file_util::CreateDirectory(base_cache_path_))
302 LOG(FATAL) << "Failed to create " << base_cache_path_.value(); 294 LOG(FATAL) << "Failed to create " << base_cache_path_.value();
303 } else { 295 } else {
304 // Async profile loading is used, so call this on the FILE thread instead. 296 // Async profile loading is used, so call this on the FILE thread instead.
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 if (webkit_context_) { 1298 if (webkit_context_) {
1307 webkit_context_->set_clear_local_state_on_exit( 1299 webkit_context_->set_clear_local_state_on_exit(
1308 clear_local_state_on_exit_); 1300 clear_local_state_on_exit_);
1309 } 1301 }
1310 if (db_tracker_) { 1302 if (db_tracker_) {
1311 db_tracker_->SetClearLocalStateOnExit( 1303 db_tracker_->SetClearLocalStateOnExit(
1312 clear_local_state_on_exit_); 1304 clear_local_state_on_exit_);
1313 } 1305 }
1314 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { 1306 } else if (*pref_name_in == prefs::kGoogleServicesUsername) {
1315 UpdateProfileUserNameCache(); 1307 UpdateProfileUserNameCache();
1316 } else if (*pref_name_in == prefs::kProfileAvatarIndex) {
1317 UpdateProfileAvatarCache();
1318 } else if (*pref_name_in == prefs::kProfileName) {
1319 UpdateProfileNameCache();
1320 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { 1308 } else if (*pref_name_in == prefs::kDefaultZoomLevel) {
1321 GetHostZoomMap()->set_default_zoom_level( 1309 GetHostZoomMap()->set_default_zoom_level(
1322 prefs->GetDouble(prefs::kDefaultZoomLevel)); 1310 prefs->GetDouble(prefs::kDefaultZoomLevel));
1323 } 1311 }
1324 break; 1312 break;
1325 } 1313 }
1326 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED: 1314 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED:
1327 GetProfileSyncService(); // Causes lazy-load if sync is enabled. 1315 GetProfileSyncService(); // Causes lazy-load if sync is enabled.
1328 registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, 1316 registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
1329 content::Source<Profile>(this)); 1317 content::Source<Profile>(this));
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1600 ProfileManager* profile_manager = g_browser_process->profile_manager();
1613 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1601 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
1614 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1602 size_t index = cache.GetIndexOfProfileWithPath(GetPath());
1615 if (index != std::string::npos) { 1603 if (index != std::string::npos) {
1616 std::string user_name = 1604 std::string user_name =
1617 GetPrefs()->GetString(prefs::kGoogleServicesUsername); 1605 GetPrefs()->GetString(prefs::kGoogleServicesUsername);
1618 cache.SetUserNameOfProfileAtIndex(index, UTF8ToUTF16(user_name)); 1606 cache.SetUserNameOfProfileAtIndex(index, UTF8ToUTF16(user_name));
1619 } 1607 }
1620 } 1608 }
1621 1609
1622 void ProfileImpl::UpdateProfileNameCache() {
1623 ProfileManager* profile_manager = g_browser_process->profile_manager();
1624 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
1625 size_t index = cache.GetIndexOfProfileWithPath(GetPath());
1626 if (index != std::string::npos) {
1627 std::string profile_name =
1628 GetPrefs()->GetString(prefs::kProfileName);
1629 cache.SetNameOfProfileAtIndex(index, UTF8ToUTF16(profile_name));
1630 }
1631 }
1632
1633 void ProfileImpl::UpdateProfileAvatarCache() {
1634 ProfileManager* profile_manager = g_browser_process->profile_manager();
1635 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
1636 size_t index = cache.GetIndexOfProfileWithPath(GetPath());
1637 if (index != std::string::npos) {
1638 size_t avatar_index =
1639 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex);
1640 cache.SetAvatarIconOfProfileAtIndex(index, avatar_index);
1641 }
1642 }
1643
1644 // Gets the cache parameters from the command line. If |is_media_context| is 1610 // Gets the cache parameters from the command line. If |is_media_context| is
1645 // set to true then settings for the media context type is what we need, 1611 // set to true then settings for the media context type is what we need,
1646 // |cache_path| will be set to the user provided path, or will not be touched if 1612 // |cache_path| will be set to the user provided path, or will not be touched if
1647 // there is not an argument. |max_size| will be the user provided value or zero 1613 // there is not an argument. |max_size| will be the user provided value or zero
1648 // by default. 1614 // by default.
1649 void ProfileImpl::GetCacheParameters(bool is_media_context, 1615 void ProfileImpl::GetCacheParameters(bool is_media_context,
1650 FilePath* cache_path, 1616 FilePath* cache_path,
1651 int* max_size) { 1617 int* max_size) {
1652 DCHECK(cache_path); 1618 DCHECK(cache_path);
1653 DCHECK(max_size); 1619 DCHECK(max_size);
1654 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); 1620 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
1655 if (!path.empty()) 1621 if (!path.empty())
1656 *cache_path = path; 1622 *cache_path = path;
1657 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1623 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1658 prefs_->GetInteger(prefs::kDiskCacheSize); 1624 prefs_->GetInteger(prefs::kDiskCacheSize);
1659 } 1625 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698