| OLD | NEW |
| 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/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 for (size_t i = 0; i < id->size(); ++i) | 57 for (size_t i = 0; i < id->size(); ++i) |
| 58 (*id)[i] = HexStringToInt(id->substr(i, 1)) + 'a'; | 58 (*id)[i] = HexStringToInt(id->substr(i, 1)) + 'a'; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Returns true if the given string is an API permission (see kPermissionNames). | 61 // Returns true if the given string is an API permission (see kPermissionNames). |
| 62 static bool IsAPIPermission(const std::string& str) { | 62 static bool IsAPIPermission(const std::string& str) { |
| 63 for (size_t i = 0; i < Extension::kNumPermissions; ++i) { | 63 for (size_t i = 0; i < Extension::kNumPermissions; ++i) { |
| 64 if (str == Extension::kPermissionNames[i]) { | 64 if (str == Extension::kPermissionNames[i]) { |
| 65 if (str == Extension::kExperimentalPermission && | 65 if (str == Extension::kExperimentalPermission && |
| 66 !CommandLine::ForCurrentProcess()->HasSwitch( | 66 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 67 switches::kEnableExperimentalExtensionApis)) { | 67 switches::kEnableExperimentalExtensionApis) && |
| 68 // TODO(arv): Tighten this so that not all extensions can access the |
| 69 // experimental APIs. |
| 70 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 71 switches::kEnableTabbedBookmarkManager)) { |
| 68 return false; | 72 return false; |
| 69 } | 73 } |
| 70 return true; | 74 return true; |
| 71 } | 75 } |
| 72 } | 76 } |
| 73 return false; | 77 return false; |
| 74 } | 78 } |
| 75 | 79 |
| 76 } // namespace | 80 } // namespace |
| 77 | 81 |
| (...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 } | 1279 } |
| 1276 | 1280 |
| 1277 // Validate that the overrides are all strings | 1281 // Validate that the overrides are all strings |
| 1278 for (DictionaryValue::key_iterator iter = overrides->begin_keys(); | 1282 for (DictionaryValue::key_iterator iter = overrides->begin_keys(); |
| 1279 iter != overrides->end_keys(); ++iter) { | 1283 iter != overrides->end_keys(); ++iter) { |
| 1280 std::string page = WideToUTF8(*iter); | 1284 std::string page = WideToUTF8(*iter); |
| 1281 // For now, only allow the new tab page. Others will work when we remove | 1285 // For now, only allow the new tab page. Others will work when we remove |
| 1282 // this check, but let's keep it simple for now. | 1286 // this check, but let's keep it simple for now. |
| 1283 // TODO(erikkay) enable other pages as well | 1287 // TODO(erikkay) enable other pages as well |
| 1284 std::string val; | 1288 std::string val; |
| 1285 if ((page != chrome::kChromeUINewTabHost) || | 1289 if ((page != chrome::kChromeUINewTabHost && |
| 1290 page != chrome::kChromeUIBookmarksHost) || |
| 1286 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { | 1291 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { |
| 1287 *error = errors::kInvalidChromeURLOverrides; | 1292 *error = errors::kInvalidChromeURLOverrides; |
| 1288 return false; | 1293 return false; |
| 1289 } | 1294 } |
| 1290 // Replace the entry with a fully qualified chrome-extension:// URL. | 1295 // Replace the entry with a fully qualified chrome-extension:// URL. |
| 1291 chrome_url_overrides_[page] = GetResourceURL(val); | 1296 chrome_url_overrides_[page] = GetResourceURL(val); |
| 1292 } | 1297 } |
| 1293 } | 1298 } |
| 1294 | 1299 |
| 1295 // If it's an app, load the appropriate keys, etc. | 1300 // If it's an app, load the appropriate keys, etc. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 UserScript::PatternList::const_iterator pattern = | 1438 UserScript::PatternList::const_iterator pattern = |
| 1434 content_script->url_patterns().begin(); | 1439 content_script->url_patterns().begin(); |
| 1435 for (; pattern != content_script->url_patterns().end(); ++pattern) { | 1440 for (; pattern != content_script->url_patterns().end(); ++pattern) { |
| 1436 if (pattern->match_subdomains() && pattern->host().empty()) | 1441 if (pattern->match_subdomains() && pattern->host().empty()) |
| 1437 return true; | 1442 return true; |
| 1438 } | 1443 } |
| 1439 } | 1444 } |
| 1440 | 1445 |
| 1441 return false; | 1446 return false; |
| 1442 } | 1447 } |
| OLD | NEW |