Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "chrome/common/extensions/extension_icon_set.h" | 20 #include "chrome/common/extensions/extension_icon_set.h" |
| 21 #include "chrome/common/extensions/extension_permission_set.h" | |
| 21 #include "chrome/common/extensions/user_script.h" | 22 #include "chrome/common/extensions/user_script.h" |
| 22 #include "chrome/common/extensions/url_pattern.h" | 23 #include "chrome/common/extensions/url_pattern.h" |
| 23 #include "chrome/common/extensions/url_pattern_set.h" | 24 #include "chrome/common/extensions/url_pattern_set.h" |
| 24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 25 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
| 26 | 27 |
| 27 class DictionaryValue; | 28 class DictionaryValue; |
| 28 class ExtensionAction; | 29 class ExtensionAction; |
| 29 class ExtensionResource; | 30 class ExtensionResource; |
| 30 class ExtensionSidebarDefaults; | 31 class ExtensionSidebarDefaults; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 bool shortcut_ctrl; | 135 bool shortcut_ctrl; |
| 135 bool shortcut_shift; | 136 bool shortcut_shift; |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 struct TtsVoice { | 139 struct TtsVoice { |
| 139 std::string voice_name; | 140 std::string voice_name; |
| 140 std::string locale; | 141 std::string locale; |
| 141 std::string gender; | 142 std::string gender; |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 // When prompting the user to install or approve permissions, we display | |
| 145 // messages describing the effects of the permissions and not the permissions | |
| 146 // themselves. Each PermissionMessage represents one of the messages that is | |
| 147 // shown to the user. | |
| 148 class PermissionMessage { | |
| 149 public: | |
| 150 // Do not reorder or add new enumerations in this list. If you need to add a | |
| 151 // new enum, add it just prior to ID_ENUM_BOUNDARY and enter its l10n | |
| 152 // message in kMessageIds. | |
| 153 enum MessageId { | |
| 154 ID_UNKNOWN, | |
| 155 ID_NONE, | |
| 156 ID_BOOKMARKS, | |
| 157 ID_GEOLOCATION, | |
| 158 ID_BROWSING_HISTORY, | |
| 159 ID_TABS, | |
| 160 ID_MANAGEMENT, | |
| 161 ID_DEBUGGER, | |
| 162 ID_HOSTS_1, | |
| 163 ID_HOSTS_2, | |
| 164 ID_HOSTS_3, | |
| 165 ID_HOSTS_4_OR_MORE, | |
| 166 ID_HOSTS_ALL, | |
| 167 ID_FULL_ACCESS, | |
| 168 ID_CLIPBOARD, | |
| 169 ID_ENUM_BOUNDARY | |
| 170 }; | |
| 171 | |
| 172 // Creates a permission message with the given |message_id| and initializes | |
| 173 // its message to the appropriate value. | |
| 174 static PermissionMessage CreateFromMessageId(MessageId message_id); | |
| 175 | |
| 176 // Creates the corresponding permission message for a list of hosts. This | |
| 177 // method exists because the hosts are presented as one message that depends | |
| 178 // on what and how many hosts there are. | |
| 179 static PermissionMessage CreateFromHostList( | |
| 180 const std::vector<std::string> hosts); | |
| 181 | |
| 182 // Gets the id of the permission message, which can be used in UMA | |
| 183 // histograms. | |
| 184 MessageId message_id() const { return message_id_; } | |
| 185 | |
| 186 // Gets a localized message describing this permission. Please note that | |
| 187 // the message will be empty for message types TYPE_NONE and TYPE_UNKNOWN. | |
| 188 const string16& message() const { return message_; } | |
| 189 | |
| 190 // Comparator to work with std::set. | |
| 191 bool operator<(const PermissionMessage& that) const { | |
| 192 return message_id_ < that.message_id_; | |
| 193 } | |
| 194 | |
| 195 private: | |
| 196 PermissionMessage(MessageId message_id, string16 message_); | |
| 197 | |
| 198 // The index of the id in the array is its enum value. The first two values | |
| 199 // are non-existent message ids to act as placeholders for "unknown" and | |
| 200 // "none". | |
| 201 // Note: Do not change the order of the items in this list since they | |
| 202 // are used in a histogram. The order must match the MessageId order. | |
| 203 static const int kMessageIds[]; | |
| 204 | |
| 205 MessageId message_id_; | |
| 206 string16 message_; | |
| 207 }; | |
| 208 | |
| 209 typedef std::vector<PermissionMessage> PermissionMessages; | |
| 210 | |
| 211 // A permission is defined by its |name| (what is used in the manifest), | |
| 212 // and the |message_id| that's used by install/update UI. | |
| 213 struct Permission { | |
| 214 const char* const name; | |
| 215 const PermissionMessage::MessageId message_id; | |
| 216 }; | |
| 217 | |
| 218 enum InitFromValueFlags { | 145 enum InitFromValueFlags { |
| 219 NO_FLAGS = 0, | 146 NO_FLAGS = 0, |
| 220 | 147 |
| 221 // Usually, the id of an extension is generated by the "key" property of | 148 // Usually, the id of an extension is generated by the "key" property of |
| 222 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be | 149 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be |
| 223 // generated based on the path. | 150 // generated based on the path. |
| 224 REQUIRE_KEY = 1 << 0, | 151 REQUIRE_KEY = 1 << 0, |
| 225 | 152 |
| 226 // |STRICT_ERROR_CHECKS| enables extra error checking, such as | 153 // |STRICT_ERROR_CHECKS| enables extra error checking, such as |
| 227 // checks that URL patterns do not contain ports. This error | 154 // checks that URL patterns do not contain ports. This error |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 248 std::string* error); | 175 std::string* error); |
| 249 | 176 |
| 250 // Return the update url used by gallery/webstore extensions. | 177 // Return the update url used by gallery/webstore extensions. |
| 251 static GURL GalleryUpdateUrl(bool secure); | 178 static GURL GalleryUpdateUrl(bool secure); |
| 252 | 179 |
| 253 // Given two install sources, return the one which should take priority | 180 // Given two install sources, return the one which should take priority |
| 254 // over the other. If an extension is installed from two sources A and B, | 181 // over the other. If an extension is installed from two sources A and B, |
| 255 // its install source should be set to GetHigherPriorityLocation(A, B). | 182 // its install source should be set to GetHigherPriorityLocation(A, B). |
| 256 static Location GetHigherPriorityLocation(Location loc1, Location loc2); | 183 static Location GetHigherPriorityLocation(Location loc1, Location loc2); |
| 257 | 184 |
| 258 // Get's the install message id for |permission|. Returns | |
| 259 // MessageId::TYPE_NONE if none exists. | |
| 260 static PermissionMessage::MessageId GetPermissionMessageId( | |
| 261 const std::string& permission); | |
| 262 | |
| 263 // Returns the full list of permission messages that this extension | 185 // Returns the full list of permission messages that this extension |
| 264 // should display at install time. | 186 // should display at install time. |
| 265 PermissionMessages GetPermissionMessages() const; | 187 ExtensionPermissionMessages GetPermissionMessages() const; |
| 266 | 188 |
| 267 // Returns the full list of permission messages that this extension | 189 // Returns the full list of permission messages that this extension |
| 268 // should display at install time. The messages are returned as strings | 190 // should display at install time. The messages are returned as strings |
| 269 // for convenience. | 191 // for convenience. |
| 270 std::vector<string16> GetPermissionMessageStrings() const; | 192 std::vector<string16> GetPermissionMessageStrings() const; |
| 271 | 193 |
| 272 // Returns the distinct hosts that should be displayed in the install UI | |
| 273 // for the URL patterns |list|. This discards some of the detail that is | |
| 274 // present in the manifest to make it as easy as possible to process by | |
| 275 // users. In particular we disregard the scheme and path components of | |
| 276 // URLPatterns and de-dupe the result, which includes filtering out common | |
| 277 // hosts with differing RCDs (aka Registry Controlled Domains, most of which | |
| 278 // are Top Level Domains but also include exceptions like co.uk). | |
| 279 // NOTE: when de-duping hosts the preferred RCD will be returned, given this | |
| 280 // order of preference: .com, .net, .org, first in list. | |
| 281 static std::vector<std::string> GetDistinctHostsForDisplay( | |
| 282 const URLPatternList& list); | |
| 283 | |
| 284 // Compares two URLPatternLists for security equality by returning whether | |
| 285 // the URL patterns in |new_list| contain additional distinct hosts compared | |
| 286 // to |old_list|. | |
| 287 static bool IsElevatedHostList( | |
| 288 const URLPatternList& old_list, const URLPatternList& new_list); | |
| 289 | |
| 290 // Icon sizes used by the extension system. | 194 // Icon sizes used by the extension system. |
| 291 static const int kIconSizes[]; | 195 static const int kIconSizes[]; |
| 292 | 196 |
| 293 // Max size (both dimensions) for browser and page actions. | 197 // Max size (both dimensions) for browser and page actions. |
| 294 static const int kPageActionIconMaxSize; | 198 static const int kPageActionIconMaxSize; |
| 295 static const int kBrowserActionIconMaxSize; | 199 static const int kBrowserActionIconMaxSize; |
| 296 static const int kSidebarIconMaxSize; | 200 static const int kSidebarIconMaxSize; |
| 297 | 201 |
| 298 // Each permission is a module that the extension is permitted to use. | |
| 299 // | |
| 300 // NOTE: To add a new permission, define it here, and add an entry to | |
| 301 // Extension::kPermissions. | |
| 302 static const char kBackgroundPermission[]; | |
| 303 static const char kBookmarkPermission[]; | |
| 304 static const char kClipboardReadPermission[]; | |
| 305 static const char kClipboardWritePermission[]; | |
| 306 static const char kContentSettingsPermission[]; | |
| 307 static const char kContextMenusPermission[]; | |
| 308 static const char kCookiePermission[]; | |
| 309 static const char kChromePrivatePermission[]; | |
| 310 static const char kChromeosInfoPrivatePermission[]; | |
| 311 static const char kDebuggerPermission[]; | |
| 312 static const char kExperimentalPermission[]; | |
| 313 static const char kFileBrowserHandlerPermission[]; | |
| 314 static const char kFileBrowserPrivatePermission[]; | |
| 315 static const char kGeolocationPermission[]; | |
| 316 static const char kHistoryPermission[]; | |
| 317 static const char kIdlePermission[]; | |
| 318 static const char kManagementPermission[]; | |
| 319 static const char kMediaPlayerPrivatePermission[]; | |
| 320 static const char kNotificationPermission[]; | |
| 321 static const char kProxyPermission[]; | |
| 322 static const char kTabPermission[]; | |
| 323 static const char kUnlimitedStoragePermission[]; | |
| 324 static const char kWebstorePrivatePermission[]; | |
| 325 static const char kWebSocketProxyPrivatePermission[]; | |
| 326 | |
| 327 static const Permission kPermissions[]; | |
| 328 static const size_t kNumPermissions; | |
| 329 static const char* const kHostedAppPermissionNames[]; | |
| 330 static const size_t kNumHostedAppPermissions; | |
| 331 static const char* const kComponentPrivatePermissionNames[]; | |
| 332 static const size_t kNumComponentPrivatePermissions; | |
| 333 | |
| 334 // The old name for the unlimited storage permission, which is deprecated but | |
| 335 // still accepted as meaning the same thing as kUnlimitedStoragePermission. | |
| 336 static const char kOldUnlimitedStoragePermission[]; | |
| 337 | |
| 338 // Valid schemes for web extent URLPatterns. | 202 // Valid schemes for web extent URLPatterns. |
| 339 static const int kValidWebExtentSchemes; | 203 static const int kValidWebExtentSchemes; |
| 340 | 204 |
| 341 // Valid schemes for host permission URLPatterns. | 205 // Valid schemes for host permission URLPatterns. |
| 342 static const int kValidHostPermissionSchemes; | 206 static const int kValidHostPermissionSchemes; |
| 343 | 207 |
| 344 // Returns true if the string is one of the known hosted app permissions (see | |
| 345 // kHostedAppPermissionNames). | |
| 346 static bool IsHostedAppPermission(const std::string& permission); | |
| 347 | |
| 348 // The name of the manifest inside an extension. | 208 // The name of the manifest inside an extension. |
| 349 static const FilePath::CharType kManifestFilename[]; | 209 static const FilePath::CharType kManifestFilename[]; |
| 350 | 210 |
| 351 // The name of locale folder inside an extension. | 211 // The name of locale folder inside an extension. |
| 352 static const FilePath::CharType kLocaleFolder[]; | 212 static const FilePath::CharType kLocaleFolder[]; |
| 353 | 213 |
| 354 // The name of the messages file inside an extension. | 214 // The name of the messages file inside an extension. |
| 355 static const FilePath::CharType kMessagesFilename[]; | 215 static const FilePath::CharType kMessagesFilename[]; |
| 356 | 216 |
| 357 #if defined(OS_WIN) | 217 #if defined(OS_WIN) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 // Generates an extension ID from arbitrary input. The same input string will | 307 // Generates an extension ID from arbitrary input. The same input string will |
| 448 // always generate the same output ID. | 308 // always generate the same output ID. |
| 449 static bool GenerateId(const std::string& input, std::string* output); | 309 static bool GenerateId(const std::string& input, std::string* output); |
| 450 | 310 |
| 451 // Expects base64 encoded |input| and formats into |output| including | 311 // Expects base64 encoded |input| and formats into |output| including |
| 452 // the appropriate header & footer. | 312 // the appropriate header & footer. |
| 453 static bool FormatPEMForFileOutput(const std::string& input, | 313 static bool FormatPEMForFileOutput(const std::string& input, |
| 454 std::string* output, | 314 std::string* output, |
| 455 bool is_public); | 315 bool is_public); |
| 456 | 316 |
| 457 // Determine whether |new_extension| has increased privileges compared to | |
| 458 // its previously granted permissions, specified by |granted_apis|, | |
| 459 // |granted_extent| and |granted_full_access|. | |
| 460 static bool IsPrivilegeIncrease(const bool granted_full_access, | |
| 461 const std::set<std::string>& granted_apis, | |
| 462 const URLPatternSet& granted_extent, | |
| 463 const Extension* new_extension); | |
| 464 | |
| 465 // Given an extension and icon size, read it if present and decode it into | 317 // Given an extension and icon size, read it if present and decode it into |
| 466 // result. In the browser process, this will DCHECK if not called on the | 318 // result. In the browser process, this will DCHECK if not called on the |
| 467 // file thread. To easily load extension images on the UI thread, see | 319 // file thread. To easily load extension images on the UI thread, see |
| 468 // ImageLoadingTracker. | 320 // ImageLoadingTracker. |
| 469 static void DecodeIcon(const Extension* extension, | 321 static void DecodeIcon(const Extension* extension, |
| 470 Icons icon_size, | 322 Icons icon_size, |
| 471 scoped_ptr<SkBitmap>* result); | 323 scoped_ptr<SkBitmap>* result); |
| 472 | 324 |
| 473 // Given an icon_path and icon size, read it if present and decode it into | 325 // Given an icon_path and icon size, read it if present and decode it into |
| 474 // result. In the browser process, this will DCHECK if not called on the | 326 // result. In the browser process, this will DCHECK if not called on the |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 489 // --apps-gallery-url switch. The URL returned will not contain a trailing | 341 // --apps-gallery-url switch. The URL returned will not contain a trailing |
| 490 // slash. Do not use this as a prefix/extent for the store. Instead see | 342 // slash. Do not use this as a prefix/extent for the store. Instead see |
| 491 // ExtensionService::GetWebStoreApp or | 343 // ExtensionService::GetWebStoreApp or |
| 492 // ExtensionService::IsDownloadFromGallery | 344 // ExtensionService::IsDownloadFromGallery |
| 493 static std::string ChromeStoreLaunchURL(); | 345 static std::string ChromeStoreLaunchURL(); |
| 494 | 346 |
| 495 // Adds an extension to the scripting whitelist. Used for testing only. | 347 // Adds an extension to the scripting whitelist. Used for testing only. |
| 496 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); | 348 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); |
| 497 static const ScriptingWhitelist* GetScriptingWhitelist(); | 349 static const ScriptingWhitelist* GetScriptingWhitelist(); |
| 498 | 350 |
| 499 // Returns true if the extension has the specified API permission. | 351 bool HasApiPermission(ExtensionAPIPermission::Id permission) const; |
| 500 static bool HasApiPermission(const std::set<std::string>& api_permissions, | 352 bool HasApiPermission(const std::string& function_name) const; |
|
Matt Perry
2011/06/21 00:43:10
I realize the code was already like this, but can
jstritar
2011/06/21 23:12:16
I'm thinking about removing it in a subsequent CL,
| |
| 501 const std::string& function_name); | |
| 502 | 353 |
| 503 // Whether the |effective_host_permissions| and |api_permissions| include | 354 const URLPatternSet& GetEffectiveHostPermissions() const; |
| 504 // effective access to all hosts. See the non-static version of the method | |
| 505 // for more details. | |
| 506 static bool HasEffectiveAccessToAllHosts( | |
| 507 const URLPatternSet& effective_host_permissions, | |
| 508 const std::set<std::string>& api_permissions); | |
| 509 | |
| 510 bool HasApiPermission(const std::string& function_name) const { | |
| 511 return HasApiPermission(this->api_permissions(), function_name); | |
| 512 } | |
| 513 | |
| 514 const URLPatternSet& GetEffectiveHostPermissions() const { | |
| 515 return effective_host_permissions_; | |
| 516 } | |
| 517 | 355 |
| 518 // Whether or not the extension is allowed permission for a URL pattern from | 356 // Whether or not the extension is allowed permission for a URL pattern from |
| 519 // the manifest. http, https, and chrome://favicon/ is allowed for all | 357 // the manifest. http, https, and chrome://favicon/ is allowed for all |
| 520 // extensions, while component extensions are allowed access to | 358 // extensions, while component extensions are allowed access to |
| 521 // chrome://resources. | 359 // chrome://resources. |
| 522 bool CanSpecifyHostPermission(const URLPattern& pattern) const; | 360 bool CanSpecifyHostPermission(const URLPattern& pattern) const; |
| 523 | 361 |
| 524 // Whether the extension has access to the given URL. | 362 // Whether the extension has access to the given URL. |
| 525 bool HasHostPermission(const GURL& url) const; | 363 bool HasHostPermission(const GURL& url) const; |
| 526 | 364 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 const std::vector<NaClModuleInfo>& nacl_modules() const { | 460 const std::vector<NaClModuleInfo>& nacl_modules() const { |
| 623 return nacl_modules_; | 461 return nacl_modules_; |
| 624 } | 462 } |
| 625 const std::vector<InputComponentInfo>& input_components() const { | 463 const std::vector<InputComponentInfo>& input_components() const { |
| 626 return input_components_; | 464 return input_components_; |
| 627 } | 465 } |
| 628 const GURL& background_url() const { return background_url_; } | 466 const GURL& background_url() const { return background_url_; } |
| 629 const GURL& options_url() const { return options_url_; } | 467 const GURL& options_url() const { return options_url_; } |
| 630 const GURL& devtools_url() const { return devtools_url_; } | 468 const GURL& devtools_url() const { return devtools_url_; } |
| 631 const std::vector<GURL>& toolstrips() const { return toolstrips_; } | 469 const std::vector<GURL>& toolstrips() const { return toolstrips_; } |
| 632 const std::set<std::string>& api_permissions() const { | 470 const ExtensionPermissionSet* permission_set() const { |
| 633 return api_permissions_; | 471 return permission_set_.get(); |
| 634 } | 472 } |
| 635 const URLPatternList& host_permissions() const { return host_permissions_; } | |
| 636 const GURL& update_url() const { return update_url_; } | 473 const GURL& update_url() const { return update_url_; } |
| 637 const ExtensionIconSet& icons() const { return icons_; } | 474 const ExtensionIconSet& icons() const { return icons_; } |
| 638 const DictionaryValue* manifest_value() const { | 475 const DictionaryValue* manifest_value() const { |
| 639 return manifest_value_.get(); | 476 return manifest_value_.get(); |
| 640 } | 477 } |
| 641 const std::string default_locale() const { return default_locale_; } | 478 const std::string default_locale() const { return default_locale_; } |
| 642 const URLOverrideMap& GetChromeURLOverrides() const { | 479 const URLOverrideMap& GetChromeURLOverrides() const { |
| 643 return chrome_url_overrides_; | 480 return chrome_url_overrides_; |
| 644 } | 481 } |
| 645 const std::string omnibox_keyword() const { return omnibox_keyword_; } | 482 const std::string omnibox_keyword() const { return omnibox_keyword_; } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 const ListValue* extension_actions, std::string* error); | 595 const ListValue* extension_actions, std::string* error); |
| 759 // Helper method to load an FileBrowserHandler from manifest. | 596 // Helper method to load an FileBrowserHandler from manifest. |
| 760 FileBrowserHandler* LoadFileBrowserHandler( | 597 FileBrowserHandler* LoadFileBrowserHandler( |
| 761 const DictionaryValue* file_browser_handlers, std::string* error); | 598 const DictionaryValue* file_browser_handlers, std::string* error); |
| 762 | 599 |
| 763 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest | 600 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest |
| 764 // entry. | 601 // entry. |
| 765 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults( | 602 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults( |
| 766 const DictionaryValue* sidebar, std::string* error); | 603 const DictionaryValue* sidebar, std::string* error); |
| 767 | 604 |
| 768 // Calculates the effective host permissions from the permissions and content | |
| 769 // script petterns. | |
| 770 void InitEffectiveHostPermissions(); | |
| 771 | |
| 772 // Returns true if the extension has more than one "UI surface". For example, | 605 // Returns true if the extension has more than one "UI surface". For example, |
| 773 // an extension that has a browser action and a page action. | 606 // an extension that has a browser action and a page action. |
| 774 bool HasMultipleUISurfaces() const; | 607 bool HasMultipleUISurfaces() const; |
| 775 | 608 |
| 776 // Figures out if a source contains keys not associated with themes - we | 609 // Figures out if a source contains keys not associated with themes - we |
| 777 // don't want to allow scripts and such to be bundled with themes. | 610 // don't want to allow scripts and such to be bundled with themes. |
| 778 bool ContainsNonThemeKeys(const DictionaryValue& source) const; | 611 bool ContainsNonThemeKeys(const DictionaryValue& source) const; |
| 779 | 612 |
| 780 // Only allow the experimental API permission if the command line | 613 // Only allow the experimental API permission if the command line |
| 781 // flag is present. | 614 // flag is present. |
| 782 bool IsDisallowedExperimentalPermission(const std::string& permission) const; | 615 bool IsDisallowedExperimentalPermission( |
| 783 | 616 ExtensionAPIPermission::Id permission) const; |
| 784 // Returns true if the string is one of the known api permissions (see | |
| 785 // kPermissions). | |
| 786 bool IsAPIPermission(const std::string& permission) const; | |
| 787 | 617 |
| 788 // Returns true if this is a component, or we are not attempting to access a | 618 // Returns true if this is a component, or we are not attempting to access a |
| 789 // component-private permission. | 619 // component-private permission. |
| 790 bool IsComponentOnlyPermission(const std::string& permission) const; | 620 bool IsComponentOnlyPermission(const ExtensionAPIPermission* api) const; |
| 791 | |
| 792 // The set of unique API install messages that the extension has. | |
| 793 // NOTE: This only includes messages related to permissions declared in the | |
| 794 // "permissions" key in the manifest. Permissions implied from other features | |
| 795 // of the manifest, like plugins and content scripts are not included. | |
| 796 std::set<PermissionMessage> GetSimplePermissionMessages() const; | |
| 797 | 621 |
| 798 // Cached images for this extension. This should only be touched on the UI | 622 // Cached images for this extension. This should only be touched on the UI |
| 799 // thread. | 623 // thread. |
| 800 mutable ImageCache image_cache_; | 624 mutable ImageCache image_cache_; |
| 801 | 625 |
| 802 // A persistent, globally unique ID. An extension's ID is used in things | 626 // A persistent, globally unique ID. An extension's ID is used in things |
| 803 // like directory structures and URLs, and is expected to not change across | 627 // like directory structures and URLs, and is expected to not change across |
| 804 // versions. It is generated as a SHA-256 hash of the extension's public | 628 // versions. It is generated as a SHA-256 hash of the extension's public |
| 805 // key, or as a hash of the path in the case of unpacked extensions. | 629 // key, or as a hash of the path in the case of unpacked extensions. |
| 806 std::string id_; | 630 std::string id_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 817 // Default locale for fall back. Can be empty if extension is not localized. | 641 // Default locale for fall back. Can be empty if extension is not localized. |
| 818 std::string default_locale_; | 642 std::string default_locale_; |
| 819 | 643 |
| 820 // If true, a separate process will be used for the extension in incognito | 644 // If true, a separate process will be used for the extension in incognito |
| 821 // mode. | 645 // mode. |
| 822 bool incognito_split_mode_; | 646 bool incognito_split_mode_; |
| 823 | 647 |
| 824 // Defines the set of URLs in the extension's web content. | 648 // Defines the set of URLs in the extension's web content. |
| 825 URLPatternSet extent_; | 649 URLPatternSet extent_; |
| 826 | 650 |
| 827 // The set of host permissions that the extension effectively has access to, | 651 // The set of permissions that the extension effectively has access to. |
| 828 // which is a merge of host_permissions_ and all of the match patterns in | 652 scoped_ptr<ExtensionPermissionSet> permission_set_; |
| 829 // any content scripts the extension has. This is used to determine which | |
| 830 // URLs have the ability to load an extension's resources via embedded | |
| 831 // chrome-extension: URLs (see extension_protocols.cc). | |
| 832 URLPatternSet effective_host_permissions_; | |
| 833 | |
| 834 // The set of module-level APIs this extension can use. | |
| 835 std::set<std::string> api_permissions_; | |
| 836 | 653 |
| 837 // The icons for the extension. | 654 // The icons for the extension. |
| 838 ExtensionIconSet icons_; | 655 ExtensionIconSet icons_; |
| 839 | 656 |
| 840 // The base extension url for the extension. | 657 // The base extension url for the extension. |
| 841 GURL extension_url_; | 658 GURL extension_url_; |
| 842 | 659 |
| 843 // The location the extension was loaded from. | 660 // The location the extension was loaded from. |
| 844 Location location_; | 661 Location location_; |
| 845 | 662 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 | 718 |
| 902 // A map of color names to colors. | 719 // A map of color names to colors. |
| 903 scoped_ptr<DictionaryValue> theme_tints_; | 720 scoped_ptr<DictionaryValue> theme_tints_; |
| 904 | 721 |
| 905 // A map of display properties. | 722 // A map of display properties. |
| 906 scoped_ptr<DictionaryValue> theme_display_properties_; | 723 scoped_ptr<DictionaryValue> theme_display_properties_; |
| 907 | 724 |
| 908 // Whether the extension is a theme. | 725 // Whether the extension is a theme. |
| 909 bool is_theme_; | 726 bool is_theme_; |
| 910 | 727 |
| 911 // The sites this extension has permission to talk to (using XHR, etc). | |
| 912 URLPatternList host_permissions_; | |
| 913 | |
| 914 // The homepage for this extension. Useful if it is not hosted by Google and | 728 // The homepage for this extension. Useful if it is not hosted by Google and |
| 915 // therefore does not have a Gallery URL. | 729 // therefore does not have a Gallery URL. |
| 916 GURL homepage_url_; | 730 GURL homepage_url_; |
| 917 | 731 |
| 918 // URL for fetching an update manifest | 732 // URL for fetching an update manifest |
| 919 GURL update_url_; | 733 GURL update_url_; |
| 920 | 734 |
| 921 // A copy of the manifest that this extension was created from. | 735 // A copy of the manifest that this extension was created from. |
| 922 scoped_ptr<DictionaryValue> manifest_value_; | 736 scoped_ptr<DictionaryValue> manifest_value_; |
| 923 | 737 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1022 // Was the extension already disabled? | 836 // Was the extension already disabled? |
| 1023 bool already_disabled; | 837 bool already_disabled; |
| 1024 | 838 |
| 1025 // The extension being unloaded - this should always be non-NULL. | 839 // The extension being unloaded - this should always be non-NULL. |
| 1026 const Extension* extension; | 840 const Extension* extension; |
| 1027 | 841 |
| 1028 UnloadedExtensionInfo(const Extension* extension, Reason reason); | 842 UnloadedExtensionInfo(const Extension* extension, Reason reason); |
| 1029 }; | 843 }; |
| 1030 | 844 |
| 1031 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 845 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |