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.
5 #include "chrome/browser/ui/webui/options/chromeos/pointer_handler.h"
7 #include "base/basictypes.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h"
10 #include "chrome/common/url_constants.h"
11 #include "chrome/grit/generated_resources.h"
12 #include "content/public/browser/web_ui.h"
13 #include "ui/base/l10n/l10n_util.h"
18 PointerHandler::PointerHandler()
19 : has_touchpad_(false),
23 PointerHandler::~PointerHandler() {
26 void PointerHandler::GetLocalizedValues(
27 base::DictionaryValue* localized_strings) {
28 DCHECK(localized_strings);
30 static OptionsStringResource resources[] = {
31 { "pointerOverlayTitleTouchpadOnly",
32 IDS_OPTIONS_POINTER_TOUCHPAD_OVERLAY_TITLE },
33 { "pointerOverlayTitleMouseOnly",
34 IDS_OPTIONS_POINTER_MOUSE_OVERLAY_TITLE },
35 { "pointerOverlayTitleTouchpadMouse",
36 IDS_OPTIONS_POINTER_TOUCHPAD_MOUSE_OVERLAY_TITLE },
37 { "pointerOverlaySectionTitleTouchpad",
38 IDS_OPTIONS_POINTER_OVERLAY_SECTION_TITLE_TOUCHPAD },
39 { "pointerOverlaySectionTitleMouse",
40 IDS_OPTIONS_POINTER_OVERLAY_SECTION_TITLE_MOUSE },
42 IDS_OPTIONS_SETTINGS_TAP_TO_CLICK_ENABLED_DESCRIPTION },
43 { "primaryMouseRight",
44 IDS_OPTIONS_SETTINGS_PRIMARY_MOUSE_RIGHT_DESCRIPTION },
45 { "traditionalScroll",
46 IDS_OPTIONS_SETTINGS_TRADITIONAL_SCROLL_DESCRIPTION },
49 localized_strings->SetString("naturalScroll",
50 l10n_util::GetStringFUTF16(
51 IDS_OPTIONS_SETTINGS_NATURAL_SCROLL_DESCRIPTION,
52 base::ASCIIToUTF16(chrome::kNaturalScrollHelpURL)));
54 RegisterStrings(localized_strings, resources, arraysize(resources));
58 void PointerHandler::TouchpadExists(bool exists) {
59 has_touchpad_ = exists;
60 base::FundamentalValue val(exists);
61 web_ui()->CallJavascriptFunction("PointerOverlay.showTouchpadControls", val);
65 void PointerHandler::MouseExists(bool exists) {
67 base::FundamentalValue val(exists);
68 web_ui()->CallJavascriptFunction("PointerOverlay.showMouseControls", val);
72 void PointerHandler::UpdateTitle() {
75 label = has_mouse_ ? "pointerOverlayTitleTouchpadMouse" :
76 "pointerOverlayTitleTouchpadOnly";
78 label = has_mouse_ ? "pointerOverlayTitleMouseOnly" : "";
80 base::StringValue val(label);
81 web_ui()->CallJavascriptFunction("PointerOverlay.setTitle", val);
84 } // namespace options
85 } // namespace chromeos