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

Unified Diff: chrome/browser/profiles/profile_info_cache.cc

Issue 895803003: [Profiles] Remove the NotificationService from the ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copy paste the right function Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_info_cache.cc
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index 824a8d8e243b57533cd5e9c6d2db15ba665cd5b2..b3fde3feef613f3ea3f515ba37864fe35e1f4ec9 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -19,7 +19,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile_avatar_downloader.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profiles_state.h"
@@ -27,7 +26,6 @@
#include "chrome/grit/generated_resources.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
@@ -227,11 +225,6 @@ void ProfileInfoCache::AddProfileToCache(
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
observer_list_,
OnProfileAdded(profile_path));
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
}
void ProfileInfoCache::AddObserver(ProfileInfoCacheObserver* obs) {
@@ -264,11 +257,6 @@ void ProfileInfoCache::DeleteProfileFromCache(
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
observer_list_,
OnProfileWasRemoved(profile_path, name));
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
}
size_t ProfileInfoCache::GetNumberOfProfiles() const {
@@ -485,7 +473,7 @@ void ProfileInfoCache::SetProfileActiveTimeAtIndex(size_t index) {
GetInfoForProfileAtIndex(index)->DeepCopy());
info->SetDouble(kActiveTimeKey, base::Time::Now().ToDoubleT());
// This takes ownership of |info|.
- SetInfoQuietlyForProfileAtIndex(index, info.release());
+ SetInfoForProfileAtIndex(index, info.release());
}
void ProfileInfoCache::SetNameOfProfileAtIndex(size_t index,
@@ -537,6 +525,11 @@ void ProfileInfoCache::SetUserNameOfProfileAtIndex(
info->SetString(kUserNameKey, user_name);
// This takes ownership of |info|.
SetInfoForProfileAtIndex(index, info.release());
+
+ base::FilePath profile_path = GetPathOfProfileAtIndex(index);
+ FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
+ observer_list_,
+ OnProfileUserNameChanged(profile_path));
}
void ProfileInfoCache::SetAvatarIconOfProfileAtIndex(size_t index,
@@ -932,24 +925,13 @@ const base::DictionaryValue* ProfileInfoCache::GetInfoForProfileAtIndex(
return info;
}
-void ProfileInfoCache::SetInfoQuietlyForProfileAtIndex(
- size_t index, base::DictionaryValue* info) {
+void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index,
+ base::DictionaryValue* info) {
DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
base::DictionaryValue* cache = update.Get();
cache->SetWithoutPathExpansion(sorted_keys_[index], info);
}
-// TODO(noms): Switch to newer notification system.
-void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index,
- base::DictionaryValue* info) {
- SetInfoQuietlyForProfileAtIndex(index, info);
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
-}
-
std::string ProfileInfoCache::CacheKeyFromProfilePath(
const base::FilePath& profile_path) const {
DCHECK(user_data_dir_ == profile_path.DirName());
@@ -1017,11 +999,6 @@ void ProfileInfoCache::UpdateSortForProfileIndex(size_t index) {
DCHECK(key_it != sorted_keys_.end());
sorted_keys_.erase(key_it);
sorted_keys_.insert(FindPositionForProfile(key, name), key);
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
}
const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex(
@@ -1107,11 +1084,6 @@ void ProfileInfoCache::OnAvatarPictureLoaded(const base::FilePath& profile_path,
}
delete image;
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
-
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
observer_list_,
OnProfileHighResAvatarLoaded(profile_path));
@@ -1122,11 +1094,6 @@ void ProfileInfoCache::OnAvatarPictureSaved(
const base::FilePath& profile_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_CACHE_PICTURE_SAVED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
-
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
observer_list_,
OnProfileHighResAvatarLoaded(profile_path));

Powered by Google App Engine
This is Rietveld 408576698