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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 212 |
212 | 213 |
213 // static | 214 // static |
214 void NetworkScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 215 void NetworkScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
215 registry->RegisterInt64Pref(prefs::kTimeOnOobe, 0); | 216 registry->RegisterInt64Pref(prefs::kTimeOnOobe, 0); |
216 } | 217 } |
217 | 218 |
218 // NetworkScreenHandler, private: ---------------------------------------------- | 219 // NetworkScreenHandler, private: ---------------------------------------------- |
219 | 220 |
220 void NetworkScreenHandler::HandleOnExit() { | 221 void NetworkScreenHandler::HandleOnExit() { |
221 detector_.reset(); | 222 idle_detector_.reset(); |
222 ClearErrors(); | 223 ClearErrors(); |
223 if (screen_) | 224 if (screen_) |
224 screen_->OnContinuePressed(); | 225 screen_->OnContinuePressed(); |
225 } | 226 } |
226 | 227 |
227 struct NetworkScreenHandlerOnLanguageChangedCallbackData { | 228 struct NetworkScreenHandlerOnLanguageChangedCallbackData { |
228 explicit NetworkScreenHandlerOnLanguageChangedCallbackData( | 229 explicit NetworkScreenHandlerOnLanguageChangedCallbackData( |
229 base::WeakPtr<NetworkScreenHandler>& handler) | 230 base::WeakPtr<NetworkScreenHandler>& handler) |
230 : handler_(handler) {} | 231 : handler_(handler) {} |
231 | 232 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); | 291 CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); |
291 } | 292 } |
292 | 293 |
293 void NetworkScreenHandler::OnSystemTimezoneChanged() { | 294 void NetworkScreenHandler::OnSystemTimezoneChanged() { |
294 std::string current_timezone_id; | 295 std::string current_timezone_id; |
295 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); | 296 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); |
296 CallJS("setTimezone", current_timezone_id); | 297 CallJS("setTimezone", current_timezone_id); |
297 } | 298 } |
298 | 299 |
299 void NetworkScreenHandler::StartIdleDetection() { | 300 void NetworkScreenHandler::StartIdleDetection() { |
300 if (!detector_.get()) { | 301 if (!idle_detector_.get()) { |
301 detector_.reset( | 302 idle_detector_.reset( |
302 new IdleDetector(base::Closure(), | 303 new IdleDetector(base::Closure(), |
303 base::Bind(&NetworkScreenHandler::OnIdle, | 304 base::Bind(&NetworkScreenHandler::OnIdle, |
304 weak_ptr_factory_.GetWeakPtr()))); | 305 weak_ptr_factory_.GetWeakPtr()))); |
305 } | 306 } |
306 detector_->Start(derelict_idle_timeout_); | 307 idle_detector_->Start(derelict_idle_timeout_); |
307 } | 308 } |
308 | 309 |
309 void NetworkScreenHandler::StartOobeTimer() { | 310 void NetworkScreenHandler::StartOobeTimer() { |
310 oobe_timer_.Start(FROM_HERE, | 311 oobe_timer_.Start(FROM_HERE, |
311 oobe_timer_update_interval_, | 312 oobe_timer_update_interval_, |
312 this, | 313 this, |
313 &NetworkScreenHandler::OnOobeTimerUpdate); | 314 &NetworkScreenHandler::OnOobeTimerUpdate); |
314 } | 315 } |
315 | 316 |
316 void NetworkScreenHandler::OnIdle() { | 317 void NetworkScreenHandler::OnIdle() { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 timezone_option->SetString("value", timezone_id); | 546 timezone_option->SetString("value", timezone_id); |
546 timezone_option->SetString("title", timezone_name); | 547 timezone_option->SetString("title", timezone_name); |
547 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); | 548 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); |
548 timezone_list->Append(timezone_option.release()); | 549 timezone_list->Append(timezone_option.release()); |
549 } | 550 } |
550 | 551 |
551 return timezone_list.release(); | 552 return timezone_list.release(); |
552 } | 553 } |
553 | 554 |
554 } // namespace chromeos | 555 } // namespace chromeos |
OLD | NEW |