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

Side by Side Diff: chrome/browser/chromeos/login/webui_login_view.cc

Issue 15879007: Support web contents modal dialogs within SimpleWebViewDialog and WebUILoginView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comment Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/login/webui_login_view.h" 5 #include "chrome/browser/chromeos/login/webui_login_view.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 WebContents* web_contents = webui_login_->GetWebContents(); 192 WebContents* web_contents = webui_login_->GetWebContents();
193 193
194 // Create the password manager that is needed for the proxy. 194 // Create the password manager that is needed for the proxy.
195 PasswordManagerDelegateImpl::CreateForWebContents(web_contents); 195 PasswordManagerDelegateImpl::CreateForWebContents(web_contents);
196 PasswordManager::CreateForWebContentsAndDelegate( 196 PasswordManager::CreateForWebContentsAndDelegate(
197 web_contents, PasswordManagerDelegateImpl::FromWebContents(web_contents)); 197 web_contents, PasswordManagerDelegateImpl::FromWebContents(web_contents));
198 198
199 // LoginHandlerViews uses a constrained window for the password manager view. 199 // LoginHandlerViews uses a constrained window for the password manager view.
200 WebContentsModalDialogManager::CreateForWebContents(web_contents); 200 WebContentsModalDialogManager::CreateForWebContents(web_contents);
201 WebContentsModalDialogManager::FromWebContents(web_contents)->
202 set_delegate(this);
201 203
202 web_contents->SetDelegate(this); 204 web_contents->SetDelegate(this);
203 renderer_preferences_util::UpdateFromSystemSettings( 205 renderer_preferences_util::UpdateFromSystemSettings(
204 web_contents->GetMutableRendererPrefs(), 206 web_contents->GetMutableRendererPrefs(),
205 signin_profile); 207 signin_profile);
206 208
207 registrar_.Add(this, 209 registrar_.Add(this,
208 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 210 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
209 content::Source<WebContents>(web_contents)); 211 content::Source<WebContents>(web_contents));
210 } 212 }
211 213
212 const char* WebUILoginView::GetClassName() const { 214 const char* WebUILoginView::GetClassName() const {
213 return kViewClassName; 215 return kViewClassName;
214 } 216 }
215 217
218 web_modal::WebContentsModalDialogHost*
219 WebUILoginView::GetWebContentsModalDialogHost() {
220 return this;
221 }
222
223 gfx::NativeView WebUILoginView::GetHostView() const {
224 return GetWidget()->GetNativeView();
225 }
226
227 gfx::Point WebUILoginView::GetDialogPosition(const gfx::Size& size) {
228 // Center the widget.
229 gfx::Size widget_size = GetWidget()->GetWindowBoundsInScreen().size();
230 return gfx::Point(widget_size.width() / 2 - size.width() / 2,
231 widget_size.height() / 2 - size.height() / 2);
232 }
233
234 void WebUILoginView::AddObserver(
235 web_modal::WebContentsModalDialogHostObserver* observer) {
236 if (observer && !observer_list_.HasObserver(observer))
237 observer_list_.AddObserver(observer);
238 }
239
240 void WebUILoginView::RemoveObserver(
241 web_modal::WebContentsModalDialogHostObserver* observer) {
242 observer_list_.RemoveObserver(observer);
243 }
244
216 bool WebUILoginView::AcceleratorPressed( 245 bool WebUILoginView::AcceleratorPressed(
217 const ui::Accelerator& accelerator) { 246 const ui::Accelerator& accelerator) {
218 AccelMap::const_iterator entry = accel_map_.find(accelerator); 247 AccelMap::const_iterator entry = accel_map_.find(accelerator);
219 if (entry == accel_map_.end()) 248 if (entry == accel_map_.end())
220 return false; 249 return false;
221 250
222 if (!webui_login_) 251 if (!webui_login_)
223 return true; 252 return true;
224 253
225 content::WebUI* web_ui = GetWebUI(); 254 content::WebUI* web_ui = GetWebUI();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 void WebUILoginView::SetUIEnabled(bool enabled) { 321 void WebUILoginView::SetUIEnabled(bool enabled) {
293 forward_keyboard_event_ = enabled; 322 forward_keyboard_event_ = enabled;
294 ash::Shell::GetInstance()->GetPrimarySystemTray()->SetEnabled(enabled); 323 ash::Shell::GetInstance()->GetPrimarySystemTray()->SetEnabled(enabled);
295 } 324 }
296 325
297 // WebUILoginView protected: --------------------------------------------------- 326 // WebUILoginView protected: ---------------------------------------------------
298 327
299 void WebUILoginView::Layout() { 328 void WebUILoginView::Layout() {
300 DCHECK(webui_login_); 329 DCHECK(webui_login_);
301 webui_login_->SetBoundsRect(bounds()); 330 webui_login_->SetBoundsRect(bounds());
331
332 FOR_EACH_OBSERVER(web_modal::WebContentsModalDialogHostObserver,
333 observer_list_,
334 OnPositionRequiresUpdate());
302 } 335 }
303 336
304 void WebUILoginView::OnLocaleChanged() { 337 void WebUILoginView::OnLocaleChanged() {
305 } 338 }
306 339
307 void WebUILoginView::ChildPreferredSizeChanged(View* child) { 340 void WebUILoginView::ChildPreferredSizeChanged(View* child) {
308 Layout(); 341 Layout();
309 SchedulePaint(); 342 SchedulePaint();
310 } 343 }
311 344
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 aura::Env::GetInstance()->set_render_white_bg(true); 450 aura::Env::GetInstance()->set_render_white_bg(true);
418 } 451 }
419 452
420 void WebUILoginView::ReturnFocus(bool reverse) { 453 void WebUILoginView::ReturnFocus(bool reverse) {
421 // Return the focus to the web contents. 454 // Return the focus to the web contents.
422 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); 455 webui_login_->web_contents()->FocusThroughTabTraversal(reverse);
423 GetWidget()->Activate(); 456 GetWidget()->Activate();
424 } 457 }
425 458
426 } // namespace chromeos 459 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698