| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ui/webui/chromeos/login/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 18 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 19 #include "chrome/browser/browser_shutdown.h" | 19 #include "chrome/browser/browser_shutdown.h" |
| 20 #include "chrome/browser/chromeos/cros/cros_library.h" | |
| 21 #include "chrome/browser/chromeos/cros/network_library.h" | |
| 22 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 20 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 23 #include "chrome/browser/chromeos/login/hwid_checker.h" | 21 #include "chrome/browser/chromeos/login/hwid_checker.h" |
| 24 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 22 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 25 #include "chrome/browser/chromeos/login/screen_locker.h" | 23 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 26 #include "chrome/browser/chromeos/login/user.h" | 24 #include "chrome/browser/chromeos/login/user.h" |
| 27 #include "chrome/browser/chromeos/login/webui_login_display.h" | 25 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 28 #include "chrome/browser/chromeos/login/wizard_controller.h" | 26 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 29 #include "chrome/browser/chromeos/net/network_portal_detector.h" | 27 #include "chrome/browser/chromeos/net/network_portal_detector.h" |
| 30 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 31 #include "chrome/browser/chromeos/settings/cros_settings.h" | 29 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 32 #include "chrome/browser/io_thread.h" | 30 #include "chrome/browser/io_thread.h" |
| 33 #include "chrome/browser/policy/browser_policy_connector.h" | 31 #include "chrome/browser/policy/browser_policy_connector.h" |
| 34 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 35 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" | 33 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" |
| 36 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" | 34 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" |
| 37 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 35 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
| 38 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 36 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 39 #include "chrome/common/chrome_notification_types.h" | 37 #include "chrome/common/chrome_notification_types.h" |
| 40 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 41 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 42 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
| 43 #include "chromeos/chromeos_switches.h" | 41 #include "chromeos/chromeos_switches.h" |
| 44 #include "chromeos/dbus/dbus_thread_manager.h" | 42 #include "chromeos/dbus/dbus_thread_manager.h" |
| 45 #include "chromeos/dbus/power_manager_client.h" | 43 #include "chromeos/dbus/power_manager_client.h" |
| 46 #include "chromeos/ime/input_method_manager.h" | 44 #include "chromeos/ime/input_method_manager.h" |
| 47 #include "chromeos/ime/xkeyboard.h" | 45 #include "chromeos/ime/xkeyboard.h" |
| 46 #include "chromeos/network/network_state.h" |
| 47 #include "chromeos/network/network_state_handler.h" |
| 48 #include "content/public/browser/render_view_host.h" | 48 #include "content/public/browser/render_view_host.h" |
| 49 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 50 #include "google_apis/gaia/gaia_auth_util.h" | 50 #include "google_apis/gaia/gaia_auth_util.h" |
| 51 #include "google_apis/gaia/gaia_switches.h" | 51 #include "google_apis/gaia/gaia_switches.h" |
| 52 #include "google_apis/gaia/gaia_urls.h" | 52 #include "google_apis/gaia/gaia_urls.h" |
| 53 #include "grit/chromium_strings.h" | 53 #include "grit/chromium_strings.h" |
| 54 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
| 55 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 55 #include "ui/base/l10n/l10n_util.h" | 56 #include "ui/base/l10n/l10n_util.h" |
| 56 | 57 |
| 57 #if defined(USE_AURA) | 58 #if defined(USE_AURA) |
| 58 #include "ash/shell.h" | 59 #include "ash/shell.h" |
| 59 #include "ash/wm/session_state_controller.h" | 60 #include "ash/wm/session_state_controller.h" |
| 60 #endif | 61 #endif |
| 61 | 62 |
| 62 using content::BrowserThread; | 63 using content::BrowserThread; |
| 63 using content::RenderViewHost; | 64 using content::RenderViewHost; |
| 64 | 65 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 screen == OobeUI::SCREEN_ACCOUNT_PICKER; | 215 screen == OobeUI::SCREEN_ACCOUNT_PICKER; |
| 215 } | 216 } |
| 216 | 217 |
| 217 bool IsSigninScreenError(ErrorScreen::ErrorState error_state) { | 218 bool IsSigninScreenError(ErrorScreen::ErrorState error_state) { |
| 218 return error_state == ErrorScreen::ERROR_STATE_PORTAL || | 219 return error_state == ErrorScreen::ERROR_STATE_PORTAL || |
| 219 error_state == ErrorScreen::ERROR_STATE_OFFLINE || | 220 error_state == ErrorScreen::ERROR_STATE_OFFLINE || |
| 220 error_state == ErrorScreen::ERROR_STATE_PROXY || | 221 error_state == ErrorScreen::ERROR_STATE_PROXY || |
| 221 error_state == ErrorScreen::ERROR_STATE_AUTH_EXT_TIMEOUT; | 222 error_state == ErrorScreen::ERROR_STATE_AUTH_EXT_TIMEOUT; |
| 222 } | 223 } |
| 223 | 224 |
| 224 // Returns a pointer to a Network instance by service path or NULL if | |
| 225 // network can not be found. | |
| 226 Network* FindNetworkByPath(const std::string& service_path) { | |
| 227 CrosLibrary* cros = CrosLibrary::Get(); | |
| 228 if (!cros) | |
| 229 return NULL; | |
| 230 NetworkLibrary* network_library = cros->GetNetworkLibrary(); | |
| 231 if (!network_library) | |
| 232 return NULL; | |
| 233 return network_library->FindNetworkByPath(service_path); | |
| 234 } | |
| 235 | |
| 236 // Returns network name by service path. | 225 // Returns network name by service path. |
| 237 std::string GetNetworkName(const std::string& service_path) { | 226 std::string GetNetworkName(const std::string& service_path) { |
| 238 Network* network = FindNetworkByPath(service_path); | 227 const NetworkState* network = |
| 228 NetworkStateHandler::Get()->GetNetworkState(service_path); |
| 239 if (!network) | 229 if (!network) |
| 240 return std::string(); | 230 return std::string(); |
| 241 return network->name(); | 231 return network->name(); |
| 242 } | 232 } |
| 243 | 233 |
| 244 // Returns network unique id by service path. | 234 // Returns network unique id by service path. |
| 245 std::string GetNetworkUniqueId(const std::string& service_path) { | 235 std::string GetNetworkUniqueId(const std::string& service_path) { |
| 246 Network* network = FindNetworkByPath(service_path); | 236 const NetworkState* network = |
| 237 NetworkStateHandler::Get()->GetNetworkState(service_path); |
| 247 if (!network) | 238 if (!network) |
| 248 return std::string(); | 239 return std::string(); |
| 249 return network->unique_id(); | 240 return network->guid(); |
| 250 } | 241 } |
| 251 | 242 |
| 252 // Returns captive portal state for a network by its service path. | 243 // Returns captive portal state for a network by its service path. |
| 253 NetworkPortalDetector::CaptivePortalState GetCaptivePortalState( | 244 NetworkPortalDetector::CaptivePortalState GetCaptivePortalState( |
| 254 const std::string& service_path) { | 245 const std::string& service_path) { |
| 255 NetworkPortalDetector* detector = NetworkPortalDetector::GetInstance(); | 246 NetworkPortalDetector* detector = NetworkPortalDetector::GetInstance(); |
| 256 Network* network = FindNetworkByPath(service_path); | 247 const NetworkState* network = |
| 248 NetworkStateHandler::Get()->GetNetworkState(service_path); |
| 257 if (!detector || !network) | 249 if (!detector || !network) |
| 258 return NetworkPortalDetector::CaptivePortalState(); | 250 return NetworkPortalDetector::CaptivePortalState(); |
| 259 return detector->GetCaptivePortalState(network); | 251 return detector->GetCaptivePortalState(network); |
| 260 } | 252 } |
| 261 | 253 |
| 262 void RecordDiscrepancyWithShill( | 254 void RecordDiscrepancyWithShill( |
| 263 const Network* network, | 255 const NetworkState* network, |
| 264 const NetworkPortalDetector::CaptivePortalStatus status) { | 256 const NetworkPortalDetector::CaptivePortalStatus status) { |
| 265 if (network->online()) { | 257 if (network->connection_state() == flimflam::kStateOnline) { |
| 266 UMA_HISTOGRAM_ENUMERATION( | 258 UMA_HISTOGRAM_ENUMERATION( |
| 267 "CaptivePortal.OOBE.DiscrepancyWithShill_Online", | 259 "CaptivePortal.OOBE.DiscrepancyWithShill_Online", |
| 268 status, | 260 status, |
| 269 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 261 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 270 } else if (network->restricted_pool()) { | 262 } else if (network->connection_state() == flimflam::kStatePortal) { |
| 271 UMA_HISTOGRAM_ENUMERATION( | 263 UMA_HISTOGRAM_ENUMERATION( |
| 272 "CaptivePortal.OOBE.DiscrepancyWithShill_RestrictedPool", | 264 "CaptivePortal.OOBE.DiscrepancyWithShill_RestrictedPool", |
| 273 status, | 265 status, |
| 274 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 266 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 275 } else { | 267 } else { |
| 276 UMA_HISTOGRAM_ENUMERATION( | 268 UMA_HISTOGRAM_ENUMERATION( |
| 277 "CaptivePortal.OOBE.DiscrepancyWithShill_Offline", | 269 "CaptivePortal.OOBE.DiscrepancyWithShill_Offline", |
| 278 status, | 270 status, |
| 279 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 271 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 280 } | 272 } |
| 281 } | 273 } |
| 282 | 274 |
| 283 // Record state and descripancies with shill (e.g. shill thinks that | 275 // Record state and descripancies with shill (e.g. shill thinks that |
| 284 // network is online but NetworkPortalDetector claims that it's behind | 276 // network is online but NetworkPortalDetector claims that it's behind |
| 285 // portal) for the network identified by |service_path|. | 277 // portal) for the network identified by |service_path|. |
| 286 void RecordNetworkPortalDetectorStats(const std::string& service_path) { | 278 void RecordNetworkPortalDetectorStats(const std::string& service_path) { |
| 287 const Network* network = FindNetworkByPath(service_path); | 279 const NetworkState* network = |
| 280 NetworkStateHandler::Get()->GetNetworkState(service_path); |
| 288 if (!network) | 281 if (!network) |
| 289 return; | 282 return; |
| 290 NetworkPortalDetector::CaptivePortalState state = | 283 NetworkPortalDetector::CaptivePortalState state = |
| 291 GetCaptivePortalState(service_path); | 284 GetCaptivePortalState(service_path); |
| 292 if (state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) | 285 if (state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) |
| 293 return; | 286 return; |
| 294 | 287 |
| 295 UMA_HISTOGRAM_ENUMERATION("CaptivePortal.OOBE.DetectionResult", | 288 UMA_HISTOGRAM_ENUMERATION("CaptivePortal.OOBE.DetectionResult", |
| 296 state.status, | 289 state.status, |
| 297 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); | 290 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT); |
| 298 | 291 |
| 299 switch (state.status) { | 292 switch (state.status) { |
| 300 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: | 293 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
| 301 NOTREACHED(); | 294 NOTREACHED(); |
| 302 break; | 295 break; |
| 303 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: | 296 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: |
| 304 if (network->online() || network->restricted_pool()) | 297 if (network->connection_state() == flimflam::kStateOnline || |
| 298 network->connection_state() == flimflam::kStatePortal) |
| 305 RecordDiscrepancyWithShill(network, state.status); | 299 RecordDiscrepancyWithShill(network, state.status); |
| 306 break; | 300 break; |
| 307 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: | 301 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: |
| 308 if (!network->online()) | 302 if (network->connection_state() != flimflam::kStateOnline) |
| 309 RecordDiscrepancyWithShill(network, state.status); | 303 RecordDiscrepancyWithShill(network, state.status); |
| 310 break; | 304 break; |
| 311 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: | 305 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: |
| 312 if (!network->restricted_pool()) | 306 if (network->connection_state() != flimflam::kStatePortal) |
| 313 RecordDiscrepancyWithShill(network, state.status); | 307 RecordDiscrepancyWithShill(network, state.status); |
| 314 break; | 308 break; |
| 315 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | 309 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
| 316 if (!network->online()) | 310 if (network->connection_state() != flimflam::kStateOnline) |
| 317 RecordDiscrepancyWithShill(network, state.status); | 311 RecordDiscrepancyWithShill(network, state.status); |
| 318 break; | 312 break; |
| 319 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: | 313 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: |
| 320 NOTREACHED(); | 314 NOTREACHED(); |
| 321 break; | 315 break; |
| 322 } | 316 } |
| 323 } | 317 } |
| 324 | 318 |
| 325 } // namespace | 319 } // namespace |
| 326 | 320 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 error_screen_actor_->AllowGuestSignin(guest_signin_allowed); | 689 error_screen_actor_->AllowGuestSignin(guest_signin_allowed); |
| 696 | 690 |
| 697 const bool offline_login_allowed = IsOfflineLoginAllowed() && | 691 const bool offline_login_allowed = IsOfflineLoginAllowed() && |
| 698 IsSigninScreenError(error_screen_actor_->error_state()) && | 692 IsSigninScreenError(error_screen_actor_->error_state()) && |
| 699 error_screen_actor_->error_state() != | 693 error_screen_actor_->error_state() != |
| 700 ErrorScreen::ERROR_STATE_AUTH_EXT_TIMEOUT; | 694 ErrorScreen::ERROR_STATE_AUTH_EXT_TIMEOUT; |
| 701 error_screen_actor_->AllowOfflineLogin(offline_login_allowed); | 695 error_screen_actor_->AllowOfflineLogin(offline_login_allowed); |
| 702 | 696 |
| 703 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) { | 697 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) { |
| 704 DictionaryValue params; | 698 DictionaryValue params; |
| 705 const ConnectionType connection_type = | 699 const std::string connection_type = |
| 706 network_state_informer_->last_network_type(); | 700 network_state_informer_->last_network_type(); |
| 707 params.SetInteger("lastNetworkType", static_cast<int>(connection_type)); | 701 params.SetString("lastNetworkType", connection_type); |
| 708 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_SIGNIN); | 702 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_SIGNIN); |
| 709 error_screen_actor_->Show(OobeUI::SCREEN_GAIA_SIGNIN, ¶ms); | 703 error_screen_actor_->Show(OobeUI::SCREEN_GAIA_SIGNIN, ¶ms); |
| 710 } | 704 } |
| 711 } | 705 } |
| 712 | 706 |
| 713 void SigninScreenHandler::HideOfflineMessage( | 707 void SigninScreenHandler::HideOfflineMessage( |
| 714 NetworkStateInformer::State state, | 708 NetworkStateInformer::State state, |
| 715 ErrorScreenActor::ErrorReason reason) { | 709 ErrorScreenActor::ErrorReason reason) { |
| 716 if (!IsSigninScreenHiddenByError()) | 710 if (!IsSigninScreenHiddenByError()) |
| 717 return; | 711 return; |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 if (!cros_settings) | 1583 if (!cros_settings) |
| 1590 return false; | 1584 return false; |
| 1591 | 1585 |
| 1592 // Offline login is allowed only when user pods are hidden. | 1586 // Offline login is allowed only when user pods are hidden. |
| 1593 bool show_pods; | 1587 bool show_pods; |
| 1594 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1588 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
| 1595 return !show_pods; | 1589 return !show_pods; |
| 1596 } | 1590 } |
| 1597 | 1591 |
| 1598 } // namespace chromeos | 1592 } // namespace chromeos |
| OLD | NEW |