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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 307048: Save a little work when fetching the default title by only checking the name... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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_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) 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/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (page_action->HasKey(keys::kPageActionDefaultIcon)) { 333 if (page_action->HasKey(keys::kPageActionDefaultIcon)) {
334 if (!page_action->GetString(keys::kPageActionDefaultIcon, &default_icon) || 334 if (!page_action->GetString(keys::kPageActionDefaultIcon, &default_icon) ||
335 default_icon.empty()) { 335 default_icon.empty()) {
336 *error = errors::kInvalidPageActionIconPath; 336 *error = errors::kInvalidPageActionIconPath;
337 return NULL; 337 return NULL;
338 } 338 }
339 // TODO(EXTENSIONS_DEPRECATED): one icon. 339 // TODO(EXTENSIONS_DEPRECATED): one icon.
340 result->AddIconPath(default_icon); 340 result->AddIconPath(default_icon);
341 } 341 }
342 342
343 // Read the page action |default_title|. 343 // Read the page action title from |default_title| if present, |name| if not
344 // (both optional).
344 std::string title; 345 std::string title;
345 if (!page_action->GetString(keys::kName, &title) && 346 if (page_action->HasKey(keys::kPageActionDefaultTitle)) {
346 !page_action->GetString(keys::kPageActionDefaultTitle, &title)) { 347 if (!page_action->GetString(keys::kPageActionDefaultTitle, &title)) {
347 *error = errors::kInvalidPageActionDefaultTitle; 348 *error = errors::kInvalidPageActionDefaultTitle;
348 return NULL; 349 return NULL;
350 }
351 } else if (page_action->HasKey(keys::kName)) {
352 if (!page_action->GetString(keys::kName, &title)) {
353 *error = errors::kInvalidPageActionName;
354 return NULL;
355 }
349 } 356 }
350 result->set_title(title); 357 result->set_title(title);
351 358
352 // Read the action's |popup| (optional). 359 // Read the action's |popup| (optional).
353 DictionaryValue* popup = NULL; 360 DictionaryValue* popup = NULL;
354 std::string url_str; 361 std::string url_str;
355 if (page_action->HasKey(keys::kPageActionPopup) && 362 if (page_action->HasKey(keys::kPageActionPopup) &&
356 !page_action->GetDictionary(keys::kPageActionPopup, &popup) && 363 !page_action->GetDictionary(keys::kPageActionPopup, &popup) &&
357 !page_action->GetString(keys::kPageActionPopup, &url_str)) { 364 !page_action->GetString(keys::kPageActionPopup, &url_str)) {
358 *error = errors::kInvalidPageActionPopup; 365 *error = errors::kInvalidPageActionPopup;
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 UserScript::PatternList::const_iterator pattern = 1181 UserScript::PatternList::const_iterator pattern =
1175 content_script->url_patterns().begin(); 1182 content_script->url_patterns().begin();
1176 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1183 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1177 if (pattern->match_subdomains() && pattern->host().empty()) 1184 if (pattern->match_subdomains() && pattern->host().empty())
1178 return true; 1185 return true;
1179 } 1186 }
1180 } 1187 }
1181 1188
1182 return false; 1189 return false;
1183 } 1190 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698