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" |
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_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/views/auto_keep_alive.h" | 15 #include "chrome/browser/ui/views/auto_keep_alive.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/views/controls/webview/webview.h" | 19 #include "ui/views/controls/webview/webview.h" |
20 #include "ui/views/layout/fill_layout.h" | 20 #include "ui/views/layout/fill_layout.h" |
21 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
23 #include "ui/views/window/dialog_client_view.h" | |
23 | 24 |
24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
25 #include "chrome/browser/shell_integration.h" | 26 #include "chrome/browser/shell_integration.h" |
26 #include "ui/base/win/shell.h" | 27 #include "ui/base/win/shell.h" |
27 #include "ui/views/win/hwnd_util.h" | 28 #include "ui/views/win/hwnd_util.h" |
28 #endif | 29 #endif |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 // Default window size. | 33 // Default window size. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 void UserManagerView::OnGuestProfileCreated( | 99 void UserManagerView::OnGuestProfileCreated( |
99 scoped_ptr<UserManagerView> instance, | 100 scoped_ptr<UserManagerView> instance, |
100 Profile* guest_profile, | 101 Profile* guest_profile, |
101 const std::string& url) { | 102 const std::string& url) { |
102 instance_ = instance.release(); // |instance_| takes over ownership. | 103 instance_ = instance.release(); // |instance_| takes over ownership. |
103 instance_->Init(guest_profile, GURL(url)); | 104 instance_->Init(guest_profile, GURL(url)); |
104 } | 105 } |
105 | 106 |
106 void UserManagerView::Init(Profile* guest_profile, const GURL& url) { | 107 void UserManagerView::Init(Profile* guest_profile, const GURL& url) { |
107 web_view_ = new views::WebView(guest_profile); | 108 web_view_ = new views::WebView(guest_profile); |
109 web_view_->set_allow_accelerators(true); | |
110 AddChildView(web_view_); | |
108 SetLayoutManager(new views::FillLayout); | 111 SetLayoutManager(new views::FillLayout); |
109 AddChildView(web_view_); | 112 AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN)); |
110 | 113 |
111 DialogDelegate::CreateDialogWidget(this, NULL, NULL); | 114 DialogDelegate::CreateDialogWidget(this, NULL, NULL); |
115 GetDialogClientView()->RemoveAccelerator( | |
msw
2014/07/09 17:07:03
nit: add a comment explaining why Esc shouldn't cl
noms (inactive)
2014/07/09 17:15:09
Done.
| |
116 ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | |
112 | 117 |
113 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
114 // Set the app id for the task manager to the app id of its parent | 119 // Set the app id for the task manager to the app id of its parent |
115 ui::win::SetAppIdForWindow( | 120 ui::win::SetAppIdForWindow( |
116 ShellIntegration::GetChromiumModelIdForProfile( | 121 ShellIntegration::GetChromiumModelIdForProfile( |
117 guest_profile->GetPath()), | 122 guest_profile->GetPath()), |
118 views::HWNDForWidget(GetWidget())); | 123 views::HWNDForWidget(GetWidget())); |
119 #endif | 124 #endif |
120 GetWidget()->Show(); | 125 GetWidget()->Show(); |
121 | 126 |
122 web_view_->LoadInitialURL(url); | 127 web_view_->LoadInitialURL(url); |
123 web_view_->RequestFocus(); | 128 web_view_->RequestFocus(); |
124 } | 129 } |
125 | 130 |
131 bool UserManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) { | |
132 DCHECK_EQ(ui::VKEY_W, accelerator.key_code()); | |
133 DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers()); | |
134 GetWidget()->Close(); | |
135 return true; | |
136 } | |
137 | |
126 gfx::Size UserManagerView::GetPreferredSize() const { | 138 gfx::Size UserManagerView::GetPreferredSize() const { |
127 return gfx::Size(kWindowWidth, kWindowHeight); | 139 return gfx::Size(kWindowWidth, kWindowHeight); |
128 } | 140 } |
129 | 141 |
130 bool UserManagerView::CanResize() const { | 142 bool UserManagerView::CanResize() const { |
131 return true; | 143 return true; |
132 } | 144 } |
133 | 145 |
134 bool UserManagerView::CanMaximize() const { | 146 bool UserManagerView::CanMaximize() const { |
135 return true; | 147 return true; |
(...skipping 11 matching lines...) Expand all Loading... | |
147 // Now that the window is closed, we can allow a new one to be opened. | 159 // Now that the window is closed, we can allow a new one to be opened. |
148 // (WindowClosing comes in asynchronously from the call to Close() and we | 160 // (WindowClosing comes in asynchronously from the call to Close() and we |
149 // may have already opened a new instance). | 161 // may have already opened a new instance). |
150 if (instance_ == this) | 162 if (instance_ == this) |
151 instance_ = NULL; | 163 instance_ = NULL; |
152 } | 164 } |
153 | 165 |
154 bool UserManagerView::UseNewStyleForThisDialog() const { | 166 bool UserManagerView::UseNewStyleForThisDialog() const { |
155 return false; | 167 return false; |
156 } | 168 } |
OLD | NEW |