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

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

Issue 202063: Implemented the rest of loading/parsing logic for extension i18n:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_unittest.cc » ('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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 if (!source.GetString(keys::kVersion, &version_str)) { 608 if (!source.GetString(keys::kVersion, &version_str)) {
609 *error = errors::kInvalidVersion; 609 *error = errors::kInvalidVersion;
610 return false; 610 return false;
611 } 611 }
612 version_.reset(Version::GetVersionFromString(version_str)); 612 version_.reset(Version::GetVersionFromString(version_str));
613 if (!version_.get() || version_->components().size() > 4) { 613 if (!version_.get() || version_->components().size() > 4) {
614 *error = errors::kInvalidVersion; 614 *error = errors::kInvalidVersion;
615 return false; 615 return false;
616 } 616 }
617 617
618 // Initialize name. 618 // Initialize & localize name.
619 if (!source.GetString(keys::kName, &name_)) { 619 if (!source.GetString(keys::kName, &name_)) {
620 *error = errors::kInvalidName; 620 *error = errors::kInvalidName;
621 return false; 621 return false;
622 } else if (message_bundle_.get()) {
623 std::string l10n_name =
624 message_bundle_->GetL10nMessage(ExtensionMessageBundle::kExtensionName);
625 if (!l10n_name.empty())
626 name_ = l10n_name;
622 } 627 }
623 628
624 // Initialize description (if present). 629 // Initialize & localize description (if present).
625 if (source.HasKey(keys::kDescription)) { 630 if (source.HasKey(keys::kDescription)) {
626 if (!source.GetString(keys::kDescription, &description_)) { 631 if (!source.GetString(keys::kDescription, &description_)) {
627 *error = errors::kInvalidDescription; 632 *error = errors::kInvalidDescription;
628 return false; 633 return false;
634 } else if (message_bundle_.get()) {
635 std::string l10n_description = message_bundle_->GetL10nMessage(
636 ExtensionMessageBundle::kExtensionDescription);
637 if (!l10n_description.empty())
638 description_ = l10n_description;
629 } 639 }
630 } 640 }
631 641
632 // Initialize update url (if present). 642 // Initialize update url (if present).
633 if (source.HasKey(keys::kUpdateURL)) { 643 if (source.HasKey(keys::kUpdateURL)) {
634 std::string tmp; 644 std::string tmp;
635 if (!source.GetString(keys::kUpdateURL, &tmp)) { 645 if (!source.GetString(keys::kUpdateURL, &tmp)) {
636 *error = ExtensionErrorUtils::FormatErrorMessage( 646 *error = ExtensionErrorUtils::FormatErrorMessage(
637 errors::kInvalidUpdateURL, ""); 647 errors::kInvalidUpdateURL, "");
638 return false; 648 return false;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 (pattern.scheme() != chrome::kHttpsScheme)) { 989 (pattern.scheme() != chrome::kHttpsScheme)) {
980 *error = ExtensionErrorUtils::FormatErrorMessage( 990 *error = ExtensionErrorUtils::FormatErrorMessage(
981 errors::kInvalidPermissionScheme, IntToString(i)); 991 errors::kInvalidPermissionScheme, IntToString(i));
982 return false; 992 return false;
983 } 993 }
984 994
985 host_permissions_.push_back(pattern); 995 host_permissions_.push_back(pattern);
986 } 996 }
987 } 997 }
988 998
989 // Initialize default locale (if present).
990 if (source.HasKey(keys::kDefaultLocale)) {
991 std::string default_locale;
992 if (!source.GetString(keys::kDefaultLocale, &default_locale)) {
993 *error = errors::kInvalidDefaultLocale;
994 return false;
995 }
996 // Normalize underscores to hyphens.
997 std::replace(default_locale.begin(), default_locale.end(), '_', '-');
998 set_default_locale(default_locale);
999 }
1000
1001 // Chrome URL overrides (optional) 999 // Chrome URL overrides (optional)
1002 if (source.HasKey(keys::kChromeURLOverrides)) { 1000 if (source.HasKey(keys::kChromeURLOverrides)) {
1003 DictionaryValue* overrides; 1001 DictionaryValue* overrides;
1004 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) { 1002 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) {
1005 *error = errors::kInvalidChromeURLOverrides; 1003 *error = errors::kInvalidChromeURLOverrides;
1006 return false; 1004 return false;
1007 } 1005 }
1008 // Validate that the overrides are all strings 1006 // Validate that the overrides are all strings
1009 DictionaryValue::key_iterator iter = overrides->begin_keys(); 1007 DictionaryValue::key_iterator iter = overrides->begin_keys();
1010 while (iter != overrides->end_keys()) { 1008 while (iter != overrides->end_keys()) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 UserScript::PatternList::const_iterator pattern = 1115 UserScript::PatternList::const_iterator pattern =
1118 content_script->url_patterns().begin(); 1116 content_script->url_patterns().begin();
1119 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1117 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1120 if (pattern->match_subdomains() && pattern->host().empty()) 1118 if (pattern->match_subdomains() && pattern->host().empty())
1121 return true; 1119 return true;
1122 } 1120 }
1123 } 1121 }
1124 1122
1125 return false; 1123 return false;
1126 } 1124 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698