OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/avatar_menu_actions_desktop.h" | 5 #include "chrome/browser/profiles/avatar_menu_actions_desktop.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 AvatarMenuActions* AvatarMenuActions::Create() { | 34 AvatarMenuActions* AvatarMenuActions::Create() { |
35 return new AvatarMenuActionsDesktop(); | 35 return new AvatarMenuActionsDesktop(); |
36 } | 36 } |
37 | 37 |
38 void AvatarMenuActionsDesktop::AddNewProfile(ProfileMetrics::ProfileAdd type) { | 38 void AvatarMenuActionsDesktop::AddNewProfile(ProfileMetrics::ProfileAdd type) { |
39 // TODO: Remove dependency on Browser by delegating AddNewProfile and | 39 // TODO: Remove dependency on Browser by delegating AddNewProfile and |
40 // and EditProfile actions. | 40 // and EditProfile actions. |
41 | 41 |
42 Browser* settings_browser = browser_; | 42 Browser* settings_browser = browser_; |
43 if (!settings_browser) { | 43 if (!settings_browser) { |
44 const Browser::CreateParams params(ProfileManager::GetLastUsedProfile(), | 44 const Browser::CreateParams params(ProfileManager::GetLastUsedProfile()); |
45 chrome::GetActiveDesktop()); | |
46 settings_browser = new Browser(params); | 45 settings_browser = new Browser(params); |
47 } | 46 } |
48 chrome::ShowSettingsSubPage(settings_browser, chrome::kCreateProfileSubPage); | 47 chrome::ShowSettingsSubPage(settings_browser, chrome::kCreateProfileSubPage); |
49 ProfileMetrics::LogProfileAddNewUser(type); | 48 ProfileMetrics::LogProfileAddNewUser(type); |
50 } | 49 } |
51 | 50 |
52 void AvatarMenuActionsDesktop::EditProfile(Profile* profile, size_t index) { | 51 void AvatarMenuActionsDesktop::EditProfile(Profile* profile, size_t index) { |
53 Browser* settings_browser = browser_; | 52 Browser* settings_browser = browser_; |
54 if (!settings_browser) { | 53 if (!settings_browser) { |
55 settings_browser = new Browser( | 54 settings_browser = new Browser(Browser::CreateParams(profile)); |
56 Browser::CreateParams(profile, chrome::GetActiveDesktop())); | |
57 } | 55 } |
58 // TODO(davidben): The manageProfile page only allows editting the profile | 56 // TODO(davidben): The manageProfile page only allows editting the profile |
59 // associated with the browser it is opened in. AvatarMenuActionsDesktop | 57 // associated with the browser it is opened in. AvatarMenuActionsDesktop |
60 // should account for this when picking a browser to open in. | 58 // should account for this when picking a browser to open in. |
61 chrome::ShowSettingsSubPage(settings_browser, chrome::kManageProfileSubPage); | 59 chrome::ShowSettingsSubPage(settings_browser, chrome::kManageProfileSubPage); |
62 } | 60 } |
63 | 61 |
64 bool AvatarMenuActionsDesktop::ShouldShowAddNewProfileLink() const { | 62 bool AvatarMenuActionsDesktop::ShouldShowAddNewProfileLink() const { |
65 // |browser_| can be NULL in unit_tests. | 63 // |browser_| can be NULL in unit_tests. |
66 if (browser_ && browser_->profile()->IsSupervised()) | 64 if (browser_ && browser_->profile()->IsSupervised()) |
67 return false; | 65 return false; |
68 #if defined(OS_WIN) | 66 #if defined(OS_WIN) |
69 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH; | 67 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH; |
70 #else | 68 #else |
71 return true; | 69 return true; |
72 #endif | 70 #endif |
73 } | 71 } |
74 | 72 |
75 bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const { | 73 bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const { |
76 #if defined(OS_WIN) | 74 #if defined(OS_WIN) |
77 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH; | 75 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH; |
78 #else | 76 #else |
79 return true; | 77 return true; |
80 #endif | 78 #endif |
81 } | 79 } |
82 | 80 |
83 void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) { | 81 void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) { |
84 browser_ = browser; | 82 browser_ = browser; |
85 } | 83 } |
OLD | NEW |