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

Side by Side Diff: chrome/browser/ui/views/profiles/user_manager_view.cc

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: Simplify UserManager View/Mac 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/views/profiles/user_manager_view.h" 5 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/lifetime/application_lifetime.h" 8 #include "chrome/browser/lifetime/application_lifetime.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profile_metrics.h" 10 #include "chrome/browser/profiles/profile_metrics.h"
11 #include "chrome/browser/profiles/profile_window.h" 11 #include "chrome/browser/profiles/profile_window.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_dialogs.h" 13 #include "chrome/browser/ui/browser_dialogs.h"
14 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/user_manager.h"
16 #include "chrome/browser/ui/views/auto_keep_alive.h" 17 #include "chrome/browser/ui/views/auto_keep_alive.h"
17 #include "chrome/grit/chromium_strings.h" 18 #include "chrome/grit/chromium_strings.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
21 #include "ui/views/controls/webview/webview.h" 22 #include "ui/views/controls/webview/webview.h"
22 #include "ui/views/layout/fill_layout.h" 23 #include "ui/views/layout/fill_layout.h"
23 #include "ui/views/view.h" 24 #include "ui/views/view.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 #include "ui/views/window/dialog_client_view.h" 26 #include "ui/views/window/dialog_client_view.h"
26 27
27 #if defined(OS_WIN) 28 #if defined(OS_WIN)
28 #include "chrome/browser/shell_integration.h" 29 #include "chrome/browser/shell_integration.h"
29 #include "ui/base/win/shell.h" 30 #include "ui/base/win/shell.h"
30 #include "ui/views/win/hwnd_util.h" 31 #include "ui/views/win/hwnd_util.h"
31 #endif 32 #endif
32 33
33 namespace { 34 namespace {
34 35
35 // Default window size. 36 // Default window size.
36 const int kWindowWidth = 900; 37 const int kWindowWidth = 900;
37 const int kWindowHeight = 700; 38 const int kWindowHeight = 700;
38 39
39 } 40 // An open User Manager window. There can only be one open at a time. This
41 // is reset to NULL when the window is closed.
42 static UserManagerView* instance_ = NULL;
Peter Kasting 2014/09/18 18:55:05 This shouldn't be static as it's already in an ano
40 43
41 namespace chrome { 44 } // namespace
42 45
43 // Declared in browser_dialogs.h so others don't have to depend on this header. 46 void UserManager::Show(
Peter Kasting 2014/09/18 18:55:05 Optional: Add divider lines ("// UserManager -----
44 void ShowUserManager(const base::FilePath& profile_path_to_focus) { 47 const base::FilePath& profile_path_to_focus,
45 UserManagerView::Show( 48 profiles::UserManagerTutorialMode tutorial_mode,
46 profile_path_to_focus, profiles::USER_MANAGER_NO_TUTORIAL); 49 profiles::UserManagerProfileSelected profile_open_action) {
47 }
48
49 void ShowUserManagerWithTutorial(profiles::UserManagerTutorialMode tutorial) {
50 UserManagerView::Show(base::FilePath(), tutorial);
51 }
52
53 void HideUserManager() {
54 UserManagerView::Hide();
55 }
56
57 } // namespace chrome
58
59 // static
60 UserManagerView* UserManagerView::instance_ = NULL;
61
62 UserManagerView::UserManagerView()
63 : web_view_(NULL),
64 keep_alive_(new AutoKeepAlive(NULL)) {
65 }
66
67 UserManagerView::~UserManagerView() {
68 }
69
70 // static
71 void UserManagerView::Show(const base::FilePath& profile_path_to_focus,
72 profiles::UserManagerTutorialMode tutorial_mode) {
73 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); 50 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER);
74 if (instance_) { 51 if (instance_) {
75 // If there's a user manager window open already, just activate it. 52 // If there's a user manager window open already, just activate it.
76 instance_->GetWidget()->Activate(); 53 instance_->GetWidget()->Activate();
77 return; 54 return;
78 } 55 }
79 56
80 // Create the guest profile, if necessary, and open the user manager 57 // Create the guest profile, if necessary, and open the user manager
81 // from the guest profile. 58 // from the guest profile.
82 profiles::CreateGuestProfileForUserManager( 59 profiles::CreateGuestProfileForUserManager(
83 profile_path_to_focus, 60 profile_path_to_focus,
84 tutorial_mode, 61 tutorial_mode,
62 profile_open_action,
85 base::Bind(&UserManagerView::OnGuestProfileCreated, 63 base::Bind(&UserManagerView::OnGuestProfileCreated,
Peter Kasting 2014/09/18 18:55:05 Somehow it seems weird to me that this is a static
86 base::Passed(make_scoped_ptr(new UserManagerView)), 64 base::Passed(make_scoped_ptr(new UserManagerView)),
87 profile_path_to_focus)); 65 profile_path_to_focus));
88 } 66 }
89 67
90 // static 68 void UserManager::Hide() {
91 void UserManagerView::Hide() {
92 if (instance_) 69 if (instance_)
93 instance_->GetWidget()->Close(); 70 instance_->GetWidget()->Close();
94 } 71 }
95 72
96 // static 73 bool UserManager::IsShowing() {
97 bool UserManagerView::IsShowing() {
98 return instance_ ? instance_->GetWidget()->IsActive() : false; 74 return instance_ ? instance_->GetWidget()->IsActive() : false;
99 } 75 }
100 76
77 UserManagerView::UserManagerView()
78 : web_view_(NULL),
79 keep_alive_(new AutoKeepAlive(NULL)) {
80 }
81
82 UserManagerView::~UserManagerView() {
83 }
84
101 // static 85 // static
102 void UserManagerView::OnGuestProfileCreated( 86 void UserManagerView::OnGuestProfileCreated(
103 scoped_ptr<UserManagerView> instance, 87 scoped_ptr<UserManagerView> instance,
104 const base::FilePath& profile_path_to_focus, 88 const base::FilePath& profile_path_to_focus,
105 Profile* guest_profile, 89 Profile* guest_profile,
106 const std::string& url) { 90 const std::string& url) {
107 instance_ = instance.release(); // |instance_| takes over ownership. 91 instance_ = instance.release(); // |instance_| takes over ownership.
Peter Kasting 2014/09/18 18:55:05 Should this check that |instance_| was previously
108 instance_->Init(profile_path_to_focus, guest_profile, GURL(url)); 92 instance_->Init(profile_path_to_focus, guest_profile, GURL(url));
109 } 93 }
110 94
111 void UserManagerView::Init( 95 void UserManagerView::Init(
112 const base::FilePath& profile_path_to_focus, 96 const base::FilePath& profile_path_to_focus,
113 Profile* guest_profile, 97 Profile* guest_profile,
114 const GURL& url) { 98 const GURL& url) {
115 web_view_ = new views::WebView(guest_profile); 99 web_view_ = new views::WebView(guest_profile);
116 web_view_->set_allow_accelerators(true); 100 web_view_->set_allow_accelerators(true);
117 AddChildView(web_view_); 101 AddChildView(web_view_);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // Now that the window is closed, we can allow a new one to be opened. 182 // Now that the window is closed, we can allow a new one to be opened.
199 // (WindowClosing comes in asynchronously from the call to Close() and we 183 // (WindowClosing comes in asynchronously from the call to Close() and we
200 // may have already opened a new instance). 184 // may have already opened a new instance).
201 if (instance_ == this) 185 if (instance_ == this)
202 instance_ = NULL; 186 instance_ = NULL;
203 } 187 }
204 188
205 bool UserManagerView::UseNewStyleForThisDialog() const { 189 bool UserManagerView::UseNewStyleForThisDialog() const {
206 return false; 190 return false;
207 } 191 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/user_manager_view.h ('k') | chrome/browser/ui/webui/signin/user_manager_screen_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698