OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/hid_detection_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/metrics/user_metrics.h" | |
10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 14 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
14 #include "device/bluetooth/bluetooth_adapter_factory.h" | 15 #include "device/bluetooth/bluetooth_adapter_factory.h" |
15 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 | 19 |
19 namespace { | 20 namespace { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 | 56 |
56 namespace chromeos { | 57 namespace chromeos { |
57 | 58 |
58 HIDDetectionScreenHandler::HIDDetectionScreenHandler() | 59 HIDDetectionScreenHandler::HIDDetectionScreenHandler() |
59 : BaseScreenHandler(kJsScreenPath), | 60 : BaseScreenHandler(kJsScreenPath), |
60 delegate_(NULL), | 61 delegate_(NULL), |
61 show_on_init_(false), | 62 show_on_init_(false), |
62 mouse_is_pairing_(false), | 63 mouse_is_pairing_(false), |
63 keyboard_is_pairing_(false), | 64 keyboard_is_pairing_(false), |
64 switch_on_adapter_when_ready_(false), | 65 switch_on_adapter_when_ready_(false), |
65 skip_screen_if_devices_present_(true), | 66 first_time_screen_show_(true), |
66 weak_ptr_factory_(this) { | 67 weak_ptr_factory_(this) { |
67 } | 68 } |
68 | 69 |
69 HIDDetectionScreenHandler::~HIDDetectionScreenHandler() { | 70 HIDDetectionScreenHandler::~HIDDetectionScreenHandler() { |
70 if (adapter_.get()) | 71 if (adapter_.get()) |
71 adapter_->RemoveObserver(this); | 72 adapter_->RemoveObserver(this); |
72 input_service_proxy_.RemoveObserver(this); | 73 input_service_proxy_.RemoveObserver(this); |
73 if (delegate_) | 74 if (delegate_) |
74 delegate_->OnActorDestroyed(this); | 75 delegate_->OnActorDestroyed(this); |
75 } | 76 } |
(...skipping 12 matching lines...) Expand all Loading... | |
88 void HIDDetectionScreenHandler::FindDevicesError() { | 89 void HIDDetectionScreenHandler::FindDevicesError() { |
89 VLOG(1) << "Failed to start Bluetooth discovery."; | 90 VLOG(1) << "Failed to start Bluetooth discovery."; |
90 } | 91 } |
91 | 92 |
92 void HIDDetectionScreenHandler::Show() { | 93 void HIDDetectionScreenHandler::Show() { |
93 if (!page_is_ready()) { | 94 if (!page_is_ready()) { |
94 show_on_init_ = true; | 95 show_on_init_ = true; |
95 return; | 96 return; |
96 } | 97 } |
97 input_service_proxy_.AddObserver(this); | 98 input_service_proxy_.AddObserver(this); |
98 skip_screen_if_devices_present_ = true; | 99 first_time_screen_show_ = true; |
99 UpdateDevices(); | 100 UpdateDevices(); |
100 ShowScreen(OobeUI::kScreenHIDDetection, NULL); | 101 ShowScreen(OobeUI::kScreenHIDDetection, NULL); |
101 } | 102 } |
102 | 103 |
103 void HIDDetectionScreenHandler::Hide() { | 104 void HIDDetectionScreenHandler::Hide() { |
104 if (adapter_.get()) | 105 if (adapter_.get()) |
105 adapter_->RemoveObserver(this); | 106 adapter_->RemoveObserver(this); |
106 input_service_proxy_.RemoveObserver(this); | 107 input_service_proxy_.RemoveObserver(this); |
107 } | 108 } |
108 | 109 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 pointing_device_connect_type_ = it->type; | 363 pointing_device_connect_type_ = it->type; |
363 SendPointingDeviceNotification(); | 364 SendPointingDeviceNotification(); |
364 } | 365 } |
365 if (keyboard_device_id_.empty() && it->is_keyboard) { | 366 if (keyboard_device_id_.empty() && it->is_keyboard) { |
366 keyboard_device_id_ = it->id; | 367 keyboard_device_id_ = it->id; |
367 keyboard_device_name_ = it->name; | 368 keyboard_device_name_ = it->name; |
368 keyboard_device_connect_type_ = it->type; | 369 keyboard_device_connect_type_ = it->type; |
369 SendKeyboardDeviceNotification(NULL); | 370 SendKeyboardDeviceNotification(NULL); |
370 } | 371 } |
371 } | 372 } |
372 // Skip screen if both devices are present and skip was requested. | 373 |
373 if (!pointing_device_id_.empty() && | 374 if (first_time_screen_show_) { |
374 !keyboard_device_id_.empty() && | 375 // Skip screen if both devices are present and it's first show. |
375 skip_screen_if_devices_present_) { | 376 if (!pointing_device_id_.empty() && !keyboard_device_id_.empty()) { |
376 HandleOnContinue(); | 377 HandleOnContinue(); |
378 } else { | |
379 base::RecordAction( | |
380 base::UserMetricsAction("OOBE.HIDDetectionDialogShown")); | |
ygorshenin1
2014/05/08 11:50:08
Consider to use HISTOGRAM_BOOLEAN.
merkulova
2014/05/12 10:22:59
Done.
| |
381 } | |
377 } | 382 } |
378 // Skip requested only once on dialog show. | 383 |
379 skip_screen_if_devices_present_ = false; | 384 first_time_screen_show_ = false; |
380 if ((pointing_device_id_.empty() || keyboard_device_id_.empty()) && | 385 if ((pointing_device_id_.empty() || keyboard_device_id_.empty()) && |
381 adapter_) { | 386 adapter_) { |
382 if (!adapter_->IsPresent()) { | 387 if (!adapter_->IsPresent()) { |
383 // Switch on BT adapter later when it's available. | 388 // Switch on BT adapter later when it's available. |
384 switch_on_adapter_when_ready_ = true; | 389 switch_on_adapter_when_ready_ = true; |
385 } else if (!adapter_->IsPowered()) { | 390 } else if (!adapter_->IsPowered()) { |
386 adapter_->SetPowered( | 391 adapter_->SetPowered( |
387 true, | 392 true, |
388 base::Bind(&HIDDetectionScreenHandler::StartBTDiscoverySession, | 393 base::Bind(&HIDDetectionScreenHandler::StartBTDiscoverySession, |
389 weak_ptr_factory_.GetWeakPtr()), | 394 weak_ptr_factory_.GetWeakPtr()), |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 l10n_util::GetStringFUTF16( | 494 l10n_util::GetStringFUTF16( |
490 IDS_HID_DETECTION_PAIRED_BLUETOOTH_KEYBOARD, | 495 IDS_HID_DETECTION_PAIRED_BLUETOOTH_KEYBOARD, |
491 base::UTF8ToUTF16(keyboard_device_name_))); | 496 base::UTF8ToUTF16(keyboard_device_name_))); |
492 } else { | 497 } else { |
493 state_info.SetString("state", kUSBConnectedState); | 498 state_info.SetString("state", kUSBConnectedState); |
494 } | 499 } |
495 CallJS("setKeyboardDeviceState", state_info); | 500 CallJS("setKeyboardDeviceState", state_info); |
496 } | 501 } |
497 | 502 |
498 } // namespace chromeos | 503 } // namespace chromeos |
OLD | NEW |