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

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

Issue 3263007: Reland r57788 - Expose Extension Bindings to Component Applications (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: don't hide gallery url in omnibar Created 10 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
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/render_messages_params.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) 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 "base/base64.h" 10 #include "base/base64.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 bool IsBaseCrxKey(const std::string& key) { 87 bool IsBaseCrxKey(const std::string& key) {
88 for (size_t i = 0; i < arraysize(kBaseCrxKeys); ++i) { 88 for (size_t i = 0; i < arraysize(kBaseCrxKeys); ++i) {
89 if (key == kBaseCrxKeys[i]) 89 if (key == kBaseCrxKeys[i])
90 return true; 90 return true;
91 } 91 }
92 92
93 return false; 93 return false;
94 } 94 }
95 95
96 // Names of API modules that do not require a permission.
97 const char kBrowserActionModuleName[] = "browserAction";
98 const char kBrowserActionsModuleName[] = "browserActions";
99 const char kDevToolsModuleName[] = "devtools";
100 const char kExtensionModuleName[] = "extension";
101 const char kI18NModuleName[] = "i18n";
102 const char kPageActionModuleName[] = "pageAction";
103 const char kPageActionsModuleName[] = "pageActions";
104 const char kTestModuleName[] = "test";
105
106 const char* kNonPermissionModuleNames[] = {
107 kBrowserActionModuleName,
108 kBrowserActionsModuleName,
109 kDevToolsModuleName,
110 kExtensionModuleName,
111 kI18NModuleName,
112 kPageActionModuleName,
113 kPageActionsModuleName,
114 kTestModuleName
115 };
116 const size_t kNumNonPermissionModuleNames =
117 arraysize(kNonPermissionModuleNames);
118
96 } // namespace 119 } // namespace
97 120
98 const FilePath::CharType Extension::kManifestFilename[] = 121 const FilePath::CharType Extension::kManifestFilename[] =
99 FILE_PATH_LITERAL("manifest.json"); 122 FILE_PATH_LITERAL("manifest.json");
100 const FilePath::CharType Extension::kLocaleFolder[] = 123 const FilePath::CharType Extension::kLocaleFolder[] =
101 FILE_PATH_LITERAL("_locales"); 124 FILE_PATH_LITERAL("_locales");
102 const FilePath::CharType Extension::kMessagesFilename[] = 125 const FilePath::CharType Extension::kMessagesFilename[] =
103 FILE_PATH_LITERAL("messages.json"); 126 FILE_PATH_LITERAL("messages.json");
104 127
105 #if defined(OS_WIN) 128 #if defined(OS_WIN)
(...skipping 10 matching lines...) Expand all
116 EXTENSION_ICON_LARGE, 139 EXTENSION_ICON_LARGE,
117 EXTENSION_ICON_MEDIUM, 140 EXTENSION_ICON_MEDIUM,
118 EXTENSION_ICON_SMALL, 141 EXTENSION_ICON_SMALL,
119 EXTENSION_ICON_SMALLISH, 142 EXTENSION_ICON_SMALLISH,
120 EXTENSION_ICON_BITTY 143 EXTENSION_ICON_BITTY
121 }; 144 };
122 145
123 const int Extension::kPageActionIconMaxSize = 19; 146 const int Extension::kPageActionIconMaxSize = 19;
124 const int Extension::kBrowserActionIconMaxSize = 19; 147 const int Extension::kBrowserActionIconMaxSize = 19;
125 148
149 // Explicit permissions -- permission declaration required.
126 const char* Extension::kBackgroundPermission = "background"; 150 const char* Extension::kBackgroundPermission = "background";
127 const char* Extension::kContextMenusPermission = "contextMenus"; 151 const char* Extension::kContextMenusPermission = "contextMenus";
128 const char* Extension::kBookmarkPermission = "bookmarks"; 152 const char* Extension::kBookmarkPermission = "bookmarks";
129 const char* Extension::kCookiePermission = "cookies"; 153 const char* Extension::kCookiePermission = "cookies";
130 const char* Extension::kExperimentalPermission = "experimental"; 154 const char* Extension::kExperimentalPermission = "experimental";
131 const char* Extension::kGeolocationPermission = "geolocation"; 155 const char* Extension::kGeolocationPermission = "geolocation";
132 const char* Extension::kHistoryPermission = "history"; 156 const char* Extension::kHistoryPermission = "history";
133 const char* Extension::kIdlePermission = "idle"; 157 const char* Extension::kIdlePermission = "idle";
134 const char* Extension::kNotificationPermission = "notifications"; 158 const char* Extension::kNotificationPermission = "notifications";
135 const char* Extension::kProxyPermission = "proxy"; 159 const char* Extension::kProxyPermission = "proxy";
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 // Only allow access to chrome://favicon to regular extensions. Component 1758 // Only allow access to chrome://favicon to regular extensions. Component
1735 // extensions can have access to all of chrome://*. 1759 // extensions can have access to all of chrome://*.
1736 return (pattern.host() == chrome::kChromeUIFavIconHost || 1760 return (pattern.host() == chrome::kChromeUIFavIconHost ||
1737 location() == Extension::COMPONENT); 1761 location() == Extension::COMPONENT);
1738 } 1762 }
1739 1763
1740 // Otherwise, the valid schemes were handled by URLPattern. 1764 // Otherwise, the valid schemes were handled by URLPattern.
1741 return true; 1765 return true;
1742 } 1766 }
1743 1767
1768 // static.
1769 bool Extension::HasApiPermission(
1770 const std::vector<std::string>& api_permissions,
1771 const std::string& permission) {
1772 std::string permission_name = permission;
1773
1774 // windows and tabs are the same permission.
1775 if (permission_name == "windows")
1776 permission_name = Extension::kTabPermission;
1777
1778 if (std::find(api_permissions.begin(), api_permissions.end(),
1779 permission_name) != api_permissions.end())
1780 return true;
1781
1782 for (size_t i = 0; i < kNumNonPermissionModuleNames; ++i) {
1783 if (permission_name == kNonPermissionModuleNames[i]) {
1784 return true;
1785 }
1786 }
1787
1788 return false;
1789 }
1790
1744 bool Extension::HasHostPermission(const GURL& url) const { 1791 bool Extension::HasHostPermission(const GURL& url) const {
1745 for (URLPatternList::const_iterator host = host_permissions_.begin(); 1792 for (URLPatternList::const_iterator host = host_permissions_.begin();
1746 host != host_permissions_.end(); ++host) { 1793 host != host_permissions_.end(); ++host) {
1747 if (host->MatchesUrl(url)) 1794 if (host->MatchesUrl(url))
1748 return true; 1795 return true;
1749 } 1796 }
1750 return false; 1797 return false;
1751 } 1798 }
1752 1799
1753 const ExtensionExtent Extension::GetEffectiveHostPermissions() const { 1800 const ExtensionExtent Extension::GetEffectiveHostPermissions() const {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 : extension_id(id), 1868 : extension_id(id),
1822 extension_path(path), 1869 extension_path(path),
1823 extension_location(location) { 1870 extension_location(location) {
1824 if (manifest) 1871 if (manifest)
1825 extension_manifest.reset( 1872 extension_manifest.reset(
1826 static_cast<DictionaryValue*>(manifest->DeepCopy())); 1873 static_cast<DictionaryValue*>(manifest->DeepCopy()));
1827 } 1874 }
1828 1875
1829 ExtensionInfo::~ExtensionInfo() { 1876 ExtensionInfo::~ExtensionInfo() {
1830 } 1877 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/render_messages_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698