| 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/chromeos/login/ui/webui_login_view.h" | 5 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 6 | 6 |
| 7 #include <unordered_set> |
| 8 |
| 7 #include "ash/common/focus_cycler.h" | 9 #include "ash/common/focus_cycler.h" |
| 8 #include "ash/common/system/status_area_widget_delegate.h" | 10 #include "ash/common/system/status_area_widget_delegate.h" |
| 9 #include "ash/common/system/tray/system_tray.h" | 11 #include "ash/common/system/tray/system_tray.h" |
| 10 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 11 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 12 #include "base/bind.h" | 14 #include "base/bind.h" |
| 13 #include "base/callback.h" | 15 #include "base/callback.h" |
| 14 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
| 15 #include "base/logging.h" | 17 #include "base/logging.h" |
| 16 #include "base/macros.h" | 18 #include "base/macros.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
| 19 #include "base/values.h" | 21 #include "base/values.h" |
| 20 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 21 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 23 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 22 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 24 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 23 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 25 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 24 #include "chrome/browser/chromeos/login/ui/preloaded_web_view.h" | 26 #include "chrome/browser/chromeos/login/ui/preloaded_web_view.h" |
| 25 #include "chrome/browser/chromeos/login/ui/preloaded_web_view_factory.h" | 27 #include "chrome/browser/chromeos/login/ui/preloaded_web_view_factory.h" |
| 26 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" | 28 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" |
| 27 #include "chrome/browser/chromeos/login/ui/web_contents_forced_title.h" | 29 #include "chrome/browser/chromeos/login/ui/web_contents_forced_title.h" |
| 28 #include "chrome/browser/chromeos/login/ui/web_contents_set_background_color.h" | 30 #include "chrome/browser/chromeos/login/ui/web_contents_set_background_color.h" |
| 29 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 31 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 30 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 32 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 31 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 32 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 33 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 33 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 34 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| 34 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | 35 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| 35 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 36 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 36 #include "chrome/browser/renderer_preferences_util.h" | 37 #include "chrome/browser/renderer_preferences_util.h" |
| 37 #include "chrome/browser/sessions/session_tab_helper.h" | 38 #include "chrome/browser/sessions/session_tab_helper.h" |
| 38 #include "chrome/browser/ui/ash/ash_util.h" | 39 #include "chrome/browser/ui/ash/ash_util.h" |
| 39 #include "chrome/browser/ui/ash/system_tray_client.h" | 40 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 40 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" | 41 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
| 41 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 42 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 42 #include "chromeos/dbus/dbus_thread_manager.h" | 43 #include "chromeos/dbus/dbus_thread_manager.h" |
| 43 #include "chromeos/dbus/session_manager_client.h" | 44 #include "chromeos/dbus/session_manager_client.h" |
| 44 #include "chromeos/network/network_state.h" | 45 #include "chromeos/network/network_state.h" |
| 45 #include "chromeos/network/network_state_handler.h" | 46 #include "chromeos/network/network_state_handler.h" |
| 46 #include "chromeos/settings/cros_settings_names.h" | |
| 47 #include "components/content_settings/core/common/content_settings_pattern.h" | 47 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 48 #include "components/password_manager/core/browser/password_manager.h" | 48 #include "components/password_manager/core/browser/password_manager.h" |
| 49 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 49 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 50 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" |
| 51 #include "content/public/browser/render_frame_host.h" | 51 #include "content/public/browser/render_frame_host.h" |
| 52 #include "content/public/browser/render_view_host.h" | 52 #include "content/public/browser/render_view_host.h" |
| 53 #include "content/public/browser/render_widget_host.h" | 53 #include "content/public/browser/render_widget_host.h" |
| 54 #include "content/public/browser/render_widget_host_view.h" | 54 #include "content/public/browser/render_widget_host_view.h" |
| 55 #include "content/public/browser/web_contents.h" | 55 #include "content/public/browser/web_contents.h" |
| 56 #include "content/public/browser/web_ui.h" | 56 #include "content/public/browser/web_ui.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 // A helper method returns status area widget delegate if exists, | 111 // A helper method returns status area widget delegate if exists, |
| 112 // otherwise nullptr. | 112 // otherwise nullptr. |
| 113 ash::StatusAreaWidgetDelegate* GetStatusAreaWidgetDelegate() { | 113 ash::StatusAreaWidgetDelegate* GetStatusAreaWidgetDelegate() { |
| 114 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 114 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 115 return tray ? static_cast<ash::StatusAreaWidgetDelegate*>( | 115 return tray ? static_cast<ash::StatusAreaWidgetDelegate*>( |
| 116 tray->GetWidget()->GetContentsView()) | 116 tray->GetWidget()->GetContentsView()) |
| 117 : nullptr; | 117 : nullptr; |
| 118 } | 118 } |
| 119 | 119 |
| 120 std::unordered_set<const content::WebContentsDelegate*>* |
| 121 GetWebUILoginViewSet() { |
| 122 CR_DEFINE_STATIC_LOCAL( |
| 123 std::unordered_set<const content::WebContentsDelegate*>, |
| 124 g_webui_login_view_set, ()); |
| 125 return &g_webui_login_view_set; |
| 126 } |
| 127 |
| 120 } // namespace | 128 } // namespace |
| 121 | 129 |
| 122 namespace chromeos { | 130 namespace chromeos { |
| 123 | 131 |
| 124 // static | 132 // static |
| 125 const char WebUILoginView::kViewClassName[] = | 133 const char WebUILoginView::kViewClassName[] = |
| 126 "browser/chromeos/login/WebUILoginView"; | 134 "browser/chromeos/login/WebUILoginView"; |
| 127 | 135 |
| 128 // WebUILoginView::CycleFocusTraversable --------------------------------------- | 136 // WebUILoginView::CycleFocusTraversable --------------------------------------- |
| 129 class WebUILoginView::CycleFocusTraversable : public views::FocusTraversable { | 137 class WebUILoginView::CycleFocusTraversable : public views::FocusTraversable { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 181 |
| 174 private: | 182 private: |
| 175 WebUILoginView* const webui_login_view_; | 183 WebUILoginView* const webui_login_view_; |
| 176 views::FocusSearch status_area_focus_search_; | 184 views::FocusSearch status_area_focus_search_; |
| 177 | 185 |
| 178 DISALLOW_COPY_AND_ASSIGN(StatusAreaFocusTraversable); | 186 DISALLOW_COPY_AND_ASSIGN(StatusAreaFocusTraversable); |
| 179 }; | 187 }; |
| 180 | 188 |
| 181 // WebUILoginView public: ------------------------------------------------------ | 189 // WebUILoginView public: ------------------------------------------------------ |
| 182 | 190 |
| 191 // static |
| 192 bool WebUILoginView::IsWebUILoginView( |
| 193 const content::WebContentsDelegate* delegate) { |
| 194 return base::ContainsKey(*GetWebUILoginViewSet(), delegate); |
| 195 } |
| 196 |
| 183 WebUILoginView::WebUILoginView(const WebViewSettings& settings) | 197 WebUILoginView::WebUILoginView(const WebViewSettings& settings) |
| 184 : settings_(settings) { | 198 : settings_(settings) { |
| 199 auto was_added = GetWebUILoginViewSet()->insert(this); |
| 200 DCHECK(was_added.second); |
| 201 |
| 185 registrar_.Add(this, | 202 registrar_.Add(this, |
| 186 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 203 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 187 content::NotificationService::AllSources()); | 204 content::NotificationService::AllSources()); |
| 188 registrar_.Add(this, | 205 registrar_.Add(this, |
| 189 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, | 206 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, |
| 190 content::NotificationService::AllSources()); | 207 content::NotificationService::AllSources()); |
| 191 | 208 |
| 192 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = | 209 accel_map_[ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)] = |
| 193 kAccelNameCancel; | 210 kAccelNameCancel; |
| 194 accel_map_[ui::Accelerator(ui::VKEY_E, | 211 accel_map_[ui::Accelerator(ui::VKEY_E, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 252 |
| 236 accel_map_[ui::Accelerator( | 253 accel_map_[ui::Accelerator( |
| 237 ui::VKEY_S, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN)] = | 254 ui::VKEY_S, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN)] = |
| 238 kAccelNameBootstrappingSlave; | 255 kAccelNameBootstrappingSlave; |
| 239 | 256 |
| 240 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) | 257 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) |
| 241 AddAccelerator(i->first); | 258 AddAccelerator(i->first); |
| 242 } | 259 } |
| 243 | 260 |
| 244 WebUILoginView::~WebUILoginView() { | 261 WebUILoginView::~WebUILoginView() { |
| 262 size_t num_removed = GetWebUILoginViewSet()->erase(this); |
| 263 DCHECK_EQ(1u, num_removed); |
| 264 |
| 245 for (auto& observer : observer_list_) | 265 for (auto& observer : observer_list_) |
| 246 observer.OnHostDestroying(); | 266 observer.OnHostDestroying(); |
| 247 | 267 |
| 248 if (!chrome::IsRunningInMash() && | 268 if (!chrome::IsRunningInMash() && |
| 249 ash::Shell::GetInstance()->HasPrimaryStatusArea()) { | 269 ash::Shell::GetInstance()->HasPrimaryStatusArea()) { |
| 250 views::Widget* tray_widget = | 270 views::Widget* tray_widget = |
| 251 ash::Shell::GetInstance()->GetPrimarySystemTray()->GetWidget(); | 271 ash::Shell::GetInstance()->GetPrimarySystemTray()->GetWidget(); |
| 252 ash::StatusAreaWidgetDelegate* status_area_widget_delegate = | 272 ash::StatusAreaWidgetDelegate* status_area_widget_delegate = |
| 253 static_cast<ash::StatusAreaWidgetDelegate*>( | 273 static_cast<ash::StatusAreaWidgetDelegate*>( |
| 254 tray_widget->GetContentsView()); | 274 tray_widget->GetContentsView()); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 reverse ? ash::FocusCycler::BACKWARD : ash::FocusCycler::FORWARD); | 575 reverse ? ash::FocusCycler::BACKWARD : ash::FocusCycler::FORWARD); |
| 556 } | 576 } |
| 557 | 577 |
| 558 return true; | 578 return true; |
| 559 } | 579 } |
| 560 | 580 |
| 561 void WebUILoginView::RequestMediaAccessPermission( | 581 void WebUILoginView::RequestMediaAccessPermission( |
| 562 WebContents* web_contents, | 582 WebContents* web_contents, |
| 563 const content::MediaStreamRequest& request, | 583 const content::MediaStreamRequest& request, |
| 564 const content::MediaResponseCallback& callback) { | 584 const content::MediaResponseCallback& callback) { |
| 585 // Note: This is only needed for SAML logins. |
| 565 MediaStreamDevicesController controller(web_contents, request, callback); | 586 MediaStreamDevicesController controller(web_contents, request, callback); |
| 566 if (!controller.IsAskingForAudio() && !controller.IsAskingForVideo()) | 587 DCHECK(!controller.IsAskingForAudio() && !controller.IsAskingForVideo()); |
| 567 return; | |
| 568 | |
| 569 if (controller.IsAskingForAudio()) { | |
| 570 controller.PermissionDenied(); | |
| 571 return; | |
| 572 } | |
| 573 | |
| 574 const CrosSettings* const settings = CrosSettings::Get(); | |
| 575 if (!settings) { | |
| 576 controller.PermissionDenied(); | |
| 577 return; | |
| 578 } | |
| 579 | |
| 580 const base::Value* const raw_list_value = | |
| 581 settings->GetPref(kLoginVideoCaptureAllowedUrls); | |
| 582 if (!raw_list_value) { | |
| 583 controller.PermissionDenied(); | |
| 584 return; | |
| 585 } | |
| 586 | |
| 587 const base::ListValue* list_value; | |
| 588 CHECK(raw_list_value->GetAsList(&list_value)); | |
| 589 for (const auto& base_value : *list_value) { | |
| 590 std::string value; | |
| 591 if (base_value->GetAsString(&value)) { | |
| 592 ContentSettingsPattern pattern = | |
| 593 ContentSettingsPattern::FromString(value); | |
| 594 if (pattern == ContentSettingsPattern::Wildcard()) { | |
| 595 LOG(WARNING) << "Ignoring wildcard URL pattern: " << value; | |
| 596 continue; | |
| 597 } | |
| 598 if (pattern.IsValid() && pattern.Matches(request.security_origin)) { | |
| 599 controller.PermissionGranted(); | |
| 600 return; | |
| 601 } | |
| 602 } | |
| 603 } | |
| 604 controller.PermissionDenied(); | |
| 605 } | 588 } |
| 606 | 589 |
| 607 bool WebUILoginView::CheckMediaAccessPermission( | 590 bool WebUILoginView::CheckMediaAccessPermission( |
| 608 content::WebContents* web_contents, | 591 content::WebContents* web_contents, |
| 609 const GURL& security_origin, | 592 const GURL& security_origin, |
| 610 content::MediaStreamType type) { | 593 content::MediaStreamType type) { |
| 611 return MediaCaptureDevicesDispatcher::GetInstance() | 594 return MediaCaptureDevicesDispatcher::GetInstance() |
| 612 ->CheckMediaAccessPermission(web_contents, security_origin, type); | 595 ->CheckMediaAccessPermission(web_contents, security_origin, type); |
| 613 } | 596 } |
| 614 | 597 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 631 if (should_emit_login_prompt_visible_) { | 614 if (should_emit_login_prompt_visible_) { |
| 632 VLOG(1) << "Login WebUI >> login-prompt-visible"; | 615 VLOG(1) << "Login WebUI >> login-prompt-visible"; |
| 633 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 616 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 634 EmitLoginPromptVisible(); | 617 EmitLoginPromptVisible(); |
| 635 } | 618 } |
| 636 | 619 |
| 637 webui_visible_ = true; | 620 webui_visible_ = true; |
| 638 } | 621 } |
| 639 | 622 |
| 640 } // namespace chromeos | 623 } // namespace chromeos |
| OLD | NEW |