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

Side by Side Diff: chrome/browser/profiles/avatar_menu_actions_desktop.cc

Issue 2685333005: ash: fix regression where ctrl+n put new window on wrong desktop (Closed)
Patch Set: Rebase to ToT Created 3 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/profiles/profile_manager.h" 8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/chrome_pages.h" 10 #include "chrome/browser/ui/chrome_pages.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 12
13 AvatarMenuActionsDesktop::AvatarMenuActionsDesktop() { 13 AvatarMenuActionsDesktop::AvatarMenuActionsDesktop() {
14 } 14 }
15 15
16 AvatarMenuActionsDesktop::~AvatarMenuActionsDesktop() { 16 AvatarMenuActionsDesktop::~AvatarMenuActionsDesktop() {
17 } 17 }
18 18
19 // static 19 // static
20 AvatarMenuActions* AvatarMenuActions::Create() { 20 AvatarMenuActions* AvatarMenuActions::Create() {
21 return new AvatarMenuActionsDesktop(); 21 return new AvatarMenuActionsDesktop();
22 } 22 }
23 23
24 void AvatarMenuActionsDesktop::AddNewProfile(ProfileMetrics::ProfileAdd type) { 24 void AvatarMenuActionsDesktop::AddNewProfile(ProfileMetrics::ProfileAdd type) {
25 // TODO: Remove dependency on Browser by delegating AddNewProfile and 25 // TODO: Remove dependency on Browser by delegating AddNewProfile and
26 // and EditProfile actions. 26 // and EditProfile actions.
27 27
28 Browser* settings_browser = browser_; 28 Browser* settings_browser = browser_;
29 if (!settings_browser) { 29 if (!settings_browser) {
30 const Browser::CreateParams params(ProfileManager::GetLastUsedProfile()); 30 const Browser::CreateParams params(ProfileManager::GetLastUsedProfile(),
31 true);
31 settings_browser = new Browser(params); 32 settings_browser = new Browser(params);
32 } 33 }
33 chrome::ShowSettingsSubPage(settings_browser, chrome::kCreateProfileSubPage); 34 chrome::ShowSettingsSubPage(settings_browser, chrome::kCreateProfileSubPage);
34 ProfileMetrics::LogProfileAddNewUser(type); 35 ProfileMetrics::LogProfileAddNewUser(type);
35 } 36 }
36 37
37 void AvatarMenuActionsDesktop::EditProfile(Profile* profile) { 38 void AvatarMenuActionsDesktop::EditProfile(Profile* profile) {
38 Browser* settings_browser = browser_; 39 Browser* settings_browser = browser_;
39 if (!settings_browser) { 40 if (!settings_browser) {
40 settings_browser = new Browser(Browser::CreateParams(profile)); 41 settings_browser = new Browser(Browser::CreateParams(profile, true));
41 } 42 }
42 // TODO(davidben): The manageProfile page only allows editting the profile 43 // TODO(davidben): The manageProfile page only allows editting the profile
43 // associated with the browser it is opened in. AvatarMenuActionsDesktop 44 // associated with the browser it is opened in. AvatarMenuActionsDesktop
44 // should account for this when picking a browser to open in. 45 // should account for this when picking a browser to open in.
45 chrome::ShowSettingsSubPage(settings_browser, chrome::kManageProfileSubPage); 46 chrome::ShowSettingsSubPage(settings_browser, chrome::kManageProfileSubPage);
46 } 47 }
47 48
48 bool AvatarMenuActionsDesktop::ShouldShowAddNewProfileLink() const { 49 bool AvatarMenuActionsDesktop::ShouldShowAddNewProfileLink() const {
49 // |browser_| can be NULL in unit_tests. 50 // |browser_| can be NULL in unit_tests.
50 if (browser_ && browser_->profile()->IsSupervised()) 51 if (browser_ && browser_->profile()->IsSupervised())
51 return false; 52 return false;
52 return true; 53 return true;
53 } 54 }
54 55
55 bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const { 56 bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const {
56 return true; 57 return true;
57 } 58 }
58 59
59 void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) { 60 void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) {
60 browser_ = browser; 61 browser_ = browser;
61 } 62 }
OLDNEW
« no previous file with comments | « chrome/browser/prefetch/prefetch_browsertest.cc ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698