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/wizard_controller.h" | 5 #include "chrome/browser/chromeos/login/wizard_controller.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/callback_helpers.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/prefs/pref_registry_simple.h" | 18 #include "base/prefs/pref_registry_simple.h" |
18 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
21 #include "base/values.h" | 22 #include "base/values.h" |
22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
24 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 25 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #else | 148 #else |
148 is_official_build_(false), | 149 is_official_build_(false), |
149 #endif | 150 #endif |
150 is_out_of_box_(false), | 151 is_out_of_box_(false), |
151 host_(host), | 152 host_(host), |
152 oobe_display_(oobe_display), | 153 oobe_display_(oobe_display), |
153 usage_statistics_reporting_(true), | 154 usage_statistics_reporting_(true), |
154 skip_update_enroll_after_eula_(false), | 155 skip_update_enroll_after_eula_(false), |
155 login_screen_started_(false), | 156 login_screen_started_(false), |
156 user_image_screen_return_to_previous_hack_(false), | 157 user_image_screen_return_to_previous_hack_(false), |
| 158 timezone_resolved_(false), |
157 weak_factory_(this) { | 159 weak_factory_(this) { |
158 DCHECK(default_controller_ == NULL); | 160 DCHECK(default_controller_ == NULL); |
159 default_controller_ = this; | 161 default_controller_ = this; |
160 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 162 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
161 CHECK(accessibility_manager); | 163 CHECK(accessibility_manager); |
162 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 164 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
163 base::Bind(&WizardController::OnAccessibilityStatusChanged, | 165 base::Bind(&WizardController::OnAccessibilityStatusChanged, |
164 base::Unretained(this))); | 166 base::Unretained(this))); |
165 } | 167 } |
166 | 168 |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 | 995 |
994 void WizardController::OnTimezoneResolved( | 996 void WizardController::OnTimezoneResolved( |
995 scoped_ptr<TimeZoneResponseData> timezone, | 997 scoped_ptr<TimeZoneResponseData> timezone, |
996 bool server_error) { | 998 bool server_error) { |
997 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 999 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
998 DCHECK(timezone.get()); | 1000 DCHECK(timezone.get()); |
999 // To check that "this" is not destroyed try to access some member | 1001 // To check that "this" is not destroyed try to access some member |
1000 // (timezone_provider_) in this case. Expect crash here. | 1002 // (timezone_provider_) in this case. Expect crash here. |
1001 DCHECK(timezone_provider_.get()); | 1003 DCHECK(timezone_provider_.get()); |
1002 | 1004 |
| 1005 timezone_resolved_ = true; |
| 1006 base::ScopedClosureRunner inform_test(on_timezone_resolved_for_testing_); |
| 1007 |
1003 VLOG(1) << "Resolved local timezone={" << timezone->ToStringForDebug() | 1008 VLOG(1) << "Resolved local timezone={" << timezone->ToStringForDebug() |
1004 << "}."; | 1009 << "}."; |
1005 | 1010 |
1006 if (timezone->status != TimeZoneResponseData::OK) { | 1011 if (timezone->status != TimeZoneResponseData::OK) { |
1007 LOG(WARNING) << "Resolve TimeZone: failed to resolve timezone."; | 1012 LOG(WARNING) << "Resolve TimeZone: failed to resolve timezone."; |
1008 return; | 1013 return; |
1009 } | 1014 } |
1010 | 1015 |
1011 policy::BrowserPolicyConnectorChromeOS* connector = | 1016 policy::BrowserPolicyConnectorChromeOS* connector = |
1012 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1017 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 // WizardController owns TimezoneProvider, so timezone request is silently | 1064 // WizardController owns TimezoneProvider, so timezone request is silently |
1060 // cancelled on destruction. | 1065 // cancelled on destruction. |
1061 GetTimezoneProvider()->RequestTimezone( | 1066 GetTimezoneProvider()->RequestTimezone( |
1062 position, | 1067 position, |
1063 false, // sensor | 1068 false, // sensor |
1064 timeout - elapsed, | 1069 timeout - elapsed, |
1065 base::Bind(&WizardController::OnTimezoneResolved, | 1070 base::Bind(&WizardController::OnTimezoneResolved, |
1066 base::Unretained(this))); | 1071 base::Unretained(this))); |
1067 } | 1072 } |
1068 | 1073 |
| 1074 bool WizardController::SetOnTimeZoneResolvedForTesting( |
| 1075 const base::Closure& callback) { |
| 1076 if (timezone_resolved_) |
| 1077 return true; |
| 1078 |
| 1079 on_timezone_resolved_for_testing_ = callback; |
| 1080 return false; |
| 1081 } |
| 1082 |
1069 } // namespace chromeos | 1083 } // namespace chromeos |
OLD | NEW |