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

Side by Side Diff: chrome/browser/chromeos/input_method/virtual_keyboard_selector.cc

Issue 7508014: Add member variables to VirtualKeyboardSelector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rewrote CheckUrls Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" 5 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 9
10 namespace { 10 namespace {
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 return NULL; 28 return NULL;
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 namespace chromeos { 33 namespace chromeos {
34 namespace input_method { 34 namespace input_method {
35 35
36 VirtualKeyboard::VirtualKeyboard(const GURL& url, 36 VirtualKeyboard::VirtualKeyboard(const GURL& url,
37 const std::string& name,
37 const std::set<std::string>& supported_layouts, 38 const std::set<std::string>& supported_layouts,
38 bool is_system) 39 bool is_system)
39 : url_(url), 40 : url_(url),
41 name_(name),
40 supported_layouts_(supported_layouts), 42 supported_layouts_(supported_layouts),
41 is_system_(is_system) { 43 is_system_(is_system) {
42 } 44 }
43 45
44 VirtualKeyboard::~VirtualKeyboard() { 46 VirtualKeyboard::~VirtualKeyboard() {
45 } 47 }
46 48
47 GURL VirtualKeyboard::GetURLForLayout(const std::string& layout) const { 49 GURL VirtualKeyboard::GetURLForLayout(const std::string& layout) const {
48 if (layout.empty()) { 50 if (layout.empty()) {
49 return url_; 51 return url_;
(...skipping 14 matching lines...) Expand all
64 : current_(NULL) { 66 : current_(NULL) {
65 } 67 }
66 68
67 VirtualKeyboardSelector::~VirtualKeyboardSelector() { 69 VirtualKeyboardSelector::~VirtualKeyboardSelector() {
68 STLDeleteElements(&keyboards_); 70 STLDeleteElements(&keyboards_);
69 STLDeleteElements(&system_keyboards_); 71 STLDeleteElements(&system_keyboards_);
70 } 72 }
71 73
72 bool VirtualKeyboardSelector::AddVirtualKeyboard( 74 bool VirtualKeyboardSelector::AddVirtualKeyboard(
73 const GURL& url, 75 const GURL& url,
76 const std::string& name,
74 const std::set<std::string>& supported_layouts, 77 const std::set<std::string>& supported_layouts,
75 bool is_system) { 78 bool is_system) {
76 if (url_to_keyboard_.count(url)) 79 if (url_to_keyboard_.count(url))
77 return false; // the URL is already in use. 80 return false; // the URL is already in use.
78 81
79 const VirtualKeyboard* new_keyboard = new VirtualKeyboard(url, 82 const VirtualKeyboard* new_keyboard = new VirtualKeyboard(url,
83 name,
80 supported_layouts, 84 supported_layouts,
81 is_system); 85 is_system);
82 if (is_system) { 86 if (is_system) {
83 system_keyboards_.push_front(new_keyboard); 87 system_keyboards_.push_front(new_keyboard);
84 } else { 88 } else {
85 keyboards_.push_front(new_keyboard); 89 keyboards_.push_front(new_keyboard);
86 } 90 }
87 91
88 url_to_keyboard_.insert(std::make_pair(url, new_keyboard)); 92 url_to_keyboard_.insert(std::make_pair(url, new_keyboard));
93 std::set<std::string>::const_iterator layout_iter;
94 for (layout_iter = new_keyboard->supported_layouts().begin();
95 layout_iter != new_keyboard->supported_layouts().end();
96 ++layout_iter) {
97 const std::string& layout = *layout_iter;
98 layout_to_keyboard_.insert(std::make_pair(layout, new_keyboard));
99 }
100
89 return true; 101 return true;
90 } 102 }
91 103
92 const VirtualKeyboard* VirtualKeyboardSelector::SelectVirtualKeyboard( 104 const VirtualKeyboard* VirtualKeyboardSelector::SelectVirtualKeyboard(
93 const std::string& layout) { 105 const std::string& layout) {
94 if (layout.empty()) { 106 if (layout.empty()) {
95 LOG(ERROR) << "No layout is specified"; 107 LOG(ERROR) << "No layout is specified";
96 return NULL; 108 return NULL;
97 } 109 }
98 110
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const std::string& layout) { 166 const std::string& layout) {
155 const VirtualKeyboard* keyboard = 167 const VirtualKeyboard* keyboard =
156 SelectVirtualKeyboardInternal(keyboards_, layout); 168 SelectVirtualKeyboardInternal(keyboards_, layout);
157 if (!keyboard) 169 if (!keyboard)
158 keyboard = SelectVirtualKeyboardInternal(system_keyboards_, layout); 170 keyboard = SelectVirtualKeyboardInternal(system_keyboards_, layout);
159 return keyboard; 171 return keyboard;
160 } 172 }
161 173
162 } // namespace input_method 174 } // namespace input_method
163 } // namespace chromeos 175 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698