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

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

Issue 13459008: Support options page handling into ComponentExtensionManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit: remove unused variable. Created 7 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/component_extension_ime_manager_i mpl.h" 5 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i mpl.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/extensions/component_loader.h" 9 #include "chrome/browser/extensions/component_loader.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_file_util.h" 15 #include "chrome/common/extensions/extension_file_util.h"
15 #include "chrome/common/extensions/extension_l10n_util.h" 16 #include "chrome/common/extensions/extension_l10n_util.h"
16 #include "chrome/common/extensions/extension_manifest_constants.h" 17 #include "chrome/common/extensions/extension_manifest_constants.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 namespace { 22 namespace {
22 23
23 struct WhitelistedComponentExtensionIME { 24 struct WhitelistedComponentExtensionIME {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (layouts->GetSize() > 0) { 146 if (layouts->GetSize() > 0) {
146 if (!layouts->GetString(0, &out->layout)) 147 if (!layouts->GetString(0, &out->layout))
147 return false; 148 return false;
148 } 149 }
149 return true; 150 return true;
150 } 151 }
151 152
152 // static 153 // static
153 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo( 154 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo(
154 const DictionaryValue& manifest, 155 const DictionaryValue& manifest,
156 const std::string& extension_id,
155 ComponentExtensionIME* out) { 157 ComponentExtensionIME* out) {
156 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
157 if (!manifest.GetString(extension_manifest_keys::kDescription, 159 if (!manifest.GetString(extension_manifest_keys::kDescription,
158 &out->description)) 160 &out->description))
159 return false; 161 return false;
160 // TODO(nona): option page handling. 162 std::string url_string;
163 if (!manifest.GetString(extension_manifest_keys::kOptionsPage, &url_string))
164 return true; // It's okay to return true on no option page case.
165
166 GURL gurl = extensions::Extension::GetResourceURL(
satorux1 2013/04/15 04:16:08 gurl -> url
Seigo Nonaka 2013/04/15 04:25:53 Done.
167 extensions::Extension::GetBaseURLFromExtensionId(extension_id),
168 url_string);
169 if (!gurl.is_valid())
170 return false;
171 out->options_page_url = gurl.spec();
161 return true; 172 return true;
162 } 173 }
163 174
164 // static 175 // static
165 void ComponentExtensionIMEManagerImpl::ReadComponentExtensionsInfo( 176 void ComponentExtensionIMEManagerImpl::ReadComponentExtensionsInfo(
166 std::vector<ComponentExtensionIME>* out_imes) { 177 std::vector<ComponentExtensionIME>* out_imes) {
167 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 178 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
168 DCHECK(out_imes); 179 DCHECK(out_imes);
169 for (size_t i = 0; i < arraysize(whitelisted_component_extension); ++i) { 180 for (size_t i = 0; i < arraysize(whitelisted_component_extension); ++i) {
170 ComponentExtensionIME component_ime; 181 ComponentExtensionIME component_ime;
171 component_ime.path = base::FilePath( 182 component_ime.path = base::FilePath(
172 whitelisted_component_extension[i].path); 183 whitelisted_component_extension[i].path);
173 184
174 const base::FilePath manifest_path = 185 const base::FilePath manifest_path =
175 component_ime.path.Append("manifest.json"); 186 component_ime.path.Append("manifest.json");
176 187
177 if (!file_util::PathExists(component_ime.path) || 188 if (!file_util::PathExists(component_ime.path) ||
178 !file_util::PathExists(manifest_path)) 189 !file_util::PathExists(manifest_path))
179 continue; 190 continue;
180 191
181 if (!file_util::ReadFileToString(manifest_path, &component_ime.manifest)) 192 if (!file_util::ReadFileToString(manifest_path, &component_ime.manifest))
182 continue; 193 continue;
183 194
184 scoped_ptr<DictionaryValue> manifest = GetManifest(component_ime.path); 195 scoped_ptr<DictionaryValue> manifest = GetManifest(component_ime.path);
185 if (!manifest.get()) 196 if (!manifest.get())
186 continue; 197 continue;
187 198
188 if (!ReadExtensionInfo(*manifest.get(), &component_ime)) 199 if (!ReadExtensionInfo(*manifest.get(),
200 whitelisted_component_extension[i].id,
201 &component_ime))
189 continue; 202 continue;
190 component_ime.id = whitelisted_component_extension[i].id; 203 component_ime.id = whitelisted_component_extension[i].id;
191 204
192 const ListValue* component_list; 205 const ListValue* component_list;
193 if (!manifest->GetList(extension_manifest_keys::kInputComponents, 206 if (!manifest->GetList(extension_manifest_keys::kInputComponents,
194 &component_list)) 207 &component_list))
195 continue; 208 continue;
196 209
197 for (size_t i = 0; i < component_list->GetSize(); ++i) { 210 for (size_t i = 0; i < component_list->GetSize(); ++i) {
198 const DictionaryValue* dictionary; 211 const DictionaryValue* dictionary;
(...skipping 12 matching lines...) Expand all
211 std::vector<ComponentExtensionIME>* result, 224 std::vector<ComponentExtensionIME>* result,
212 const base::Closure& callback) { 225 const base::Closure& callback) {
213 DCHECK(thread_checker_.CalledOnValidThread()); 226 DCHECK(thread_checker_.CalledOnValidThread());
214 DCHECK(result); 227 DCHECK(result);
215 component_extension_list_ = *result; 228 component_extension_list_ = *result;
216 is_initialized_ = true; 229 is_initialized_ = true;
217 callback.Run(); 230 callback.Run();
218 } 231 }
219 232
220 } // namespace chromeos 233 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698