OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_VIRTUAL_KEYBOARD_MANAGER_HANDL
ER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_VIRTUAL_KEYBOARD_MANAGER_HANDL
ER_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 #include <set> | |
11 #include <string> | |
12 | |
13 #include "chrome/browser/ui/webui/options2/options_ui.h" | |
14 #include "googleurl/src/gurl.h" | |
15 | |
16 namespace base { | |
17 class DictionaryValue; | |
18 class ListValue; | |
19 } // namespace base | |
20 | |
21 namespace chromeos { | |
22 | |
23 namespace input_method { | |
24 class VirtualKeyboard; | |
25 } // namespace input_method; | |
26 | |
27 // A class which provides information to virtual_keyboard.js. | |
28 class VirtualKeyboardManagerHandler : public OptionsPage2UIHandler { | |
29 public: | |
30 VirtualKeyboardManagerHandler(); | |
31 virtual ~VirtualKeyboardManagerHandler(); | |
32 | |
33 // OptionsPage2UIHandler implementation. | |
34 virtual void GetLocalizedValues( | |
35 base::DictionaryValue* localized_strings) OVERRIDE; | |
36 virtual void Initialize() OVERRIDE; | |
37 virtual void RegisterMessages() OVERRIDE; | |
38 | |
39 protected: | |
40 typedef std::multimap< | |
41 std::string, const input_method::VirtualKeyboard*> LayoutToKeyboard; | |
42 typedef std::map<GURL, const input_method::VirtualKeyboard*> UrlToKeyboard; | |
43 | |
44 // Returns true if |layout_to_keyboard| contains |layout| as a key, and the | |
45 // value for |layout| contains |url|. This function is protected for | |
46 // testability. | |
47 static bool ValidateUrl(const UrlToKeyboard& url_to_keyboard, | |
48 const std::string& layout, | |
49 const std::string& url); | |
50 | |
51 // Builds a list from |layout_to_keyboard| and |virtual_keyboard_user_pref|. | |
52 // See virtual_keyboard_list.js for an example of the format the list should | |
53 // take. This function is protected for testability. | |
54 static base::ListValue* CreateVirtualKeyboardList( | |
55 const LayoutToKeyboard& layout_to_keyboard, | |
56 const UrlToKeyboard& url_to_keyboard, | |
57 const base::DictionaryValue* virtual_keyboard_user_pref); | |
58 | |
59 private: | |
60 // Reads user pref and create a list using CreateVirtualKeyboardList(). | |
61 base::ListValue* GetVirtualKeyboardList(); | |
62 | |
63 // Handles chrome.send("updateVirtualKeyboardList") JS call. | |
64 // TODO(yusukes): This function should also be called when user pref is | |
65 // updated by chrome://settings page in other tab. | |
66 void UpdateVirtualKeyboardList(const base::ListValue* args); | |
67 | |
68 // Handles chrome.send("setVirtualKeyboardPreference") JS call. | |
69 void SetVirtualKeyboardPreference(const base::ListValue* args); | |
70 // Handles chrome.send("clearVirtualKeyboardPreference") JS call. | |
71 void ClearVirtualKeyboardPreference(const base::ListValue* args); | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardManagerHandler); | |
74 }; | |
75 | |
76 } // namespace chromeos | |
77 | |
78 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_VIRTUAL_KEYBOARD_MANAGER_HA
NDLER_H_ | |
OLD | NEW |