Chromium Code Reviews| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 } | 109 } |
| 110 | 110 |
| 111 void UserManagerView::Init( | 111 void UserManagerView::Init( |
| 112 const base::FilePath& profile_path_to_focus, | 112 const base::FilePath& profile_path_to_focus, |
| 113 Profile* guest_profile, | 113 Profile* guest_profile, |
| 114 const GURL& url) { | 114 const GURL& url) { |
| 115 web_view_ = new views::WebView(guest_profile); | 115 web_view_ = new views::WebView(guest_profile); |
| 116 web_view_->set_allow_accelerators(true); | 116 web_view_->set_allow_accelerators(true); |
| 117 AddChildView(web_view_); | 117 AddChildView(web_view_); |
| 118 SetLayoutManager(new views::FillLayout); | 118 SetLayoutManager(new views::FillLayout); |
| 119 | |
| 120 // Only handle close window accelerators or accelerators that make sense in | |
| 121 // the locked pod password field. | |
| 119 AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN)); | 122 AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN)); |
| 120 | 123 |
| 121 // If the user manager is being displayed from an existing profile, use | 124 // If the user manager is being displayed from an existing profile, use |
| 122 // its last active browser to determine where the user manager should be | 125 // its last active browser to determine where the user manager should be |
| 123 // placed. This is used so that we can center the dialog on the correct | 126 // placed. This is used so that we can center the dialog on the correct |
| 124 // monitor in a multiple-monitor setup. | 127 // monitor in a multiple-monitor setup. |
| 125 // | 128 // |
| 126 // If |profile_path_to_focus| is empty (for example, starting up chrome | 129 // If |profile_path_to_focus| is empty (for example, starting up chrome |
| 127 // when all existing profiles are locked) or we can't find an active | 130 // when all existing profiles are locked) or we can't find an active |
| 128 // browser, bounds will remain empty and the user manager will be centered on | 131 // browser, bounds will remain empty and the user manager will be centered on |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 guest_profile->GetPath()), | 164 guest_profile->GetPath()), |
| 162 views::HWNDForWidget(GetWidget())); | 165 views::HWNDForWidget(GetWidget())); |
| 163 #endif | 166 #endif |
| 164 GetWidget()->Show(); | 167 GetWidget()->Show(); |
| 165 | 168 |
| 166 web_view_->LoadInitialURL(url); | 169 web_view_->LoadInitialURL(url); |
| 167 web_view_->RequestFocus(); | 170 web_view_->RequestFocus(); |
| 168 } | 171 } |
| 169 | 172 |
| 170 bool UserManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { | 173 bool UserManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
| 171 DCHECK_EQ(ui::VKEY_W, accelerator.key_code()); | |
| 172 DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers()); | 174 DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers()); |
| 173 GetWidget()->Close(); | 175 |
| 174 return true; | 176 // Handle the close window accelerator, and let the WebView handle the rest. |
| 177 if (accelerator.key_code() == ui::VKEY_W) { | |
|
sky
2014/09/10 16:21:15
How do you end up here for other accelerator types
noms (inactive)
2014/09/10 16:55:09
Oh weird, you're right. This seems to work without
| |
| 178 GetWidget()->Close(); | |
| 179 return true; | |
| 180 } | |
| 181 return false; | |
| 175 } | 182 } |
| 176 | 183 |
| 177 gfx::Size UserManagerView::GetPreferredSize() const { | 184 gfx::Size UserManagerView::GetPreferredSize() const { |
| 178 return gfx::Size(kWindowWidth, kWindowHeight); | 185 return gfx::Size(kWindowWidth, kWindowHeight); |
| 179 } | 186 } |
| 180 | 187 |
| 181 bool UserManagerView::CanResize() const { | 188 bool UserManagerView::CanResize() const { |
| 182 return true; | 189 return true; |
| 183 } | 190 } |
| 184 | 191 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 198 // Now that the window is closed, we can allow a new one to be opened. | 205 // 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 | 206 // (WindowClosing comes in asynchronously from the call to Close() and we |
| 200 // may have already opened a new instance). | 207 // may have already opened a new instance). |
| 201 if (instance_ == this) | 208 if (instance_ == this) |
| 202 instance_ = NULL; | 209 instance_ = NULL; |
| 203 } | 210 } |
| 204 | 211 |
| 205 bool UserManagerView::UseNewStyleForThisDialog() const { | 212 bool UserManagerView::UseNewStyleForThisDialog() const { |
| 206 return false; | 213 return false; |
| 207 } | 214 } |
| OLD | NEW |