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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm

Issue 564453003: Access to Chrome via the System Tray should go through the User Manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Listen to the window Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/cocoa/profiles/user_manager_mac.h" 5 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser_dialogs.h" 10 #include "chrome/browser/ui/browser_dialogs.h"
11 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 11 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
12 #include "chrome/browser/ui/cocoa/chrome_event_processing_window.h" 12 #include "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
13 #include "chrome/grit/chromium_strings.h" 13 #include "chrome/grit/chromium_strings.h"
14 #include "content/public/browser/native_web_keyboard_event.h" 14 #include "content/public/browser/native_web_keyboard_event.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_delegate.h" 16 #include "content/public/browser/web_contents_delegate.h"
17 #include "ui/base/l10n/l10n_util_mac.h" 17 #include "ui/base/l10n/l10n_util_mac.h"
18 18
19 // Default window size. Taken from the views implementation in 19 // Default window size. Taken from the views implementation in
20 // chrome/browser/ui/views/user_manager_view.cc. 20 // chrome/browser/ui/views/user_manager_view.cc.
21 // TODO(noms): Figure out if this size can be computed dynamically or adjusted 21 // TODO(noms): Figure out if this size can be computed dynamically or adjusted
22 // for smaller screens. 22 // for smaller screens.
23 const int kWindowWidth = 900; 23 const int kWindowWidth = 900;
24 const int kWindowHeight = 700; 24 const int kWindowHeight = 700;
25 25
26 namespace chrome { 26 namespace chrome {
27 27
28 // Declared in browser_dialogs.h so others don't have to depend on this header. 28 // Declared in browser_dialogs.h so others don't have to depend on this header.
29 void ShowUserManager(const base::FilePath& profile_path_to_focus) { 29 void ShowUserManager(const base::FilePath& profile_path_to_focus) {
30 UserManagerMac::Show( 30 UserManagerMac::Show(profile_path_to_focus,
31 profile_path_to_focus, profiles::USER_MANAGER_NO_TUTORIAL); 31 profiles::USER_MANAGER_NO_TUTORIAL,
32 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
32 } 33 }
33 34
34 void ShowUserManagerWithTutorial(profiles::UserManagerTutorialMode tutorial) { 35 void ShowUserManagerWithTutorial(profiles::UserManagerTutorialMode tutorial) {
35 UserManagerMac::Show(base::FilePath(), tutorial); 36 UserManagerMac::Show(base::FilePath(),
37 tutorial,
38 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
36 } 39 }
37 40
41 void ShowUserManagerThenTaskManager() {
42 UserManagerMac::Show(base::FilePath(),
noms (inactive) 2014/09/12 14:44:16 Peter's comment aside. I would combine these two i
Mike Lerman 2014/09/15 13:44:04 I'll wait on Peter's comments before I start refac
43 profiles::USER_MANAGER_NO_TUTORIAL,
44 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER);
45 }
46
47 void ShowUserManagerThenAboutChrome() {
48 UserManagerMac::Show(base::FilePath(),
49 profiles::USER_MANAGER_NO_TUTORIAL,
50 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME);
51 }
52
53 void ShowUserManagerThenTaskManager
noms (inactive) 2014/09/12 14:44:16 is this a typo?
Mike Lerman 2014/09/15 13:44:04 The best kind!
54
38 void HideUserManager() { 55 void HideUserManager() {
39 UserManagerMac::Hide(); 56 UserManagerMac::Hide();
40 } 57 }
41 58
42 } // namespace chrome 59 } // namespace chrome
43 60
44 // Custom WebContentsDelegate that allows handling of hotkeys. 61 // Custom WebContentsDelegate that allows handling of hotkeys.
45 class UserManagerWebContentsDelegate : public content::WebContentsDelegate { 62 class UserManagerWebContentsDelegate : public content::WebContentsDelegate {
46 public: 63 public:
47 UserManagerWebContentsDelegate(ChromeEventProcessingWindow* window) 64 UserManagerWebContentsDelegate(ChromeEventProcessingWindow* window)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 185
169 UserManagerMac::UserManagerMac(Profile* profile) { 186 UserManagerMac::UserManagerMac(Profile* profile) {
170 window_controller_.reset([[UserManagerWindowController alloc] 187 window_controller_.reset([[UserManagerWindowController alloc]
171 initWithProfile:profile withObserver:this]); 188 initWithProfile:profile withObserver:this]);
172 } 189 }
173 190
174 UserManagerMac::~UserManagerMac() { 191 UserManagerMac::~UserManagerMac() {
175 } 192 }
176 193
177 // static 194 // static
178 void UserManagerMac::Show(const base::FilePath& profile_path_to_focus, 195 void UserManagerMac::Show(
179 profiles::UserManagerTutorialMode tutorial_mode) { 196 const base::FilePath& profile_path_to_focus,
197 profiles::UserManagerTutorialMode tutorial_mode,
198 profiles::UserManagerProfileSelected profile_open_action) {
180 if (instance_) { 199 if (instance_) {
181 // If there's a user manager window open already, just activate it. 200 // If there's a user manager window open already, just activate it.
182 [instance_->window_controller_ show]; 201 [instance_->window_controller_ show];
183 return; 202 return;
184 } 203 }
185 204
186 // Create the guest profile, if necessary, and open the User Manager 205 // Create the guest profile, if necessary, and open the User Manager
187 // from the guest profile. 206 // from the guest profile.
188 profiles::CreateGuestProfileForUserManager( 207 profiles::CreateGuestProfileForUserManager(
189 profile_path_to_focus, 208 profile_path_to_focus,
190 tutorial_mode, 209 tutorial_mode,
210 profile_open_action,
191 base::Bind(&UserManagerMac::OnGuestProfileCreated)); 211 base::Bind(&UserManagerMac::OnGuestProfileCreated));
192 } 212 }
193 213
194 // static 214 // static
195 void UserManagerMac::Hide() { 215 void UserManagerMac::Hide() {
196 if (instance_) 216 if (instance_)
197 [instance_->window_controller_ close]; 217 [instance_->window_controller_ close];
198 } 218 }
199 219
200 // static 220 // static
201 bool UserManagerMac::IsShowing() { 221 bool UserManagerMac::IsShowing() {
202 return instance_ ? [instance_->window_controller_ isVisible]: false; 222 return instance_ ? [instance_->window_controller_ isVisible]: false;
203 } 223 }
204 224
205 // static 225 // static
206 void UserManagerMac::OnGuestProfileCreated(Profile* guest_profile, 226 void UserManagerMac::OnGuestProfileCreated(Profile* guest_profile,
207 const std::string& url) { 227 const std::string& url) {
208 instance_ = new UserManagerMac(guest_profile); 228 instance_ = new UserManagerMac(guest_profile);
209 [instance_->window_controller_ showURL:GURL(url)]; 229 [instance_->window_controller_ showURL:GURL(url)];
210 } 230 }
211 231
212 void UserManagerMac::WindowWasClosed() { 232 void UserManagerMac::WindowWasClosed() {
213 instance_ = NULL; 233 instance_ = NULL;
214 delete this; 234 delete this;
215 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698