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

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

Issue 2814863002: cros: Allow JS to control virtual keyboard on sign-in screen. (Closed)
Patch Set: Remove login_display_host_impl.cc keyboard logic Created 3 years, 8 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/focus_cycler.h" 7 #include "ash/focus_cycler.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "content/public/browser/render_view_host.h" 47 #include "content/public/browser/render_view_host.h"
48 #include "content/public/browser/render_widget_host.h" 48 #include "content/public/browser/render_widget_host.h"
49 #include "content/public/browser/render_widget_host_view.h" 49 #include "content/public/browser/render_widget_host_view.h"
50 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
51 #include "content/public/browser/web_ui.h" 51 #include "content/public/browser/web_ui.h"
52 #include "content/public/common/renderer_preferences.h" 52 #include "content/public/common/renderer_preferences.h"
53 #include "extensions/browser/view_type_utils.h" 53 #include "extensions/browser/view_type_utils.h"
54 #include "third_party/WebKit/public/platform/WebInputEvent.h" 54 #include "third_party/WebKit/public/platform/WebInputEvent.h"
55 #include "ui/gfx/geometry/rect.h" 55 #include "ui/gfx/geometry/rect.h"
56 #include "ui/gfx/geometry/size.h" 56 #include "ui/gfx/geometry/size.h"
57 #include "ui/keyboard/keyboard_controller.h"
57 #include "ui/views/controls/webview/webview.h" 58 #include "ui/views/controls/webview/webview.h"
58 #include "ui/views/widget/widget.h" 59 #include "ui/views/widget/widget.h"
59 60
60 using content::NativeWebKeyboardEvent; 61 using content::NativeWebKeyboardEvent;
61 using content::RenderViewHost; 62 using content::RenderViewHost;
62 using content::WebContents; 63 using content::WebContents;
63 using web_modal::WebContentsModalDialogManager; 64 using web_modal::WebContentsModalDialogManager;
64 65
65 namespace { 66 namespace {
66 67
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 namespace chromeos { 105 namespace chromeos {
105 106
106 // static 107 // static
107 const char WebUILoginView::kViewClassName[] = 108 const char WebUILoginView::kViewClassName[] =
108 "browser/chromeos/login/WebUILoginView"; 109 "browser/chromeos/login/WebUILoginView";
109 110
110 // WebUILoginView public: ------------------------------------------------------ 111 // WebUILoginView public: ------------------------------------------------------
111 112
112 WebUILoginView::WebUILoginView(const WebViewSettings& settings) 113 WebUILoginView::WebUILoginView(const WebViewSettings& settings)
113 : settings_(settings) { 114 : settings_(settings) {
115 if (keyboard::KeyboardController::GetInstance())
116 keyboard::KeyboardController::GetInstance()->AddObserver(this);
117 // TODO(crbug.com/648733): OnVirtualKeyboardStateChanged not supported in mash
118 if (!ash_util::IsRunningInMash())
119 ash::Shell::Get()->AddShellObserver(this);
120 else
121 NOTIMPLEMENTED();
122
114 registrar_.Add(this, 123 registrar_.Add(this,
115 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 124 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
116 content::NotificationService::AllSources()); 125 content::NotificationService::AllSources());
117 registrar_.Add(this, 126 registrar_.Add(this,
118 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, 127 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN,
119 content::NotificationService::AllSources()); 128 content::NotificationService::AllSources());
120 129
121 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = 130 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] =
122 kAccelNameCancel; 131 kAccelNameCancel;
123 accel_map_[ui::Accelerator(ui::VKEY_E, 132 accel_map_[ui::Accelerator(ui::VKEY_E,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 kAccelNameBootstrappingSlave; 173 kAccelNameBootstrappingSlave;
165 174
166 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) 175 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i)
167 AddAccelerator(i->first); 176 AddAccelerator(i->first);
168 } 177 }
169 178
170 WebUILoginView::~WebUILoginView() { 179 WebUILoginView::~WebUILoginView() {
171 for (auto& observer : observer_list_) 180 for (auto& observer : observer_list_)
172 observer.OnHostDestroying(); 181 observer.OnHostDestroying();
173 182
183 // TODO(crbug.com/648733): OnVirtualKeyboardStateChanged not supported in mash
184 if (!ash_util::IsRunningInMash())
185 ash::Shell::Get()->RemoveShellObserver(this);
186 if (keyboard::KeyboardController::GetInstance())
187 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
188
174 if (!ash_util::IsRunningInMash() && 189 if (!ash_util::IsRunningInMash() &&
175 ash::Shell::Get()->HasPrimaryStatusArea()) { 190 ash::Shell::Get()->HasPrimaryStatusArea()) {
176 ash::Shell::Get()->GetPrimarySystemTray()->SetNextFocusableView(nullptr); 191 ash::Shell::Get()->GetPrimarySystemTray()->SetNextFocusableView(nullptr);
177 } else { 192 } else {
178 NOTIMPLEMENTED(); 193 NOTIMPLEMENTED();
179 } 194 }
180 195
181 // Clear any delegates we have set on the WebView. 196 // Clear any delegates we have set on the WebView.
182 WebContents* web_contents = web_view()->GetWebContents(); 197 WebContents* web_contents = web_view()->GetWebContents();
183 WebContentsModalDialogManager::FromWebContents(web_contents) 198 WebContentsModalDialogManager::FromWebContents(web_contents)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 414 }
400 default: 415 default:
401 NOTREACHED() << "Unexpected notification " << type; 416 NOTREACHED() << "Unexpected notification " << type;
402 } 417 }
403 } 418 }
404 419
405 views::WebView* WebUILoginView::web_view() { 420 views::WebView* WebUILoginView::web_view() {
406 return webui_login_.get(); 421 return webui_login_.get();
407 } 422 }
408 423
424 ////////////////////////////////////////////////////////////////////////////////
425 // ash::ShellObserver:
426
427 void WebUILoginView::OnVirtualKeyboardStateChanged(bool activated,
428 ash::WmWindow* root_window) {
429 auto* keyboard_controller = keyboard::KeyboardController::GetInstance();
430 if (keyboard_controller) {
431 if (activated) {
432 if (!keyboard_controller->HasObserver(this))
433 keyboard_controller->AddObserver(this);
434 } else {
435 keyboard_controller->RemoveObserver(this);
436 }
437 }
438 }
439
440 ////////////////////////////////////////////////////////////////////////////////
441 // keyboard::KeyboardControllerObserver:
442
443 void WebUILoginView::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
444 if (!GetOobeUI())
445 return;
446 CoreOobeView* view = GetOobeUI()->GetCoreOobeView();
447 if (new_bounds.IsEmpty()) {
448 // Keyboard has been hidden.
449 view->ShowControlBar(true);
450 view->SetVirtualKeyboardShown(false);
451 } else {
452 // Keyboard has been shown.
453 view->ShowControlBar(false);
454 view->SetVirtualKeyboardShown(true);
455 }
456 }
457
458 void WebUILoginView::OnKeyboardClosed() {}
459
409 // WebUILoginView private: ----------------------------------------------------- 460 // WebUILoginView private: -----------------------------------------------------
410 461
411 bool WebUILoginView::HandleContextMenu( 462 bool WebUILoginView::HandleContextMenu(
412 const content::ContextMenuParams& params) { 463 const content::ContextMenuParams& params) {
413 // Do not show the context menu. 464 // Do not show the context menu.
414 #ifndef NDEBUG 465 #ifndef NDEBUG
415 return false; 466 return false;
416 #else 467 #else
417 return true; 468 return true;
418 #endif 469 #endif
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 if (should_emit_login_prompt_visible_) { 554 if (should_emit_login_prompt_visible_) {
504 VLOG(1) << "Login WebUI >> login-prompt-visible"; 555 VLOG(1) << "Login WebUI >> login-prompt-visible";
505 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> 556 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
506 EmitLoginPromptVisible(); 557 EmitLoginPromptVisible();
507 } 558 }
508 559
509 webui_visible_ = true; 560 webui_visible_ = true;
510 } 561 }
511 562
512 } // namespace chromeos 563 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/webui_login_view.h ('k') | chrome/browser/resources/chromeos/login/login_shared.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698