OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/views/profiles/avatar_base_controller.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/string16.h" |
| 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "components/signin/core/common/profile_management_switches.h" |
| 13 |
| 14 AvatarBaseController::AvatarBaseController(Browser* browser) |
| 15 : browser_(browser) { |
| 16 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); |
| 17 } |
| 18 |
| 19 AvatarBaseController::~AvatarBaseController() { |
| 20 g_browser_process->profile_manager()-> |
| 21 GetProfileInfoCache().RemoveObserver(this); |
| 22 } |
| 23 |
| 24 void AvatarBaseController::OnProfileAdded(const base::FilePath& profile_path) { |
| 25 Update(); |
| 26 } |
| 27 |
| 28 void AvatarBaseController::OnProfileWasRemoved( |
| 29 const base::FilePath& profile_path, |
| 30 const base::string16& profile_name) { |
| 31 // If deleting the active profile, don't bother updating the avatar |
| 32 // button, as the browser window is being closed anyway. |
| 33 if (browser_->profile()->GetPath() != profile_path) |
| 34 Update(); |
| 35 } |
| 36 |
| 37 void AvatarBaseController::OnProfileNameChanged( |
| 38 const base::FilePath& profile_path, |
| 39 const base::string16& old_profile_name) { |
| 40 if (browser_->profile()->GetPath() == profile_path) |
| 41 Update(); |
| 42 } |
| 43 |
| 44 void AvatarBaseController::OnProfileAvatarChanged( |
| 45 const base::FilePath& profile_path) { |
| 46 if (!switches::IsNewAvatarMenu() && |
| 47 browser_->profile()->GetPath() == profile_path) |
| 48 Update(); |
| 49 } |
| 50 |
| 51 void AvatarBaseController::OnProfileSupervisedUserIdChanged( |
| 52 const base::FilePath& profile_path) { |
| 53 if (browser_->profile()->GetPath() == profile_path) |
| 54 Update(); |
| 55 } |
| 56 |
| 57 void AvatarBaseController::Update() { |
| 58 NOTREACHED(); |
| 59 } |
OLD | NEW |