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

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: string16->string. Simplify OnbrowserWindowReady. 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);
39 }
40
41 void ShowUserManagerThenTaskManager() {
42 UserManagerMac::Show(base::FilePath(),
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);
36 } 51 }
37 52
38 void HideUserManager() { 53 void HideUserManager() {
39 UserManagerMac::Hide(); 54 UserManagerMac::Hide();
40 } 55 }
41 56
42 } // namespace chrome 57 } // namespace chrome
43 58
44 // Custom WebContentsDelegate that allows handling of hotkeys. 59 // Custom WebContentsDelegate that allows handling of hotkeys.
45 class UserManagerWebContentsDelegate : public content::WebContentsDelegate { 60 class UserManagerWebContentsDelegate : public content::WebContentsDelegate {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 183
169 UserManagerMac::UserManagerMac(Profile* profile) { 184 UserManagerMac::UserManagerMac(Profile* profile) {
170 window_controller_.reset([[UserManagerWindowController alloc] 185 window_controller_.reset([[UserManagerWindowController alloc]
171 initWithProfile:profile withObserver:this]); 186 initWithProfile:profile withObserver:this]);
172 } 187 }
173 188
174 UserManagerMac::~UserManagerMac() { 189 UserManagerMac::~UserManagerMac() {
175 } 190 }
176 191
177 // static 192 // static
178 void UserManagerMac::Show(const base::FilePath& profile_path_to_focus, 193 void UserManagerMac::Show(
179 profiles::UserManagerTutorialMode tutorial_mode) { 194 const base::FilePath& profile_path_to_focus,
195 profiles::UserManagerTutorialMode tutorial_mode,
196 profiles::UserManagerProfileSelected profile_open_action) {
180 if (instance_) { 197 if (instance_) {
181 // If there's a user manager window open already, just activate it. 198 // If there's a user manager window open already, just activate it.
182 [instance_->window_controller_ show]; 199 [instance_->window_controller_ show];
183 return; 200 return;
184 } 201 }
185 202
186 // Create the guest profile, if necessary, and open the User Manager 203 // Create the guest profile, if necessary, and open the User Manager
187 // from the guest profile. 204 // from the guest profile.
188 profiles::CreateGuestProfileForUserManager( 205 profiles::CreateGuestProfileForUserManager(
189 profile_path_to_focus, 206 profile_path_to_focus,
190 tutorial_mode, 207 tutorial_mode,
208 profile_open_action,
191 base::Bind(&UserManagerMac::OnGuestProfileCreated)); 209 base::Bind(&UserManagerMac::OnGuestProfileCreated));
192 } 210 }
193 211
194 // static 212 // static
195 void UserManagerMac::Hide() { 213 void UserManagerMac::Hide() {
196 if (instance_) 214 if (instance_)
197 [instance_->window_controller_ close]; 215 [instance_->window_controller_ close];
198 } 216 }
199 217
200 // static 218 // static
201 bool UserManagerMac::IsShowing() { 219 bool UserManagerMac::IsShowing() {
202 return instance_ ? [instance_->window_controller_ isVisible]: false; 220 return instance_ ? [instance_->window_controller_ isVisible]: false;
203 } 221 }
204 222
205 // static 223 // static
206 void UserManagerMac::OnGuestProfileCreated(Profile* guest_profile, 224 void UserManagerMac::OnGuestProfileCreated(Profile* guest_profile,
207 const std::string& url) { 225 const std::string& url) {
208 instance_ = new UserManagerMac(guest_profile); 226 instance_ = new UserManagerMac(guest_profile);
209 [instance_->window_controller_ showURL:GURL(url)]; 227 [instance_->window_controller_ showURL:GURL(url)];
210 } 228 }
211 229
212 void UserManagerMac::WindowWasClosed() { 230 void UserManagerMac::WindowWasClosed() {
213 instance_ = NULL; 231 instance_ = NULL;
214 delete this; 232 delete this;
215 } 233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698