| 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/login_performer.h" | 5 #include "chrome/browser/chromeos/login/login_performer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 14 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 15 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chromeos/boot_times_loader.h" | 16 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 18 #include "chrome/browser/chromeos/login/login_utils.h" | 17 #include "chrome/browser/chromeos/login/login_utils.h" |
| 19 #include "chrome/browser/chromeos/login/screen_locker.h" | 18 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 21 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 20 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 22 #include "chrome/browser/policy/browser_policy_connector.h" | 21 #include "chrome/browser/policy/browser_policy_connector.h" |
| 23 #include "chrome/browser/policy/device_local_account_policy_service.h" | 22 #include "chrome/browser/policy/device_local_account_policy_service.h" |
| 24 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/chrome_switches.h" | |
| 29 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 30 #include "chromeos/dbus/dbus_thread_manager.h" | 28 #include "chromeos/dbus/dbus_thread_manager.h" |
| 31 #include "chromeos/dbus/session_manager_client.h" | 29 #include "chromeos/dbus/session_manager_client.h" |
| 32 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
| 35 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 36 #include "google_apis/gaia/gaia_auth_util.h" | 34 #include "google_apis/gaia/gaia_auth_util.h" |
| 37 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 38 #include "net/cookies/cookie_monster.h" | 36 #include "net/cookies/cookie_monster.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 53 | 51 |
| 54 LoginPerformer::LoginPerformer(Delegate* delegate) | 52 LoginPerformer::LoginPerformer(Delegate* delegate) |
| 55 : ALLOW_THIS_IN_INITIALIZER_LIST(online_attempt_host_(this)), | 53 : ALLOW_THIS_IN_INITIALIZER_LIST(online_attempt_host_(this)), |
| 56 last_login_failure_(LoginFailure::None()), | 54 last_login_failure_(LoginFailure::None()), |
| 57 delegate_(delegate), | 55 delegate_(delegate), |
| 58 password_changed_(false), | 56 password_changed_(false), |
| 59 password_changed_callback_count_(0), | 57 password_changed_callback_count_(0), |
| 60 screen_lock_requested_(false), | 58 screen_lock_requested_(false), |
| 61 initial_online_auth_pending_(false), | 59 initial_online_auth_pending_(false), |
| 62 auth_mode_(AUTH_MODE_INTERNAL), | 60 auth_mode_(AUTH_MODE_INTERNAL), |
| 63 using_oauth_( | |
| 64 !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 65 switches::kSkipOAuthLogin)), | |
| 66 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 61 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 67 DCHECK(default_performer_ == NULL) | 62 DCHECK(default_performer_ == NULL) |
| 68 << "LoginPerformer should have only one instance."; | 63 << "LoginPerformer should have only one instance."; |
| 69 default_performer_ = this; | 64 default_performer_ = this; |
| 70 } | 65 } |
| 71 | 66 |
| 72 LoginPerformer::~LoginPerformer() { | 67 LoginPerformer::~LoginPerformer() { |
| 73 DVLOG(1) << "Deleting LoginPerformer"; | 68 DVLOG(1) << "Deleting LoginPerformer"; |
| 74 DCHECK(default_performer_ != NULL) << "Default instance should exist."; | 69 DCHECK(default_performer_ != NULL) << "Default instance should exist."; |
| 75 default_performer_ = NULL; | 70 default_performer_ = NULL; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 case Profile::CREATE_STATUS_INITIALIZED: | 178 case Profile::CREATE_STATUS_INITIALIZED: |
| 184 break; | 179 break; |
| 185 case Profile::CREATE_STATUS_CREATED: | 180 case Profile::CREATE_STATUS_CREATED: |
| 186 return; | 181 return; |
| 187 case Profile::CREATE_STATUS_FAIL: | 182 case Profile::CREATE_STATUS_FAIL: |
| 188 default: | 183 default: |
| 189 NOTREACHED(); | 184 NOTREACHED(); |
| 190 return; | 185 return; |
| 191 } | 186 } |
| 192 | 187 |
| 193 if (using_oauth_) | 188 // TODO(zelidrag): Figure out when this needs to run. |
| 194 LoginUtils::Get()->StartTokenServices(profile); | 189 LoginUtils::Get()->StartTokenServices(profile); |
| 195 | 190 |
| 196 // Don't unlock screen if it was locked while we're waiting | 191 // Don't unlock screen if it was locked while we're waiting |
| 197 // for initial online auth. | 192 // for initial online auth. |
| 198 if (ScreenLocker::default_screen_locker() && | 193 if (ScreenLocker::default_screen_locker() && |
| 199 !initial_online_auth_pending_) { | 194 !initial_online_auth_pending_) { |
| 200 DVLOG(1) << "Online login OK - unlocking screen."; | 195 DVLOG(1) << "Online login OK - unlocking screen."; |
| 201 RequestScreenUnlock(); | 196 RequestScreenUnlock(); |
| 202 // Do not delete itself just yet, wait for unlock. | 197 // Do not delete itself just yet, wait for unlock. |
| 203 // See ResolveScreenUnlocked(). | 198 // See ResolveScreenUnlocked(). |
| 204 return; | 199 return; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 profile, | 554 profile, |
| 560 username_, | 555 username_, |
| 561 password_, | 556 password_, |
| 562 std::string(), | 557 std::string(), |
| 563 std::string())); | 558 std::string())); |
| 564 } | 559 } |
| 565 password_.clear(); | 560 password_.clear(); |
| 566 } | 561 } |
| 567 | 562 |
| 568 } // namespace chromeos | 563 } // namespace chromeos |
| OLD | NEW |