OLD | NEW |
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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "ui/views/window/dialog_client_view.h" | 27 #include "ui/views/window/dialog_client_view.h" |
28 | 28 |
29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
30 #include "chrome/browser/shell_integration.h" | 30 #include "chrome/browser/shell_integration.h" |
31 #include "ui/base/win/shell.h" | 31 #include "ui/base/win/shell.h" |
32 #include "ui/views/win/hwnd_util.h" | 32 #include "ui/views/win/hwnd_util.h" |
33 #endif | 33 #endif |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 // Default window size. | |
38 const int kWindowWidth = 900; | |
39 const int kWindowHeight = 700; | |
40 | |
41 // An open User Manager window. There can only be one open at a time. This | 37 // An open User Manager window. There can only be one open at a time. This |
42 // is reset to NULL when the window is closed. | 38 // is reset to NULL when the window is closed. |
43 UserManagerView* instance_ = NULL; | 39 UserManagerView* instance_ = NULL; |
44 | 40 |
45 } // namespace | 41 } // namespace |
46 | 42 |
47 // UserManager ----------------------------------------------------------------- | 43 // UserManager ----------------------------------------------------------------- |
48 | 44 |
49 void UserManager::Show( | 45 void UserManager::Show( |
50 const base::FilePath& profile_path_to_focus, | 46 const base::FilePath& profile_path_to_focus, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Profile* profile = manager->GetProfileByPath(profile_path_to_focus); | 128 Profile* profile = manager->GetProfileByPath(profile_path_to_focus); |
133 DCHECK(profile); | 129 DCHECK(profile); |
134 Browser* browser = chrome::FindLastActiveWithProfile(profile, | 130 Browser* browser = chrome::FindLastActiveWithProfile(profile, |
135 chrome::GetActiveDesktop()); | 131 chrome::GetActiveDesktop()); |
136 if (browser) { | 132 if (browser) { |
137 gfx::NativeView native_view = | 133 gfx::NativeView native_view = |
138 views::Widget::GetWidgetForNativeWindow( | 134 views::Widget::GetWidgetForNativeWindow( |
139 browser->window()->GetNativeWindow())->GetNativeView(); | 135 browser->window()->GetNativeWindow())->GetNativeView(); |
140 bounds = gfx::Screen::GetScreenFor(native_view)-> | 136 bounds = gfx::Screen::GetScreenFor(native_view)-> |
141 GetDisplayNearestWindow(native_view).work_area(); | 137 GetDisplayNearestWindow(native_view).work_area(); |
142 bounds.ClampToCenteredSize(gfx::Size(kWindowWidth, kWindowHeight)); | 138 bounds.ClampToCenteredSize(gfx::Size(UserManager::kWindowWidth, |
| 139 UserManager::kWindowHeight)); |
143 } | 140 } |
144 } | 141 } |
145 } | 142 } |
146 | 143 |
147 DialogDelegate::CreateDialogWidgetWithBounds(this, NULL, NULL, bounds); | 144 DialogDelegate::CreateDialogWidgetWithBounds(this, NULL, NULL, bounds); |
148 | 145 |
149 // Since the User Manager can be the only top level window, we don't | 146 // Since the User Manager can be the only top level window, we don't |
150 // want to accidentally quit all of Chrome if the user is just trying to | 147 // want to accidentally quit all of Chrome if the user is just trying to |
151 // unfocus the selected pod in the WebView. | 148 // unfocus the selected pod in the WebView. |
152 GetDialogClientView()->RemoveAccelerator( | 149 GetDialogClientView()->RemoveAccelerator( |
(...skipping 13 matching lines...) Expand all Loading... |
166 } | 163 } |
167 | 164 |
168 bool UserManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { | 165 bool UserManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
169 DCHECK_EQ(ui::VKEY_W, accelerator.key_code()); | 166 DCHECK_EQ(ui::VKEY_W, accelerator.key_code()); |
170 DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers()); | 167 DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers()); |
171 GetWidget()->Close(); | 168 GetWidget()->Close(); |
172 return true; | 169 return true; |
173 } | 170 } |
174 | 171 |
175 gfx::Size UserManagerView::GetPreferredSize() const { | 172 gfx::Size UserManagerView::GetPreferredSize() const { |
176 return gfx::Size(kWindowWidth, kWindowHeight); | 173 return gfx::Size(UserManager::kWindowWidth, UserManager::kWindowHeight); |
177 } | 174 } |
178 | 175 |
179 bool UserManagerView::CanResize() const { | 176 bool UserManagerView::CanResize() const { |
180 return true; | 177 return true; |
181 } | 178 } |
182 | 179 |
183 bool UserManagerView::CanMaximize() const { | 180 bool UserManagerView::CanMaximize() const { |
184 return true; | 181 return true; |
185 } | 182 } |
186 | 183 |
(...skipping 13 matching lines...) Expand all Loading... |
200 // Now that the window is closed, we can allow a new one to be opened. | 197 // Now that the window is closed, we can allow a new one to be opened. |
201 // (WindowClosing comes in asynchronously from the call to Close() and we | 198 // (WindowClosing comes in asynchronously from the call to Close() and we |
202 // may have already opened a new instance). | 199 // may have already opened a new instance). |
203 if (instance_ == this) | 200 if (instance_ == this) |
204 instance_ = NULL; | 201 instance_ = NULL; |
205 } | 202 } |
206 | 203 |
207 bool UserManagerView::UseNewStyleForThisDialog() const { | 204 bool UserManagerView::UseNewStyleForThisDialog() const { |
208 return false; | 205 return false; |
209 } | 206 } |
OLD | NEW |