Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/command_line.h" | |
| 11 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 12 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 16 #include "chrome/browser/chromeos/cros/cros_library.h" | 17 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 17 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 18 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
| 18 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 19 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
| 19 #include "chrome/browser/chromeos/login/webui_login_display.h" | 20 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 21 #include "chrome/browser/extensions/component_loader.h" | |
| 22 #include "chrome/browser/extensions/extension_service.h" | |
| 23 #include "chrome/browser/extensions/extension_system.h" | |
| 20 #include "chrome/browser/password_manager/password_manager.h" | 24 #include "chrome/browser/password_manager/password_manager.h" |
| 21 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" | 25 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" |
| 22 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 23 #include "chrome/browser/renderer_preferences_util.h" | 27 #include "chrome/browser/renderer_preferences_util.h" |
| 24 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 28 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
| 25 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 29 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
| 26 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 30 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_switches.h" | |
| 28 #include "chrome/common/render_messages.h" | 33 #include "chrome/common/render_messages.h" |
| 29 #include "chromeos/dbus/dbus_thread_manager.h" | 34 #include "chromeos/dbus/dbus_thread_manager.h" |
| 30 #include "chromeos/dbus/session_manager_client.h" | 35 #include "chromeos/dbus/session_manager_client.h" |
| 31 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
| 33 #include "content/public/browser/render_view_host_observer.h" | 38 #include "content/public/browser/render_view_host_observer.h" |
| 34 #include "content/public/browser/render_widget_host_view.h" | 39 #include "content/public/browser/render_widget_host_view.h" |
| 35 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 36 #include "content/public/browser/web_contents_view.h" | 41 #include "content/public/browser/web_contents_view.h" |
| 37 #include "content/public/browser/web_ui.h" | 42 #include "content/public/browser/web_ui.h" |
| 43 #include "grit/browser_resources.h" | |
| 38 #include "ui/aura/env.h" | 44 #include "ui/aura/env.h" |
| 39 #include "ui/gfx/rect.h" | 45 #include "ui/gfx/rect.h" |
| 40 #include "ui/gfx/size.h" | 46 #include "ui/gfx/size.h" |
| 41 #include "ui/views/controls/webview/webview.h" | 47 #include "ui/views/controls/webview/webview.h" |
| 42 #include "ui/views/widget/widget.h" | 48 #include "ui/views/widget/widget.h" |
| 43 | 49 |
| 44 using content::NativeWebKeyboardEvent; | 50 using content::NativeWebKeyboardEvent; |
| 45 using content::RenderViewHost; | 51 using content::RenderViewHost; |
| 46 using content::WebContents; | 52 using content::WebContents; |
| 47 | 53 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 } | 113 } |
| 108 | 114 |
| 109 } // namespace | 115 } // namespace |
| 110 | 116 |
| 111 namespace chromeos { | 117 namespace chromeos { |
| 112 | 118 |
| 113 // static | 119 // static |
| 114 const char WebUILoginView::kViewClassName[] = | 120 const char WebUILoginView::kViewClassName[] = |
| 115 "browser/chromeos/login/WebUILoginView"; | 121 "browser/chromeos/login/WebUILoginView"; |
| 116 | 122 |
| 123 // WebUILoginView::ScopedGaiaAuthExtension ------------------------------------- | |
| 124 class WebUILoginView::ScopedGaiaAuthExtension { | |
| 125 public: | |
| 126 explicit ScopedGaiaAuthExtension(Profile* profile) | |
| 127 : profile_(profile) { | |
| 128 LoadGaiaAuthExtension(); | |
| 129 } | |
| 130 | |
| 131 ~ScopedGaiaAuthExtension() { | |
| 132 UnloadGaiaAuthExtension(); | |
| 133 } | |
| 134 | |
| 135 private: | |
| 136 extensions::ComponentLoader* GetComponentLoader() { | |
| 137 extensions::ExtensionSystem* extension_system = | |
| 138 extensions::ExtensionSystem::Get(profile_); | |
| 139 ExtensionService* extension_service = extension_system->extension_service(); | |
| 140 return extension_service->component_loader(); | |
| 141 } | |
| 142 | |
| 143 void LoadGaiaAuthExtension() { | |
| 144 extensions::ComponentLoader* component_loader = GetComponentLoader(); | |
| 145 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 146 if (command_line->HasSwitch(switches::kAuthExtensionPath)) { | |
| 147 base::FilePath auth_extension_path = | |
| 148 command_line->GetSwitchValuePath(switches::kAuthExtensionPath); | |
| 149 component_loader->Add(IDR_GAIA_TEST_AUTH_MANIFEST, auth_extension_path); | |
| 150 return; | |
| 151 } | |
| 152 component_loader->Add(IDR_GAIA_AUTH_MANIFEST, | |
|
Nikita (slow)
2013/04/19 11:35:57
Is ComponentLoader just fine with postponed initia
| |
| 153 base::FilePath(FILE_PATH_LITERAL("gaia_auth"))); | |
| 154 } | |
| 155 | |
| 156 void UnloadGaiaAuthExtension() { | |
| 157 const char kGaiaAuthId[] = "mfffpogegjflfpflabcdkioaeobkgjik"; | |
| 158 GetComponentLoader()->Remove(kGaiaAuthId); | |
| 159 } | |
| 160 | |
| 161 Profile* profile_; | |
|
Nikita (slow)
2013/04/19 11:35:57
nit: // Not owned.
| |
| 162 | |
| 163 DISALLOW_COPY_AND_ASSIGN(ScopedGaiaAuthExtension); | |
| 164 }; | |
| 165 | |
| 117 // WebUILoginView public: ------------------------------------------------------ | 166 // WebUILoginView public: ------------------------------------------------------ |
| 118 | 167 |
| 119 WebUILoginView::WebUILoginView() | 168 WebUILoginView::WebUILoginView() |
| 120 : webui_login_(NULL), | 169 : webui_login_(NULL), |
| 121 login_window_(NULL), | 170 login_window_(NULL), |
| 122 host_window_frozen_(false), | 171 host_window_frozen_(false), |
| 123 is_hidden_(false), | 172 is_hidden_(false), |
| 124 login_prompt_visible_handled_(false), | 173 login_prompt_visible_handled_(false), |
| 125 should_emit_login_prompt_visible_(true), | 174 should_emit_login_prompt_visible_(true), |
| 126 forward_keyboard_event_(true) { | 175 forward_keyboard_event_(true) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 144 } | 193 } |
| 145 | 194 |
| 146 WebUILoginView::~WebUILoginView() { | 195 WebUILoginView::~WebUILoginView() { |
| 147 if (ash::Shell::GetInstance()->HasPrimaryStatusArea()) { | 196 if (ash::Shell::GetInstance()->HasPrimaryStatusArea()) { |
| 148 ash::Shell::GetInstance()->GetPrimarySystemTray()-> | 197 ash::Shell::GetInstance()->GetPrimarySystemTray()-> |
| 149 SetNextFocusableView(NULL); | 198 SetNextFocusableView(NULL); |
| 150 } | 199 } |
| 151 } | 200 } |
| 152 | 201 |
| 153 void WebUILoginView::Init(views::Widget* login_window) { | 202 void WebUILoginView::Init(views::Widget* login_window) { |
| 203 Profile* profile = ProfileManager::GetDefaultProfile(); | |
|
Nikita (slow)
2013/04/15 15:49:27
Depending on which CL lands first, this has to be
Nikita (slow)
2013/04/19 11:35:57
CL landed, this should be ProfileHelper::GetSignin
| |
| 204 gaia_auth_.reset(new ScopedGaiaAuthExtension(profile)); | |
| 205 | |
| 154 login_window_ = login_window; | 206 login_window_ = login_window; |
| 155 webui_login_ = new views::WebView(ProfileManager::GetDefaultProfile()); | 207 webui_login_ = new views::WebView(profile); |
| 156 AddChildView(webui_login_); | 208 AddChildView(webui_login_); |
| 157 | 209 |
| 158 WebContents* web_contents = webui_login_->GetWebContents(); | 210 WebContents* web_contents = webui_login_->GetWebContents(); |
| 159 | 211 |
| 160 // Create the password manager that is needed for the proxy. | 212 // Create the password manager that is needed for the proxy. |
| 161 PasswordManagerDelegateImpl::CreateForWebContents(web_contents); | 213 PasswordManagerDelegateImpl::CreateForWebContents(web_contents); |
| 162 PasswordManager::CreateForWebContentsAndDelegate( | 214 PasswordManager::CreateForWebContentsAndDelegate( |
| 163 web_contents, PasswordManagerDelegateImpl::FromWebContents(web_contents)); | 215 web_contents, PasswordManagerDelegateImpl::FromWebContents(web_contents)); |
| 164 | 216 |
| 165 // LoginHandlerViews uses a constrained window for the password manager view. | 217 // LoginHandlerViews uses a constrained window for the password manager view. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 aura::Env::GetInstance()->set_render_white_bg(true); | 430 aura::Env::GetInstance()->set_render_white_bg(true); |
| 379 } | 431 } |
| 380 | 432 |
| 381 void WebUILoginView::ReturnFocus(bool reverse) { | 433 void WebUILoginView::ReturnFocus(bool reverse) { |
| 382 // Return the focus to the web contents. | 434 // Return the focus to the web contents. |
| 383 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); | 435 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); |
| 384 GetWidget()->Activate(); | 436 GetWidget()->Activate(); |
| 385 } | 437 } |
| 386 | 438 |
| 387 } // namespace chromeos | 439 } // namespace chromeos |
| OLD | NEW |