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

Unified Diff: chrome/browser/chromeos/input_method/virtual_keyboard_selector.h

Issue 7497028: Add SetUserPreference function to VirtualKeyboardSelector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/input_method/virtual_keyboard_selector.h
diff --git a/chrome/browser/chromeos/input_method/virtual_keyboard_selector.h b/chrome/browser/chromeos/input_method/virtual_keyboard_selector.h
index 72cda9123625891333000f2e7af642f00c80201e..bf6014e8a7ea3139c161209315ac6b7d849492a8 100644
--- a/chrome/browser/chromeos/input_method/virtual_keyboard_selector.h
+++ b/chrome/browser/chromeos/input_method/virtual_keyboard_selector.h
@@ -7,6 +7,7 @@
#pragma once
#include <list>
+#include <map>
#include <set>
#include <string>
@@ -32,6 +33,9 @@ class VirtualKeyboard {
// in this case.
GURL GetURLForLayout(const std::string& layout) const;
+ // Returns true if the virtual keyboard extension supports the |layout|.
+ bool IsLayoutSupported(const std::string& layout) const;
+
const GURL& url() const { return url_; }
const std::set<std::string>& supported_layouts() const {
return supported_layouts_;
@@ -62,7 +66,9 @@ class VirtualKeyboardSelector {
// Selects and returns the most suitable virtual keyboard extension for the
// |layout|. Returns NULL if no virtual keyboard extension for the layout
- // is found. If |current_|, which is the virtual keyboard extension currently
+ // is found. If a specific virtual keyboard extension for the |layout| is
+ // already set by SetUserPreference, the virtual keyboard extension is always
+ // returned. If |current_|, which is the virtual keyboard extension currently
// in use, supports the |layout|, the current one will be returned. Otherwise
// the function scans the list of |keyboards_| and then the list of
// |system_keyboards_|. The most recently added keyboards to each list take
@@ -75,16 +81,22 @@ class VirtualKeyboardSelector {
// currently using.
const VirtualKeyboard* SelectVirtualKeyboard(const std::string& layout);
- // TODO(yusukes): Add a function something like
- // void SetUserPreference(const std::string& layout,
- // const VirtualKeyboard& keyboard);
- // so that users could use a specific virtual keyboard extension for the
- // |layout|.
+ // Sets user preferences on virtual keyboard selection so that the virtual
+ // keyboard extension specified by the |url| is always selected for the
+ // |layout|. Returns false if a virtual keyboard extension whose address is
+ // |url| is not registered, or the extension specified by the |url| does not
+ // support the |layout|.
+ bool SetUserPreference(const std::string& layout, const GURL& url);
+
+ // Removes the preference for the |layout| added by SetUserPreference.
+ void RemoveUserPreference(const std::string& layout);
protected:
- // This function neither checks |current_| nor updates the variable. The
- // function is protected for testability.
- const VirtualKeyboard* SelectVirtualKeyboardInternal(
+ // Selects and returns the most suitable virtual keyboard extension for the
+ // |layout|. Unlike SelectVirtualKeyboard(), this function only scans
+ // |keyboards_| and |system_keyboards_| (in this order), and never updates
+ // |current_|. The function is protected for testability.
+ const VirtualKeyboard* SelectVirtualKeyboardWithoutPreferences(
const std::string& layout);
private:
@@ -93,6 +105,12 @@ class VirtualKeyboardSelector {
// A list of system virtual keyboard extensions.
std::list<const VirtualKeyboard*> system_keyboards_;
+ // A map from layout name to virtual keyboard extension.
+ std::map<std::string, const VirtualKeyboard*> user_preference_;
+
+ // TODO(yusukes): Support per-site preference. e.g. always use virtual
+ // keyboard ABC on https://mail.google.com/, XYZ on http://www.google.com/.
+
// The virtual keyboard currently in use.
const VirtualKeyboard* current_;

Powered by Google App Engine
This is Rietveld 408576698