Commit ef2de98a authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove NotificationService usage in ProfileShortcutManagerWin

Bug: 268984
Change-Id: I6a460108f1cce3c4fd45c243dd254d8877327eb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1851928Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705580}
parent 51788175
......@@ -28,7 +28,6 @@
#include "base/threading/scoped_blocking_call.h"
#include "base/win/shortcut.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
......@@ -45,7 +44,6 @@
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkRRect.h"
......@@ -731,13 +729,12 @@ std::unique_ptr<ProfileShortcutManager> ProfileShortcutManager::Create(
ProfileShortcutManagerWin::ProfileShortcutManagerWin(ProfileManager* manager)
: profile_manager_(manager) {
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED,
content::NotificationService::AllSources());
profile_manager_->GetProfileAttributesStorage().AddObserver(this);
profile_manager_->AddObserver(this);
}
ProfileShortcutManagerWin::~ProfileShortcutManagerWin() {
profile_manager_->RemoveObserver(this);
profile_manager_->GetProfileAttributesStorage().RemoveObserver(this);
}
......@@ -857,6 +854,14 @@ void ProfileShortcutManagerWin::OnProfileAvatarChanged(
CreateOrUpdateProfileIcon(profile_path);
}
void ProfileShortcutManagerWin::OnProfileAdded(Profile* profile) {
if (profile->GetPrefs()->GetInteger(prefs::kProfileIconVersion) <
kCurrentProfileIconVersion) {
// Ensure the profile's icon file has been created.
CreateOrUpdateProfileIcon(profile->GetPath());
}
}
base::FilePath ProfileShortcutManagerWin::GetOtherProfilePath(
const base::FilePath& profile_path) {
const ProfileAttributesStorage& storage =
......@@ -923,18 +928,3 @@ void ProfileShortcutManagerWin::CreateOrUpdateShortcutsForProfileAtPath(
entry->SetShortcutName(params.profile_name);
}
void ProfileShortcutManagerWin::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CREATED, type);
Profile* profile =
content::Source<Profile>(source).ptr()->GetOriginalProfile();
if (profile->GetPrefs()->GetInteger(prefs::kProfileIconVersion) <
kCurrentProfileIconVersion) {
// Ensure the profile's icon file has been created.
CreateOrUpdateProfileIcon(profile->GetPath());
}
}
......@@ -10,9 +10,8 @@
#include "base/callback.h"
#include "base/macros.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager_observer.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
// Internal free-standing functions that are exported here for testing.
namespace profiles {
......@@ -58,7 +57,7 @@ base::string16 CreateProfileShortcutFlags(const base::FilePath& profile_path);
class ProfileShortcutManagerWin : public ProfileShortcutManager,
public ProfileAttributesStorage::Observer,
public content::NotificationObserver {
public ProfileManagerObserver {
public:
// Specifies whether only the existing shortcut should be updated, a new
// shortcut should be created if none exist, or only the icon for this profile
......@@ -98,10 +97,8 @@ class ProfileShortcutManagerWin : public ProfileShortcutManager,
const base::string16& old_profile_name) override;
void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
// content::NotificationObserver implementation:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// ProfileManagerObserver:
void OnProfileAdded(Profile* profile) override;
private:
// Gives the profile path of an alternate profile than |profile_path|.
......@@ -118,8 +115,6 @@ class ProfileShortcutManagerWin : public ProfileShortcutManager,
ProfileManager* profile_manager_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment