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

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

Issue 434026: disable extension toolstrips by default, adding (Closed)
Patch Set: fix a failing test 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | 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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 // Initialize options page url (optional). 911 // Initialize options page url (optional).
912 if (source.HasKey(keys::kOptionsPage)) { 912 if (source.HasKey(keys::kOptionsPage)) {
913 std::string options_str; 913 std::string options_str;
914 if (!source.GetString(keys::kOptionsPage, &options_str)) { 914 if (!source.GetString(keys::kOptionsPage, &options_str)) {
915 *error = errors::kInvalidOptionsPage; 915 *error = errors::kInvalidOptionsPage;
916 return false; 916 return false;
917 } 917 }
918 options_url_ = GetResourceURL(options_str); 918 options_url_ = GetResourceURL(options_str);
919 } 919 }
920 920
921 // Initialize toolstrips (optional). 921 // Initialize toolstrips (deprecated and optional).
922 if (source.HasKey(keys::kToolstrips)) { 922 // TODO(erikkay) remove this altogether.
923 if (CommandLine::ForCurrentProcess()->HasSwitch(
924 switches::kEnableExtensionToolstrips) &&
925 source.HasKey(keys::kToolstrips)) {
923 ListValue* list_value; 926 ListValue* list_value;
924 if (!source.GetList(keys::kToolstrips, &list_value)) { 927 if (!source.GetList(keys::kToolstrips, &list_value)) {
925 *error = errors::kInvalidToolstrips; 928 *error = errors::kInvalidToolstrips;
926 return false; 929 return false;
927 } 930 }
928 931
929 for (size_t i = 0; i < list_value->GetSize(); ++i) { 932 for (size_t i = 0; i < list_value->GetSize(); ++i) {
930 ToolstripInfo toolstrip; 933 ToolstripInfo toolstrip;
931 DictionaryValue* toolstrip_value; 934 DictionaryValue* toolstrip_value;
932 std::string toolstrip_path; 935 std::string toolstrip_path;
933 if (list_value->GetString(i, &toolstrip_path)) { 936 if (list_value->GetString(i, &toolstrip_path)) {
934 // Support a simple URL value for backwards compatibility. 937 // Support a simple URL value for backwards compatibility.
935 // TODO(erikkay) Perhaps deprecate this in the future.
936 toolstrip.toolstrip = GetResourceURL(toolstrip_path); 938 toolstrip.toolstrip = GetResourceURL(toolstrip_path);
937 } else if (list_value->GetDictionary(i, &toolstrip_value)) { 939 } else if (list_value->GetDictionary(i, &toolstrip_value)) {
938 if (!toolstrip_value->GetString(keys::kToolstripPath, 940 if (!toolstrip_value->GetString(keys::kToolstripPath,
939 &toolstrip_path)) { 941 &toolstrip_path)) {
940 *error = ExtensionErrorUtils::FormatErrorMessage( 942 *error = ExtensionErrorUtils::FormatErrorMessage(
941 errors::kInvalidToolstrip, IntToString(i)); 943 errors::kInvalidToolstrip, IntToString(i));
942 return false; 944 return false;
943 } 945 }
944 toolstrip.toolstrip = GetResourceURL(toolstrip_path); 946 toolstrip.toolstrip = GetResourceURL(toolstrip_path);
945 if (toolstrip_value->HasKey(keys::kToolstripMolePath)) { 947 if (toolstrip_value->HasKey(keys::kToolstripMolePath)) {
946 std::string mole_path; 948 std::string mole_path;
947 if (!toolstrip_value->GetString(keys::kToolstripMolePath, 949 if (!toolstrip_value->GetString(keys::kToolstripMolePath,
948 &mole_path)) { 950 &mole_path)) {
949 *error = ExtensionErrorUtils::FormatErrorMessage( 951 *error = ExtensionErrorUtils::FormatErrorMessage(
950 errors::kInvalidToolstrip, IntToString(i)); 952 errors::kInvalidToolstrip, IntToString(i));
951 return false; 953 return false;
952 } 954 }
953 // TODO(erikkay) is there a better way to get this dynamically
954 // from the content itself?
955 int height; 955 int height;
956 if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight, 956 if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight,
957 &height) || (height < 0)) { 957 &height) || (height < 0)) {
958 *error = ExtensionErrorUtils::FormatErrorMessage( 958 *error = ExtensionErrorUtils::FormatErrorMessage(
959 errors::kInvalidToolstrip, IntToString(i)); 959 errors::kInvalidToolstrip, IntToString(i));
960 return false; 960 return false;
961 } 961 }
962 toolstrip.mole = GetResourceURL(mole_path); 962 toolstrip.mole = GetResourceURL(mole_path);
963 toolstrip.mole_height = height; 963 toolstrip.mole_height = height;
964 } 964 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 UserScript::PatternList::const_iterator pattern = 1250 UserScript::PatternList::const_iterator pattern =
1251 content_script->url_patterns().begin(); 1251 content_script->url_patterns().begin();
1252 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1252 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1253 if (pattern->match_subdomains() && pattern->host().empty()) 1253 if (pattern->match_subdomains() && pattern->host().empty())
1254 return true; 1254 return true;
1255 } 1255 }
1256 } 1256 }
1257 1257
1258 return false; 1258 return false;
1259 } 1259 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698