OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/options2/chromeos/pointer_handler.h" | |
6 | |
7 #include "base/basictypes.h" | |
8 #include "base/utf_string_conversions.h" | |
9 #include "base/values.h" | |
10 #include "chrome/common/url_constants.h" | |
11 #include "content/public/browser/web_ui.h" | |
12 #include "grit/generated_resources.h" | |
13 #include "ui/base/l10n/l10n_util.h" | |
14 | |
15 namespace chromeos { | |
16 namespace options { | |
17 | |
18 PointerHandler::PointerHandler() | |
19 : has_touchpad_(false), | |
20 has_mouse_(false) { | |
21 } | |
22 | |
23 PointerHandler::~PointerHandler() { | |
24 } | |
25 | |
26 void PointerHandler::GetLocalizedValues(DictionaryValue* localized_strings) { | |
27 DCHECK(localized_strings); | |
28 | |
29 static OptionsStringResource resources[] = { | |
30 { "pointerOverlayTitleTouchpadOnly", | |
31 IDS_OPTIONS_POINTER_TOUCHPAD_OVERLAY_TITLE }, | |
32 { "pointerOverlayTitleMouseOnly", | |
33 IDS_OPTIONS_POINTER_MOUSE_OVERLAY_TITLE }, | |
34 { "pointerOverlayTitleTouchpadMouse", | |
35 IDS_OPTIONS_POINTER_TOUCHPAD_MOUSE_OVERLAY_TITLE }, | |
36 { "pointerOverlaySectionTitleTouchpad", | |
37 IDS_OPTIONS_POINTER_OVERLAY_SECTION_TITLE_TOUCHPAD }, | |
38 { "pointerOverlaySectionTitleMouse", | |
39 IDS_OPTIONS_POINTER_OVERLAY_SECTION_TITLE_MOUSE }, | |
40 { "enableTapToClick", | |
41 IDS_OPTIONS_SETTINGS_TAP_TO_CLICK_ENABLED_DESCRIPTION }, | |
42 { "primaryMouseRight", | |
43 IDS_OPTIONS_SETTINGS_PRIMARY_MOUSE_RIGHT_DESCRIPTION }, | |
44 }; | |
45 | |
46 localized_strings->SetString("naturalScroll", | |
47 l10n_util::GetStringFUTF16( | |
48 IDS_OPTIONS_SETTINGS_NATURAL_SCROLL_DESCRIPTION, | |
49 ASCIIToUTF16(chrome::kNaturalScrollHelpURL))); | |
50 | |
51 RegisterStrings(localized_strings, resources, arraysize(resources)); | |
52 } | |
53 | |
54 | |
55 void PointerHandler::TouchpadExists(bool exists) { | |
56 has_touchpad_ = exists; | |
57 base::FundamentalValue val(exists); | |
58 web_ui()->CallJavascriptFunction("PointerOverlay.showTouchpadControls", val); | |
59 UpdateTitle(); | |
60 } | |
61 | |
62 void PointerHandler::MouseExists(bool exists) { | |
63 has_mouse_ = exists; | |
64 base::FundamentalValue val(exists); | |
65 web_ui()->CallJavascriptFunction("PointerOverlay.showMouseControls", val); | |
66 UpdateTitle(); | |
67 } | |
68 | |
69 void PointerHandler::UpdateTitle() { | |
70 std::string label; | |
71 if (has_touchpad_) { | |
72 label = has_mouse_ ? "pointerOverlayTitleTouchpadMouse" : | |
73 "pointerOverlayTitleTouchpadOnly"; | |
74 } else { | |
75 label = has_mouse_ ? "pointerOverlayTitleMouseOnly" : ""; | |
76 } | |
77 base::StringValue val(label); | |
78 web_ui()->CallJavascriptFunction("PointerOverlay.setTitle", val); | |
79 } | |
80 | |
81 } // namespace options | |
82 } // namespace chromeos | |
OLD | NEW |