Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: chrome/browser/ui/webui/gesture_config_ui.cc

Issue 10532005: Initial check-in of gesture config WebUI. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix for chrome_browser.gypi. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/gesture_config_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/gesture_config_ui.h"
6
7 #include "base/values.h"
8 #include "base/bind.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/web_ui.h"
15 #include "grit/browser_resources.h"
16 #include "grit/generated_resources.h"
17
18 /**
19 * WebUI for configuring 'gesture.*' preference values used by
20 * Chrome's gesture recognition system.
21 */
22 GestureConfigUI::GestureConfigUI(content::WebUI* web_ui)
23 : content::WebUIController(web_ui) {
24 // Set up the chrome://gesture-config source.
25 ChromeWebUIDataSource* html_source =
26 new ChromeWebUIDataSource(chrome::kChromeUIGestureConfigHost);
27
28 // Register callback handlers.
29 web_ui->RegisterMessageCallback(
30 "getPreferenceValue",
31 base::Bind(&GestureConfigUI::GetPreferenceValue,
32 base::Unretained(this)));
33 web_ui->RegisterMessageCallback(
34 "setPreferenceValue",
35 base::Bind(&GestureConfigUI::SetPreferenceValue,
36 base::Unretained(this)));
37
38 // Add required resources.
39 html_source->add_resource_path("gesture_config.css", IDR_GESTURE_CONFIG_CSS);
40 html_source->add_resource_path("gesture_config.js", IDR_GESTURE_CONFIG_JS);
41 html_source->set_default_resource(IDR_GESTURE_CONFIG_HTML);
42
43 Profile* profile = Profile::FromWebUI(web_ui);
44 ChromeURLDataManager::AddDataSource(profile, html_source);
45 }
46
47 GestureConfigUI::~GestureConfigUI() {
48 }
49
50 void GestureConfigUI::GetPreferenceValue(const base::ListValue* args) {
51 std::string pref_name;
52
53 if (!args->GetString(0, &pref_name)) return;
54
55 Profile* profile = Profile::FromWebUI(web_ui());
56 PrefService* prefs = profile->GetPrefs();
57
58 base::StringValue arg1(pref_name);
59 base::FundamentalValue arg2(prefs->GetDouble(pref_name.c_str()));
60
61 web_ui()->CallJavascriptFunction(
62 "gesture_config.getPreferenceValueResult",
63 arg1,
64 arg2);
65 }
66
67 void GestureConfigUI::SetPreferenceValue(const base::ListValue* args) {
68 std::string pref_name;
69 double value;
70
71 if (!args->GetString(0, &pref_name) || !args->GetDouble(1, &value)) return;
72
73 Profile* profile = Profile::FromWebUI(web_ui());
74 PrefService* prefs = profile->GetPrefs();
75
76 prefs->SetDouble(pref_name.c_str(), value);
77 }
78
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/gesture_config_ui.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698