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

Side by Side Diff: chrome/browser/extensions/extension_file_util.cc

Issue 332021: Move page actions over to ExtensionAction2 (Closed)
Patch Set: Review feedback Created 11 years, 1 month 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions/extension_file_util.h" 5 #include "chrome/browser/extensions/extension_file_util.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const Extension::PrivacyBlacklistInfo& blacklist = 221 const Extension::PrivacyBlacklistInfo& blacklist =
222 extension->privacy_blacklists()[i]; 222 extension->privacy_blacklists()[i];
223 if (!file_util::PathExists(blacklist.path)) { 223 if (!file_util::PathExists(blacklist.path)) {
224 *error = StringPrintf("Could not load '%s' for privacy blacklist.", 224 *error = StringPrintf("Could not load '%s' for privacy blacklist.",
225 WideToUTF8(blacklist.path.ToWStringHack()).c_str()); 225 WideToUTF8(blacklist.path.ToWStringHack()).c_str());
226 return false; 226 return false;
227 } 227 }
228 } 228 }
229 229
230 // Validate icon location for page actions. 230 // Validate icon location for page actions.
231 const ExtensionAction* page_action = extension->page_action(); 231 ExtensionAction2* page_action = extension->page_action();
232 if (page_action) { 232 if (page_action) {
233 const std::vector<std::string>& icon_paths = page_action->icon_paths(); 233 std::vector<std::string> icon_paths(*page_action->icon_paths());
234 for (std::vector<std::string>::const_iterator iter = icon_paths.begin(); 234 if (!page_action->default_icon_path().empty())
235 icon_paths.push_back(page_action->default_icon_path());
236 for (std::vector<std::string>::iterator iter = icon_paths.begin();
235 iter != icon_paths.end(); ++iter) { 237 iter != icon_paths.end(); ++iter) {
236 if (extension->GetResource(*iter).GetFilePath().empty()) { 238 if (extension->GetResource(*iter).GetFilePath().empty()) {
237 *error = StringPrintf("Could not load icon '%s' for page action.", 239 *error = StringPrintf("Could not load icon '%s' for page action.",
238 iter->c_str()); 240 iter->c_str());
239 return false; 241 return false;
240 } 242 }
241 } 243 }
242 } 244 }
243 245
244 // Validate icon location for browser actions. 246 // Validate icon location for browser actions.
247 // Note: browser actions don't use the icon_paths().
245 ExtensionAction2* browser_action = extension->browser_action(); 248 ExtensionAction2* browser_action = extension->browser_action();
246 if (browser_action) { 249 if (browser_action) {
247 std::vector<std::string>* icon_paths = browser_action->icon_paths(); 250 std::string default_icon_path = browser_action->default_icon_path();
248 for (std::vector<std::string>::iterator iter = icon_paths->begin(); 251 if (!default_icon_path.empty()) {
249 iter != icon_paths->end(); ++iter) { 252 if (extension->GetResource(default_icon_path).GetFilePath().empty()) {
250 if (extension->GetResource(*iter).GetFilePath().empty()) {
251 *error = StringPrintf("Could not load icon '%s' for browser action.", 253 *error = StringPrintf("Could not load icon '%s' for browser action.",
252 iter->c_str()); 254 default_icon_path.c_str());
253 return false; 255 return false;
254 } 256 }
255 } 257 }
256 } 258 }
257 259
258 // Check children of extension root to see if any of them start with _ and is 260 // Check children of extension root to see if any of them start with _ and is
259 // not on the reserved list. 261 // not on the reserved list.
260 if (!CheckForIllegalFilenames(extension->path(), error)) { 262 if (!CheckForIllegalFilenames(extension->path(), error)) {
261 return false; 263 return false;
262 } 264 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 "Filenames starting with \"_\" are reserved for use by the system.", 401 "Filenames starting with \"_\" are reserved for use by the system.",
400 filename.c_str()); 402 filename.c_str());
401 return false; 403 return false;
402 } 404 }
403 } 405 }
404 406
405 return true; 407 return true;
406 } 408 }
407 409
408 } // namespace extension_file_util 410 } // namespace extension_file_util
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_page_actions_module.h » ('j') | chrome/browser/gtk/location_bar_view_gtk.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698