| Index: chrome/browser/ui/views/profiles/avatar_base_controller.cc
|
| diff --git a/chrome/browser/ui/views/profiles/avatar_base_controller.cc b/chrome/browser/ui/views/profiles/avatar_base_controller.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..16604536058fb45f2163bd99a2eb58d0af68793e
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/profiles/avatar_base_controller.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/views/profiles/avatar_base_controller.h"
|
| +
|
| +#include "base/files/file_path.h"
|
| +#include "base/strings/string16.h"
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| +#include "components/signin/core/common/profile_management_switches.h"
|
| +
|
| +AvatarBaseController::AvatarBaseController(Browser* browser)
|
| + : browser_(browser) {
|
| + g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
|
| +}
|
| +
|
| +AvatarBaseController::~AvatarBaseController() {
|
| + g_browser_process->profile_manager()->
|
| + GetProfileInfoCache().RemoveObserver(this);
|
| +}
|
| +
|
| +void AvatarBaseController::OnProfileAdded(const base::FilePath& profile_path) {
|
| + Update();
|
| +}
|
| +
|
| +void AvatarBaseController::OnProfileWasRemoved(
|
| + const base::FilePath& profile_path,
|
| + const base::string16& profile_name) {
|
| + // If deleting the active profile, don't bother updating the avatar
|
| + // button, as the browser window is being closed anyway.
|
| + if (browser_->profile()->GetPath() != profile_path)
|
| + Update();
|
| +}
|
| +
|
| +void AvatarBaseController::OnProfileNameChanged(
|
| + const base::FilePath& profile_path,
|
| + const base::string16& old_profile_name) {
|
| + if (browser_->profile()->GetPath() == profile_path)
|
| + Update();
|
| +}
|
| +
|
| +void AvatarBaseController::OnProfileAvatarChanged(
|
| + const base::FilePath& profile_path) {
|
| + if (!switches::IsNewAvatarMenu() &&
|
| + browser_->profile()->GetPath() == profile_path)
|
| + Update();
|
| +}
|
| +
|
| +void AvatarBaseController::OnProfileSupervisedUserIdChanged(
|
| + const base::FilePath& profile_path) {
|
| + if (browser_->profile()->GetPath() == profile_path)
|
| + Update();
|
| +}
|
| +
|
| +void AvatarBaseController::Update() {
|
| + NOTREACHED();
|
| +}
|
|
|