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

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

Issue 8890086: Issue 71980: Extensions code should use UTF-16 for user-visible Unicode strings (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
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>
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 // |FROM_BOOKMARK| indicates the extension was created using a mock App 199 // |FROM_BOOKMARK| indicates the extension was created using a mock App
200 // created from a bookmark. 200 // created from a bookmark.
201 FROM_BOOKMARK = 1 << 5, 201 FROM_BOOKMARK = 1 << 5,
202 }; 202 };
203 203
204 static scoped_refptr<Extension> Create(const FilePath& path, 204 static scoped_refptr<Extension> Create(const FilePath& path,
205 Location location, 205 Location location,
206 const base::DictionaryValue& value, 206 const base::DictionaryValue& value,
207 int flags, 207 int flags,
208 std::string* error); 208 std::string* std_error);
Aaron Boodman 2011/12/15 02:25:36 No need to change this. If it makes implementation
209 209
210 // In a few special circumstances, we want to create an Extension and give it 210 // In a few special circumstances, we want to create an Extension and give it
211 // an explicit id. Most consumers should just use the plain Create() method. 211 // an explicit id. Most consumers should just use the plain Create() method.
212 static scoped_refptr<Extension> CreateWithId( 212 static scoped_refptr<Extension> CreateWithId(
213 const FilePath& path, 213 const FilePath& path,
214 Location location, 214 Location location,
215 const base::DictionaryValue& value, 215 const base::DictionaryValue& value,
216 int flags, 216 int flags,
217 const std::string& explicit_id, 217 const std::string& explicit_id,
218 std::string* error); 218 std::string* error);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 // Adds an extension to the scripting whitelist. Used for testing only. 372 // Adds an extension to the scripting whitelist. Used for testing only.
373 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); 373 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
374 static const ScriptingWhitelist* GetScriptingWhitelist(); 374 static const ScriptingWhitelist* GetScriptingWhitelist();
375 375
376 // Parses the host and api permissions from the specified permission |key| 376 // Parses the host and api permissions from the specified permission |key|
377 // in the manifest |source|. 377 // in the manifest |source|.
378 bool ParsePermissions(const extensions::Manifest* source, 378 bool ParsePermissions(const extensions::Manifest* source,
379 const char* key, 379 const char* key,
380 int flags, 380 int flags,
381 std::string* error, 381 string16* error,
382 ExtensionAPIPermissionSet* api_permissions, 382 ExtensionAPIPermissionSet* api_permissions,
383 URLPatternSet* host_permissions); 383 URLPatternSet* host_permissions);
384 384
385 bool HasAPIPermission(ExtensionAPIPermission::ID permission) const; 385 bool HasAPIPermission(ExtensionAPIPermission::ID permission) const;
386 bool HasAPIPermission(const std::string& function_name) const; 386 bool HasAPIPermission(const std::string& function_name) const;
387 387
388 const URLPatternSet& GetEffectiveHostPermissions() const; 388 const URLPatternSet& GetEffectiveHostPermissions() const;
389 389
390 // Returns true if the extension can silently increase its permission level. 390 // Returns true if the extension can silently increase its permission level.
391 // Extensions that can silently increase permissions are installed through 391 // Extensions that can silently increase permissions are installed through
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 612
613 // Returns true if this extension id is from a trusted provider. 613 // Returns true if this extension id is from a trusted provider.
614 static bool IsTrustedId(const std::string& id); 614 static bool IsTrustedId(const std::string& id);
615 615
616 Extension(const FilePath& path, Location location); 616 Extension(const FilePath& path, Location location);
617 ~Extension(); 617 ~Extension();
618 618
619 // Initialize the extension from a parsed manifest. 619 // Initialize the extension from a parsed manifest.
620 // Takes ownership of the manifest |value|. 620 // Takes ownership of the manifest |value|.
621 bool InitFromValue(extensions::Manifest* value, int flags, 621 bool InitFromValue(extensions::Manifest* value, int flags,
622 std::string* error); 622 string16* error);
623 623
624 // Helper function for implementing HasCachedImage/GetCachedImage. A return 624 // Helper function for implementing HasCachedImage/GetCachedImage. A return
625 // value of NULL means there is no matching image cached (we allow caching an 625 // value of NULL means there is no matching image cached (we allow caching an
626 // empty SkBitmap). 626 // empty SkBitmap).
627 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, 627 SkBitmap* GetCachedImageImpl(const ExtensionResource& source,
628 const gfx::Size& max_size) const; 628 const gfx::Size& max_size) const;
629 629
630 // Helper method that loads a UserScript object from a 630 // Helper method that loads a UserScript object from a
631 // dictionary in the content_script list of the manifest. 631 // dictionary in the content_script list of the manifest.
632 bool LoadUserScriptHelper(const base::DictionaryValue* content_script, 632 bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
633 int definition_index, 633 int definition_index,
634 int flags, 634 int flags,
635 std::string* error, 635 string16* error,
636 UserScript* result); 636 UserScript* result);
637 637
638 // Helper method that loads either the include_globs or exclude_globs list 638 // Helper method that loads either the include_globs or exclude_globs list
639 // from an entry in the content_script lists of the manifest. 639 // from an entry in the content_script lists of the manifest.
640 bool LoadGlobsHelper(const base::DictionaryValue* content_script, 640 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
641 int content_script_index, 641 int content_script_index,
642 const char* globs_property_name, 642 const char* globs_property_name,
643 std::string* error, 643 string16* error,
644 void(UserScript::*add_method)(const std::string& glob), 644 void(UserScript::*add_method)(const std::string& glob),
645 UserScript *instance); 645 UserScript *instance);
646 646
647 // Helpers to load various chunks of the manifest. 647 // Helpers to load various chunks of the manifest.
648 bool LoadExtent(const extensions::Manifest* manifest, 648 bool LoadExtent(const extensions::Manifest* manifest,
649 const char* key, 649 const char* key,
650 URLPatternSet* extent, 650 URLPatternSet* extent,
651 const char* list_error, 651 const char* list_error,
652 const char* value_error, 652 const char* value_error,
653 URLPattern::ParseOption parse_option, 653 URLPattern::ParseOption parse_option,
654 std::string* error); 654 string16* error);
655 bool LoadLaunchContainer(const extensions::Manifest* manifest, 655 bool LoadLaunchContainer(const extensions::Manifest* manifest,
656 std::string* error); 656 string16* error);
657 bool LoadLaunchURL(const extensions::Manifest* manifest, 657 bool LoadLaunchURL(const extensions::Manifest* manifest,
658 std::string* error); 658 string16* error);
659 bool LoadAppIsolation(const extensions::Manifest* manifest, 659 bool LoadAppIsolation(const extensions::Manifest* manifest,
660 std::string* error); 660 string16* error);
661 bool LoadWebIntentServices(const extensions::Manifest* manifest, 661 bool LoadWebIntentServices(const extensions::Manifest* manifest,
662 std::string* error); 662 string16* error);
663 663
664 // Helper method to load an ExtensionAction from the page_action or 664 // Helper method to load an ExtensionAction from the page_action or
665 // browser_action entries in the manifest. 665 // browser_action entries in the manifest.
666 ExtensionAction* LoadExtensionActionHelper( 666 ExtensionAction* LoadExtensionActionHelper(
667 const base::DictionaryValue* extension_action, std::string* error); 667 const base::DictionaryValue* extension_action, string16* error);
668 668
669 // Helper method to load an FileBrowserHandlerList from the manifest. 669 // Helper method to load an FileBrowserHandlerList from the manifest.
670 FileBrowserHandlerList* LoadFileBrowserHandlers( 670 FileBrowserHandlerList* LoadFileBrowserHandlers(
671 const base::ListValue* extension_actions, std::string* error); 671 const base::ListValue* extension_actions, string16* error);
672 // Helper method to load an FileBrowserHandler from manifest. 672 // Helper method to load an FileBrowserHandler from manifest.
673 FileBrowserHandler* LoadFileBrowserHandler( 673 FileBrowserHandler* LoadFileBrowserHandler(
674 const base::DictionaryValue* file_browser_handlers, std::string* error); 674 const base::DictionaryValue* file_browser_handlers, string16* error);
675 675
676 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest 676 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest
677 // entry. 677 // entry.
678 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults( 678 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults(
679 const base::DictionaryValue* sidebar, std::string* error); 679 const base::DictionaryValue* sidebar, string16* error);
680 680
681 // Returns true if the extension has more than one "UI surface". For example, 681 // Returns true if the extension has more than one "UI surface". For example,
682 // an extension that has a browser action and a page action. 682 // an extension that has a browser action and a page action.
683 bool HasMultipleUISurfaces() const; 683 bool HasMultipleUISurfaces() const;
684 684
685 // Updates the launch URL and extents for the extension using the given 685 // Updates the launch URL and extents for the extension using the given
686 // |override_url|. 686 // |override_url|.
687 void OverrideLaunchUrl(const GURL& override_url); 687 void OverrideLaunchUrl(const GURL& override_url);
688 688
689 // Returns true if this extension can specify |api|. 689 // Returns true if this extension can specify |api|.
690 bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api, 690 bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api,
691 std::string* error) const; 691 string16* error) const;
692 bool CanSpecifyComponentOnlyPermission() const; 692 bool CanSpecifyComponentOnlyPermission() const;
693 bool CanSpecifyExperimentalPermission() const; 693 bool CanSpecifyExperimentalPermission() const;
694 694
695 // Checks whether the host |pattern| is allowed for this extension, given API 695 // Checks whether the host |pattern| is allowed for this extension, given API
696 // permissions |permissions|. 696 // permissions |permissions|.
697 bool CanSpecifyHostPermission(const URLPattern& pattern, 697 bool CanSpecifyHostPermission(const URLPattern& pattern,
698 const ExtensionAPIPermissionSet& permissions) const; 698 const ExtensionAPIPermissionSet& permissions) const;
699 699
700 // Cached images for this extension. This should only be touched on the UI 700 // Cached images for this extension. This should only be touched on the UI
701 // thread. 701 // thread.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 // only contain the removed permissions. 932 // only contain the removed permissions.
933 const ExtensionPermissionSet* permissions; 933 const ExtensionPermissionSet* permissions;
934 934
935 UpdatedExtensionPermissionsInfo( 935 UpdatedExtensionPermissionsInfo(
936 const Extension* extension, 936 const Extension* extension,
937 const ExtensionPermissionSet* permissions, 937 const ExtensionPermissionSet* permissions,
938 Reason reason); 938 Reason reason);
939 }; 939 };
940 940
941 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 941 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698