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

Side by Side Diff: chrome/common/extensions/api/input_ime/input_components_handler.cc

Issue 14772016: Treats empty layout as expected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | « no previous file | chrome/common/extensions/extension_manifest_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/common/extensions/api/input_ime/input_components_handler.h" 5 #include "chrome/common/extensions/api/input_ime/input_components_handler.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return false; 110 return false;
111 } 111 }
112 112
113 // Get input_components[i].language. 113 // Get input_components[i].language.
114 if (!module_value->GetString(keys::kLanguage, &language_str)) { 114 if (!module_value->GetString(keys::kLanguage, &language_str)) {
115 language_str = ""; 115 language_str = "";
116 } 116 }
117 117
118 // Get input_components[i].layouts. 118 // Get input_components[i].layouts.
119 const ListValue* layouts_value = NULL; 119 const ListValue* layouts_value = NULL;
120 if (!module_value->GetList(keys::kLayouts, &layouts_value)) { 120 if (module_value->GetList(keys::kLayouts, &layouts_value)) {
121 *error = ASCIIToUTF16( 121 for (size_t j = 0; j < layouts_value->GetSize(); ++j) {
122 errors::kInvalidInputComponentLayouts); 122 std::string layout_name_str;
123 return false; 123 if (!layouts_value->GetString(j, &layout_name_str)) {
124 } 124 *error = ErrorUtils::FormatErrorMessageUTF16(
125 125 errors::kInvalidInputComponentLayoutName,
126 for (size_t j = 0; j < layouts_value->GetSize(); ++j) { 126 base::IntToString(i), base::IntToString(j));
127 std::string layout_name_str; 127 return false;
128 if (!layouts_value->GetString(j, &layout_name_str)) { 128 }
129 *error = ErrorUtils::FormatErrorMessageUTF16( 129 layouts.insert(layout_name_str);
130 errors::kInvalidInputComponentLayoutName,
131 base::IntToString(i), base::IntToString(j));
132 return false;
133 } 130 }
134 layouts.insert(layout_name_str); 131 } else {
132 layouts_value = new ListValue();
Matt Perry 2013/05/10 16:54:10 layouts_value is never used. This will leak.
Seigo Nonaka 2013/05/10 18:04:00 Yes, nice catch! On 2013/05/10 16:54:10, Matt Per
135 } 133 }
136 134
137 if (module_value->HasKey(keys::kShortcutKey)) { 135 if (module_value->HasKey(keys::kShortcutKey)) {
138 const DictionaryValue* shortcut_value = NULL; 136 const DictionaryValue* shortcut_value = NULL;
139 if (!module_value->GetDictionary(keys::kShortcutKey, 137 if (!module_value->GetDictionary(keys::kShortcutKey,
140 &shortcut_value)) { 138 &shortcut_value)) {
141 *error = ErrorUtils::FormatErrorMessageUTF16( 139 *error = ErrorUtils::FormatErrorMessageUTF16(
142 errors::kInvalidInputComponentShortcutKey, 140 errors::kInvalidInputComponentShortcutKey,
143 base::IntToString(i)); 141 base::IntToString(i));
144 return false; 142 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 181 }
184 extension->SetManifestData(keys::kInputComponents, info.release()); 182 extension->SetManifestData(keys::kInputComponents, info.release());
185 return true; 183 return true;
186 } 184 }
187 185
188 const std::vector<std::string> InputComponentsHandler::Keys() const { 186 const std::vector<std::string> InputComponentsHandler::Keys() const {
189 return SingleKey(keys::kInputComponents); 187 return SingleKey(keys::kInputComponents);
190 } 188 }
191 189
192 } // namespace extensions 190 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension_manifest_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698