Chromium Code Reviews| 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/profiles/profile_info_cache.h" | 5 #include "chrome/browser/profiles/profile_info_cache.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 29 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| 33 #include "ui/gfx/image/image_util.h" | 33 #include "ui/gfx/image/image_util.h" |
| 34 | 34 |
| 35 #if defined(OS_WIN) | |
| 36 #include "chrome/installer/util/auto_launch_util.h" | |
| 37 #endif | |
| 38 | |
| 35 using content::BrowserThread; | 39 using content::BrowserThread; |
| 36 | 40 |
| 37 namespace { | 41 namespace { |
| 38 | 42 |
| 39 const char kNameKey[] = "name"; | 43 const char kNameKey[] = "name"; |
| 40 const char kGAIANameKey[] = "gaia_name"; | 44 const char kGAIANameKey[] = "gaia_name"; |
| 41 const char kUseGAIANameKey[] = "use_gaia_name"; | 45 const char kUseGAIANameKey[] = "use_gaia_name"; |
| 42 const char kUserNameKey[] = "user_name"; | 46 const char kUserNameKey[] = "user_name"; |
| 43 const char kAvatarIconKey[] = "avatar_icon"; | 47 const char kAvatarIconKey[] = "avatar_icon"; |
| 44 const char kUseGAIAPictureKey[] = "use_gaia_picture"; | 48 const char kUseGAIAPictureKey[] = "use_gaia_picture"; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 } | 160 } |
| 157 | 161 |
| 158 *out_image = image; | 162 *out_image = image; |
| 159 } | 163 } |
| 160 | 164 |
| 161 void DeleteBitmap(const FilePath& image_path) { | 165 void DeleteBitmap(const FilePath& image_path) { |
| 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 163 file_util::Delete(image_path, false); | 167 file_util::Delete(image_path, false); |
| 164 } | 168 } |
| 165 | 169 |
| 170 #if defined(OS_WIN) | |
| 171 void DeleteAutoLaunchValueForProfile( | |
| 172 const FilePath& profile_path) { | |
| 173 if (auto_launch_util::WillLaunchAtLogin(FilePath(), | |
| 174 profile_path.BaseName().value())) { | |
| 175 auto_launch_util::SetWillLaunchAtLogin( | |
| 176 false, FilePath(), profile_path.BaseName().value()); | |
| 177 } | |
| 178 } | |
| 179 #endif | |
| 180 | |
| 166 } // namespace | 181 } // namespace |
| 167 | 182 |
| 168 ProfileInfoCache::ProfileInfoCache(PrefService* prefs, | 183 ProfileInfoCache::ProfileInfoCache(PrefService* prefs, |
| 169 const FilePath& user_data_dir) | 184 const FilePath& user_data_dir) |
| 170 : prefs_(prefs), | 185 : prefs_(prefs), |
| 171 user_data_dir_(user_data_dir) { | 186 user_data_dir_(user_data_dir) { |
| 172 // Populate the cache | 187 // Populate the cache |
| 173 const DictionaryValue* cache = | 188 const DictionaryValue* cache = |
| 174 prefs_->GetDictionary(prefs::kProfileInfoCache); | 189 prefs_->GetDictionary(prefs::kProfileInfoCache); |
| 175 for (DictionaryValue::key_iterator it = cache->begin_keys(); | 190 for (DictionaryValue::key_iterator it = cache->begin_keys(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, | 246 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, |
| 232 observer_list_, | 247 observer_list_, |
| 233 OnProfileWillBeRemoved(profile_path)); | 248 OnProfileWillBeRemoved(profile_path)); |
| 234 | 249 |
| 235 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); | 250 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); |
| 236 DictionaryValue* cache = update.Get(); | 251 DictionaryValue* cache = update.Get(); |
| 237 std::string key = CacheKeyFromProfilePath(profile_path); | 252 std::string key = CacheKeyFromProfilePath(profile_path); |
| 238 cache->Remove(key, NULL); | 253 cache->Remove(key, NULL); |
| 239 sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key)); | 254 sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key)); |
| 240 | 255 |
| 256 #if defined(OS_WIN) | |
| 257 BrowserThread::PostTask( | |
| 258 BrowserThread::FILE, FROM_HERE, | |
| 259 base::Bind(&DeleteAutoLaunchValueForProfile, profile_path)); | |
|
grt (UTC plus 2)
2012/02/09 16:43:50
shouldn't this be more like the ProfileShortcutMan
| |
| 260 #endif | |
| 261 | |
| 241 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, | 262 FOR_EACH_OBSERVER(ProfileInfoCacheObserver, |
| 242 observer_list_, | 263 observer_list_, |
| 243 OnProfileWasRemoved(profile_path, name)); | 264 OnProfileWasRemoved(profile_path, name)); |
| 244 | 265 |
| 245 content::NotificationService::current()->Notify( | 266 content::NotificationService::current()->Notify( |
| 246 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 267 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 247 content::NotificationService::AllSources(), | 268 content::NotificationService::AllSources(), |
| 248 content::NotificationService::NoDetails()); | 269 content::NotificationService::NoDetails()); |
| 249 } | 270 } |
| 250 | 271 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 info->GetString(kNameKey, &name); | 796 info->GetString(kNameKey, &name); |
| 776 names.push_back(name); | 797 names.push_back(name); |
| 777 } | 798 } |
| 778 return names; | 799 return names; |
| 779 } | 800 } |
| 780 | 801 |
| 781 // static | 802 // static |
| 782 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { | 803 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { |
| 783 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); | 804 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); |
| 784 } | 805 } |
| OLD | NEW |