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

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

Issue 2610373002: cros: Only preload the lock screen; do not reuse it. (Closed)
Patch Set: Address comments Created 3 years, 11 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/chromeos/login/ui/webui_login_view.h" 5 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
6 6
7 #include "ash/common/focus_cycler.h" 7 #include "ash/common/focus_cycler.h"
8 #include "ash/common/system/status_area_widget_delegate.h" 8 #include "ash/common/system/status_area_widget_delegate.h"
9 #include "ash/common/system/tray/system_tray.h" 9 #include "ash/common/system/tray/system_tray.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 21 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
22 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 22 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
23 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 23 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
24 #include "chrome/browser/chromeos/login/ui/preloaded_web_view.h"
25 #include "chrome/browser/chromeos/login/ui/preloaded_web_view_factory.h"
24 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" 26 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h"
25 #include "chrome/browser/chromeos/login/ui/shared_web_view.h"
26 #include "chrome/browser/chromeos/login/ui/shared_web_view_factory.h"
27 #include "chrome/browser/chromeos/login/ui/web_contents_forced_title.h" 27 #include "chrome/browser/chromeos/login/ui/web_contents_forced_title.h"
28 #include "chrome/browser/chromeos/login/ui/web_contents_set_background_color.h" 28 #include "chrome/browser/chromeos/login/ui/web_contents_set_background_color.h"
29 #include "chrome/browser/chromeos/login/ui/web_view_handle.h"
30 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" 29 #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
31 #include "chrome/browser/chromeos/profiles/profile_helper.h" 30 #include "chrome/browser/chromeos/profiles/profile_helper.h"
32 #include "chrome/browser/chromeos/settings/cros_settings.h" 31 #include "chrome/browser/chromeos/settings/cros_settings.h"
33 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 32 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
34 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 33 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
35 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" 34 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h"
36 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 35 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
37 #include "chrome/browser/renderer_preferences_util.h" 36 #include "chrome/browser/renderer_preferences_util.h"
38 #include "chrome/browser/sessions/session_tab_helper.h" 37 #include "chrome/browser/sessions/session_tab_helper.h"
39 #include "chrome/browser/ui/ash/ash_util.h" 38 #include "chrome/browser/ui/ash/ash_util.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 ash::Shell::GetInstance()->GetPrimarySystemTray()->GetWidget(); 251 ash::Shell::GetInstance()->GetPrimarySystemTray()->GetWidget();
253 ash::StatusAreaWidgetDelegate* status_area_widget_delegate = 252 ash::StatusAreaWidgetDelegate* status_area_widget_delegate =
254 static_cast<ash::StatusAreaWidgetDelegate*>( 253 static_cast<ash::StatusAreaWidgetDelegate*>(
255 tray_widget->GetContentsView()); 254 tray_widget->GetContentsView());
256 status_area_widget_delegate->set_custom_focus_traversable(nullptr); 255 status_area_widget_delegate->set_custom_focus_traversable(nullptr);
257 status_area_widget_delegate->set_default_last_focusable_child(false); 256 status_area_widget_delegate->set_default_last_focusable_child(false);
258 } else { 257 } else {
259 NOTIMPLEMENTED(); 258 NOTIMPLEMENTED();
260 } 259 }
261 260
262 // If the WebView is going to be reused, make sure we call teardown.
263 if (!webui_login_->HasOneRef())
264 GetWebUI()->CallJavascriptFunctionUnsafe("cr.ui.Oobe.teardown");
265
266 // Clear any delegates we have set on the WebView. 261 // Clear any delegates we have set on the WebView.
267 WebContents* web_contents = web_view()->GetWebContents(); 262 WebContents* web_contents = web_view()->GetWebContents();
268 WebContentsModalDialogManager::FromWebContents(web_contents) 263 WebContentsModalDialogManager::FromWebContents(web_contents)
269 ->SetDelegate(nullptr); 264 ->SetDelegate(nullptr);
270 web_contents->SetDelegate(nullptr); 265 web_contents->SetDelegate(nullptr);
271 } 266 }
272 267
273 // static 268 // static
274 void WebUILoginView::InitializeWebView(views::WebView* web_view, 269 void WebUILoginView::InitializeWebView(views::WebView* web_view,
275 const base::string16& title) { 270 const base::string16& title) {
(...skipping 22 matching lines...) Expand all
298 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( 293 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
299 web_contents); 294 web_contents);
300 content::RendererPreferences* prefs = web_contents->GetMutableRendererPrefs(); 295 content::RendererPreferences* prefs = web_contents->GetMutableRendererPrefs();
301 renderer_preferences_util::UpdateFromSystemSettings( 296 renderer_preferences_util::UpdateFromSystemSettings(
302 prefs, ProfileHelper::GetSigninProfile(), web_contents); 297 prefs, ProfileHelper::GetSigninProfile(), web_contents);
303 } 298 }
304 299
305 void WebUILoginView::Init() { 300 void WebUILoginView::Init() {
306 Profile* signin_profile = ProfileHelper::GetSigninProfile(); 301 Profile* signin_profile = ProfileHelper::GetSigninProfile();
307 302
308 if (!settings_.preloaded_url.is_empty()) { 303 if (settings_.check_for_preload) {
309 SharedWebView* shared_web_view = 304 PreloadedWebView* preloaded_web_view =
310 SharedWebViewFactory::GetForProfile(signin_profile); 305 PreloadedWebViewFactory::GetForProfile(signin_profile);
311 is_reusing_webview_ = 306 // webui_login_ may still be null after this call if there is no preloaded
312 shared_web_view->Get(settings_.preloaded_url, &webui_login_); 307 // instance.
313 } else { 308 webui_login_ = preloaded_web_view->TryTake();
314 webui_login_ = new WebViewHandle(signin_profile); 309 is_reusing_webview_ = true;
310 }
311
312 if (!webui_login_) {
313 webui_login_ = base::MakeUnique<views::WebView>(signin_profile);
314 webui_login_->set_owned_by_client();
315 is_reusing_webview_ = false; 315 is_reusing_webview_ = false;
316 } 316 }
317 317
318 WebContents* web_contents = web_view()->GetWebContents(); 318 WebContents* web_contents = web_view()->GetWebContents();
319 if (!is_reusing_webview_) 319 if (!is_reusing_webview_)
320 InitializeWebView(web_view(), settings_.web_view_title); 320 InitializeWebView(web_view(), settings_.web_view_title);
321 321
322 web_view()->set_allow_accelerators(true); 322 web_view()->set_allow_accelerators(true);
323 AddChildView(web_view()); 323 AddChildView(web_view());
324 324
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 386 }
387 387
388 return true; 388 return true;
389 } 389 }
390 390
391 gfx::NativeWindow WebUILoginView::GetNativeWindow() const { 391 gfx::NativeWindow WebUILoginView::GetNativeWindow() const {
392 return GetWidget()->GetNativeWindow(); 392 return GetWidget()->GetNativeWindow();
393 } 393 }
394 394
395 void WebUILoginView::LoadURL(const GURL& url) { 395 void WebUILoginView::LoadURL(const GURL& url) {
396 // If a preloaded_url is provided then |url| must match it. 396 if (!is_reusing_webview_)
397 DCHECK(settings_.preloaded_url.is_empty() || url == settings_.preloaded_url);
398
399 if (is_reusing_webview_ && !settings_.preloaded_url.is_empty())
400 GetWebUI()->CallJavascriptFunctionUnsafe("cr.ui.Oobe.reload");
401 else
402 web_view()->LoadInitialURL(url); 397 web_view()->LoadInitialURL(url);
403 web_view()->RequestFocus(); 398 web_view()->RequestFocus();
404 399
405 // There is no Shell instance while running in mash. 400 // There is no Shell instance while running in mash.
406 if (chrome::IsRunningInMash()) 401 if (chrome::IsRunningInMash())
407 return; 402 return;
408 403
409 ash::StatusAreaWidgetDelegate* status_area_widget_delegate = 404 ash::StatusAreaWidgetDelegate* status_area_widget_delegate =
410 GetStatusAreaWidgetDelegate(); 405 GetStatusAreaWidgetDelegate();
411 DCHECK(status_area_widget_delegate); 406 DCHECK(status_area_widget_delegate);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 OnLoginPromptVisible(); 488 OnLoginPromptVisible();
494 registrar_.RemoveAll(); 489 registrar_.RemoveAll();
495 break; 490 break;
496 } 491 }
497 default: 492 default:
498 NOTREACHED() << "Unexpected notification " << type; 493 NOTREACHED() << "Unexpected notification " << type;
499 } 494 }
500 } 495 }
501 496
502 views::WebView* WebUILoginView::web_view() { 497 views::WebView* WebUILoginView::web_view() {
503 return webui_login_->web_view(); 498 return webui_login_.get();
504 } 499 }
505 500
506 // WebUILoginView private: ----------------------------------------------------- 501 // WebUILoginView private: -----------------------------------------------------
507 502
508 bool WebUILoginView::HandleContextMenu( 503 bool WebUILoginView::HandleContextMenu(
509 const content::ContextMenuParams& params) { 504 const content::ContextMenuParams& params) {
510 // Do not show the context menu. 505 // Do not show the context menu.
511 #ifndef NDEBUG 506 #ifndef NDEBUG
512 return false; 507 return false;
513 #else 508 #else
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 if (should_emit_login_prompt_visible_) { 631 if (should_emit_login_prompt_visible_) {
637 VLOG(1) << "Login WebUI >> login-prompt-visible"; 632 VLOG(1) << "Login WebUI >> login-prompt-visible";
638 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> 633 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
639 EmitLoginPromptVisible(); 634 EmitLoginPromptVisible();
640 } 635 }
641 636
642 webui_visible_ = true; 637 webui_visible_ = true;
643 } 638 }
644 639
645 } // namespace chromeos 640 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/webui_login_view.h ('k') | chrome/browser/resources/chromeos/login/lock.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698