| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 const int Extension::kPageActionIconMaxSize = 19; | 101 const int Extension::kPageActionIconMaxSize = 19; |
| 102 const int Extension::kBrowserActionIconMaxSize = 19; | 102 const int Extension::kBrowserActionIconMaxSize = 19; |
| 103 | 103 |
| 104 const char* Extension::kTabPermission = "tabs"; | 104 const char* Extension::kTabPermission = "tabs"; |
| 105 const char* Extension::kBookmarkPermission = "bookmarks"; | 105 const char* Extension::kBookmarkPermission = "bookmarks"; |
| 106 const char* Extension::kNotificationPermission = "notifications"; | 106 const char* Extension::kNotificationPermission = "notifications"; |
| 107 const char* Extension::kExperimentalPermission = "experimental"; | 107 const char* Extension::kExperimentalPermission = "experimental"; |
| 108 const char* Extension::kUnlimitedStoragePermission = "unlimited_storage"; | 108 const char* Extension::kUnlimitedStoragePermission = "unlimited_storage"; |
| 109 const char* Extension::kHistoryPermission = "history"; |
| 109 | 110 |
| 110 const char* Extension::kPermissionNames[] = { | 111 const char* Extension::kPermissionNames[] = { |
| 111 Extension::kTabPermission, | 112 Extension::kTabPermission, |
| 112 Extension::kBookmarkPermission, | 113 Extension::kBookmarkPermission, |
| 113 Extension::kNotificationPermission, | 114 Extension::kNotificationPermission, |
| 114 Extension::kExperimentalPermission, | 115 Extension::kExperimentalPermission, |
| 115 Extension::kUnlimitedStoragePermission | 116 Extension::kUnlimitedStoragePermission, |
| 117 Extension::kHistoryPermission |
| 116 }; | 118 }; |
| 117 const size_t Extension::kNumPermissions = | 119 const size_t Extension::kNumPermissions = |
| 118 arraysize(Extension::kPermissionNames); | 120 arraysize(Extension::kPermissionNames); |
| 119 | 121 |
| 120 Extension::~Extension() { | 122 Extension::~Extension() { |
| 121 } | 123 } |
| 122 | 124 |
| 123 const std::string Extension::VersionString() const { | 125 const std::string Extension::VersionString() const { |
| 124 return version_->GetString(); | 126 return version_->GetString(); |
| 125 } | 127 } |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 DictionaryValue* overrides; | 1366 DictionaryValue* overrides; |
| 1365 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) { | 1367 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) { |
| 1366 *error = errors::kInvalidChromeURLOverrides; | 1368 *error = errors::kInvalidChromeURLOverrides; |
| 1367 return false; | 1369 return false; |
| 1368 } | 1370 } |
| 1369 | 1371 |
| 1370 // Validate that the overrides are all strings | 1372 // Validate that the overrides are all strings |
| 1371 for (DictionaryValue::key_iterator iter = overrides->begin_keys(); | 1373 for (DictionaryValue::key_iterator iter = overrides->begin_keys(); |
| 1372 iter != overrides->end_keys(); ++iter) { | 1374 iter != overrides->end_keys(); ++iter) { |
| 1373 std::string page = WideToUTF8(*iter); | 1375 std::string page = WideToUTF8(*iter); |
| 1374 // For now, only allow the new tab page. Others will work when we remove | |
| 1375 // this check, but let's keep it simple for now. | |
| 1376 // TODO(erikkay) enable other pages as well | |
| 1377 std::string val; | 1376 std::string val; |
| 1377 // Restrict override pages to a list of supported URLs. |
| 1378 if ((page != chrome::kChromeUINewTabHost && | 1378 if ((page != chrome::kChromeUINewTabHost && |
| 1379 page != chrome::kChromeUIBookmarksHost) || | 1379 page != chrome::kChromeUIBookmarksHost && |
| 1380 page != chrome::kChromeUIHistoryHost) || |
| 1380 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { | 1381 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { |
| 1381 *error = errors::kInvalidChromeURLOverrides; | 1382 *error = errors::kInvalidChromeURLOverrides; |
| 1382 return false; | 1383 return false; |
| 1383 } | 1384 } |
| 1384 // Replace the entry with a fully qualified chrome-extension:// URL. | 1385 // Replace the entry with a fully qualified chrome-extension:// URL. |
| 1385 chrome_url_overrides_[page] = GetResourceURL(val); | 1386 chrome_url_overrides_[page] = GetResourceURL(val); |
| 1386 } | 1387 } |
| 1388 |
| 1389 // An extension may override at most one page. |
| 1390 if (overrides->size() > 1) { |
| 1391 *error = errors::kMultipleOverrides; |
| 1392 return false; |
| 1393 } |
| 1387 } | 1394 } |
| 1388 | 1395 |
| 1389 if (!CheckAppsAreEnabled(manifest_value_.get(), error) || | 1396 if (!CheckAppsAreEnabled(manifest_value_.get(), error) || |
| 1390 !LoadWebContentEnabled(manifest_value_.get(), error) || | 1397 !LoadWebContentEnabled(manifest_value_.get(), error) || |
| 1391 !LoadWebOrigin(manifest_value_.get(), error) || | 1398 !LoadWebOrigin(manifest_value_.get(), error) || |
| 1392 !LoadWebPaths(manifest_value_.get(), error) || | 1399 !LoadWebPaths(manifest_value_.get(), error) || |
| 1393 !LoadLaunchURL(manifest_value_.get(), error) || | 1400 !LoadLaunchURL(manifest_value_.get(), error) || |
| 1394 !LoadLaunchContainer(manifest_value_.get(), error)) { | 1401 !LoadLaunchContainer(manifest_value_.get(), error)) { |
| 1395 return false; | 1402 return false; |
| 1396 } | 1403 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 } else { | 1600 } else { |
| 1594 return false; | 1601 return false; |
| 1595 } | 1602 } |
| 1596 } else { | 1603 } else { |
| 1597 return true; | 1604 return true; |
| 1598 } | 1605 } |
| 1599 } | 1606 } |
| 1600 } | 1607 } |
| 1601 return false; | 1608 return false; |
| 1602 } | 1609 } |
| OLD | NEW |