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/ui/webui/chromeos/login/network_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/prefs/pref_registry_simple.h" | 14 #include "base/prefs/pref_registry_simple.h" |
14 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 21 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
21 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | |
22 #include "chrome/browser/chromeos/base/locale_util.h" | 22 #include "chrome/browser/chromeos/base/locale_util.h" |
23 #include "chrome/browser/chromeos/idle_detector.h" | 23 #include "chrome/browser/chromeos/idle_detector.h" |
24 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 24 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
25 #include "chrome/browser/chromeos/login/input_events_blocker.h" | 25 #include "chrome/browser/chromeos/login/input_events_blocker.h" |
| 26 #include "chrome/browser/chromeos/login/login_display_host.h" |
26 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 27 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
27 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 28 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
28 #include "chrome/browser/chromeos/system/input_device_settings.h" | 29 #include "chrome/browser/chromeos/system/input_device_settings.h" |
29 #include "chrome/browser/chromeos/system/timezone_util.h" | 30 #include "chrome/browser/chromeos/system/timezone_util.h" |
30 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 31 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
31 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler
.h" | 32 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler
.h" |
32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
33 #include "chromeos/chromeos_switches.h" | 34 #include "chromeos/chromeos_switches.h" |
34 #include "chromeos/ime/extension_ime_util.h" | 35 #include "chromeos/ime/extension_ime_util.h" |
35 #include "chromeos/ime/input_method_manager.h" | 36 #include "chromeos/ime/input_method_manager.h" |
36 #include "grit/chromium_strings.h" | 37 #include "grit/chromium_strings.h" |
37 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/gfx/rect.h" | 40 #include "ui/gfx/rect.h" |
40 #include "ui/views/layout/fill_layout.h" | 41 #include "ui/views/layout/fill_layout.h" |
41 #include "ui/views/widget/widget.h" | 42 #include "ui/views/widget/widget.h" |
42 | 43 |
43 namespace { | 44 namespace { |
44 | 45 |
45 const char kJsScreenPath[] = "login.NetworkScreen"; | 46 const char kJsScreenPath[] = "login.NetworkScreen"; |
46 | 47 |
47 // JS API callbacks names. | 48 // JS API callbacks names. |
48 const char kJsApiNetworkOnExit[] = "networkOnExit"; | 49 const char kJsApiNetworkOnExit[] = "networkOnExit"; |
49 const char kJsApiNetworkOnLanguageChanged[] = "networkOnLanguageChanged"; | 50 const char kJsApiNetworkOnLanguageChanged[] = "networkOnLanguageChanged"; |
50 const char kJsApiNetworkOnInputMethodChanged[] = "networkOnInputMethodChanged"; | 51 const char kJsApiNetworkOnInputMethodChanged[] = "networkOnInputMethodChanged"; |
51 const char kJsApiNetworkOnTimezoneChanged[] = "networkOnTimezoneChanged"; | 52 const char kJsApiNetworkOnTimezoneChanged[] = "networkOnTimezoneChanged"; |
52 | 53 |
53 const char kUSLayout[] = "xkb:us::eng"; | 54 const char kUSLayout[] = "xkb:us::eng"; |
54 | 55 |
55 const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours. | 56 const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours. |
56 const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes. | 57 const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes. |
57 const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes. | 58 const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes. |
58 | 59 |
59 // Returns true if element was inserted. | 60 // Returns true if element was inserted. |
60 bool InsertString(const std::string& str, std::set<std::string>& to) { | 61 bool InsertString(const std::string& str, std::set<std::string>& to) { |
61 const std::pair<std::set<std::string>::iterator, bool> result = | 62 const std::pair<std::set<std::string>::iterator, bool> result = |
62 to.insert(str); | 63 to.insert(str); |
63 return result.second; | 64 return result.second; |
64 } | 65 } |
65 | 66 |
66 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { | 67 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { |
67 base::DictionaryValue* optgroup = new base::DictionaryValue; | 68 base::DictionaryValue* optgroup = new base::DictionaryValue; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 214 |
214 | 215 |
215 // static | 216 // static |
216 void NetworkScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 217 void NetworkScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
217 registry->RegisterInt64Pref(prefs::kTimeOnOobe, 0); | 218 registry->RegisterInt64Pref(prefs::kTimeOnOobe, 0); |
218 } | 219 } |
219 | 220 |
220 // NetworkScreenHandler, private: ---------------------------------------------- | 221 // NetworkScreenHandler, private: ---------------------------------------------- |
221 | 222 |
222 void NetworkScreenHandler::HandleOnExit() { | 223 void NetworkScreenHandler::HandleOnExit() { |
223 detector_.reset(); | 224 idle_detector_.reset(); |
224 ClearErrors(); | 225 ClearErrors(); |
225 if (screen_) | 226 if (screen_) |
226 screen_->OnContinuePressed(); | 227 screen_->OnContinuePressed(); |
227 } | 228 } |
228 | 229 |
229 struct NetworkScreenHandlerOnLanguageChangedCallbackData { | 230 struct NetworkScreenHandlerOnLanguageChangedCallbackData { |
230 explicit NetworkScreenHandlerOnLanguageChangedCallbackData( | 231 explicit NetworkScreenHandlerOnLanguageChangedCallbackData( |
231 base::WeakPtr<NetworkScreenHandler>& handler) | 232 base::WeakPtr<NetworkScreenHandler>& handler) |
232 : handler_(handler) {} | 233 : handler_(handler) {} |
233 | 234 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); | 293 CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); |
293 } | 294 } |
294 | 295 |
295 void NetworkScreenHandler::OnSystemTimezoneChanged() { | 296 void NetworkScreenHandler::OnSystemTimezoneChanged() { |
296 std::string current_timezone_id; | 297 std::string current_timezone_id; |
297 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); | 298 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); |
298 CallJS("setTimezone", current_timezone_id); | 299 CallJS("setTimezone", current_timezone_id); |
299 } | 300 } |
300 | 301 |
301 void NetworkScreenHandler::StartIdleDetection() { | 302 void NetworkScreenHandler::StartIdleDetection() { |
302 if (!detector_.get()) { | 303 if (!idle_detector_.get()) { |
303 detector_.reset( | 304 idle_detector_.reset( |
304 new IdleDetector(base::Closure(), | 305 new IdleDetector(base::Closure(), |
305 base::Bind(&NetworkScreenHandler::OnIdle, | 306 base::Bind(&NetworkScreenHandler::OnIdle, |
306 weak_ptr_factory_.GetWeakPtr()))); | 307 weak_ptr_factory_.GetWeakPtr()))); |
307 } | 308 } |
308 detector_->Start(derelict_idle_timeout_); | 309 idle_detector_->Start(derelict_idle_timeout_); |
309 } | 310 } |
310 | 311 |
311 void NetworkScreenHandler::StartOobeTimer() { | 312 void NetworkScreenHandler::StartOobeTimer() { |
312 oobe_timer_.Start(FROM_HERE, | 313 oobe_timer_.Start(FROM_HERE, |
313 oobe_timer_update_interval_, | 314 oobe_timer_update_interval_, |
314 this, | 315 this, |
315 &NetworkScreenHandler::OnOobeTimerUpdate); | 316 &NetworkScreenHandler::OnOobeTimerUpdate); |
316 } | 317 } |
317 | 318 |
318 void NetworkScreenHandler::OnIdle() { | 319 void NetworkScreenHandler::OnIdle() { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 timezone_option->SetString("value", timezone_id); | 548 timezone_option->SetString("value", timezone_id); |
548 timezone_option->SetString("title", timezone_name); | 549 timezone_option->SetString("title", timezone_name); |
549 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); | 550 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); |
550 timezone_list->Append(timezone_option.release()); | 551 timezone_list->Append(timezone_option.release()); |
551 } | 552 } |
552 | 553 |
553 return timezone_list.release(); | 554 return timezone_list.release(); |
554 } | 555 } |
555 | 556 |
556 } // namespace chromeos | 557 } // namespace chromeos |
OLD | NEW |