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

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: Fix mash test 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
114 registrar_.Add(this, 121 registrar_.Add(this,
115 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 122 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
116 content::NotificationService::AllSources()); 123 content::NotificationService::AllSources());
117 registrar_.Add(this, 124 registrar_.Add(this,
118 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, 125 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN,
119 content::NotificationService::AllSources()); 126 content::NotificationService::AllSources());
120 127
121 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = 128 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] =
122 kAccelNameCancel; 129 kAccelNameCancel;
123 accel_map_[ui::Accelerator(ui::VKEY_E, 130 accel_map_[ui::Accelerator(ui::VKEY_E,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 kAccelNameBootstrappingSlave; 171 kAccelNameBootstrappingSlave;
165 172
166 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) 173 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i)
167 AddAccelerator(i->first); 174 AddAccelerator(i->first);
168 } 175 }
169 176
170 WebUILoginView::~WebUILoginView() { 177 WebUILoginView::~WebUILoginView() {
171 for (auto& observer : observer_list_) 178 for (auto& observer : observer_list_)
172 observer.OnHostDestroying(); 179 observer.OnHostDestroying();
173 180
181 // TODO(crbug.com/648733): OnVirtualKeyboardStateChanged not supported in mash
182 if (!ash_util::IsRunningInMash())
183 ash::Shell::Get()->RemoveShellObserver(this);
184 if (keyboard::KeyboardController::GetInstance())
achuithb 2017/04/13 21:49:41 Don't we need a HasObserver test here? In case Add
achuithb 2017/04/13 21:51:28 Actually feel free to ignore this
185 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
186
174 if (!ash_util::IsRunningInMash() && 187 if (!ash_util::IsRunningInMash() &&
175 ash::Shell::Get()->HasPrimaryStatusArea()) { 188 ash::Shell::Get()->HasPrimaryStatusArea()) {
176 ash::Shell::Get()->GetPrimarySystemTray()->SetNextFocusableView(nullptr); 189 ash::Shell::Get()->GetPrimarySystemTray()->SetNextFocusableView(nullptr);
177 } else { 190 } else {
178 NOTIMPLEMENTED(); 191 NOTIMPLEMENTED();
179 } 192 }
180 193
181 // Clear any delegates we have set on the WebView. 194 // Clear any delegates we have set on the WebView.
182 WebContents* web_contents = web_view()->GetWebContents(); 195 WebContents* web_contents = web_view()->GetWebContents();
183 WebContentsModalDialogManager::FromWebContents(web_contents) 196 WebContentsModalDialogManager::FromWebContents(web_contents)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 412 }
400 default: 413 default:
401 NOTREACHED() << "Unexpected notification " << type; 414 NOTREACHED() << "Unexpected notification " << type;
402 } 415 }
403 } 416 }
404 417
405 views::WebView* WebUILoginView::web_view() { 418 views::WebView* WebUILoginView::web_view() {
406 return webui_login_.get(); 419 return webui_login_.get();
407 } 420 }
408 421
422 ////////////////////////////////////////////////////////////////////////////////
423 // ash::ShellObserver:
424
425 void WebUILoginView::OnVirtualKeyboardStateChanged(bool activated,
426 ash::WmWindow* root_window) {
427 auto* keyboard_controller = keyboard::KeyboardController::GetInstance();
428 if (keyboard_controller) {
429 if (activated) {
430 if (!keyboard_controller->HasObserver(this))
431 keyboard_controller->AddObserver(this);
432 } else {
433 keyboard_controller->RemoveObserver(this);
434 }
435 }
436 }
437
438 ////////////////////////////////////////////////////////////////////////////////
439 // keyboard::KeyboardControllerObserver:
440
441 void WebUILoginView::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
442 if (!GetOobeUI())
443 return;
444 CoreOobeView* view = GetOobeUI()->GetCoreOobeView();
445 if (new_bounds.IsEmpty()) {
446 // Keyboard has been hidden.
447 view->ShowControlBar(true);
xiyuan 2017/04/13 05:03:07 We should update LoginDisplayHostImpl [1] to conso
jdufault 2017/04/13 20:29:51 Done.
448 view->SetVirtualKeyboardShown(false);
449 } else {
450 // Keyboard has been shown.
451 view->ShowControlBar(false);
452 view->SetVirtualKeyboardShown(true);
453 }
454 }
455
456 void WebUILoginView::OnKeyboardClosed() {}
457
409 // WebUILoginView private: ----------------------------------------------------- 458 // WebUILoginView private: -----------------------------------------------------
410 459
411 bool WebUILoginView::HandleContextMenu( 460 bool WebUILoginView::HandleContextMenu(
412 const content::ContextMenuParams& params) { 461 const content::ContextMenuParams& params) {
413 // Do not show the context menu. 462 // Do not show the context menu.
414 #ifndef NDEBUG 463 #ifndef NDEBUG
415 return false; 464 return false;
416 #else 465 #else
417 return true; 466 return true;
418 #endif 467 #endif
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 if (should_emit_login_prompt_visible_) { 552 if (should_emit_login_prompt_visible_) {
504 VLOG(1) << "Login WebUI >> login-prompt-visible"; 553 VLOG(1) << "Login WebUI >> login-prompt-visible";
505 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> 554 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
506 EmitLoginPromptVisible(); 555 EmitLoginPromptVisible();
507 } 556 }
508 557
509 webui_visible_ = true; 558 webui_visible_ = true;
510 } 559 }
511 560
512 } // namespace chromeos 561 } // 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