diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-10 19:15:08 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-10 19:15:08 +0000 |
commit | 4a8d3279cc9f2149c90d36550a55d01a264ba0a3 (patch) | |
tree | 10686a040d5bbb5af5dc4686564ceec0189fee22 /chrome/browser/extensions | |
parent | a724b6ad91affee34adc5c3ab25b05536bb51f6d (diff) | |
download | chromium_src-4a8d3279cc9f2149c90d36550a55d01a264ba0a3.zip chromium_src-4a8d3279cc9f2149c90d36550a55d01a264ba0a3.tar.gz chromium_src-4a8d3279cc9f2149c90d36550a55d01a264ba0a3.tar.bz2 |
Unrevert 11294.
- include stub fix so that linux/mac still build.
- fix DCHECK in views code.
- fix unit test.
Review URL: http://codereview.chromium.org/41020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11360 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension.cc | 13 | ||||
-rw-r--r-- | chrome/browser/extensions/extension.h | 55 | ||||
-rwxr-xr-x | chrome/browser/extensions/extension_view.cc | 2 | ||||
-rwxr-xr-x | chrome/browser/extensions/extension_view.h | 2 | ||||
-rwxr-xr-x | chrome/browser/extensions/extension_view_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 10 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.h | 4 |
7 files changed, 40 insertions, 48 deletions
diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc index 1155891..75d8930 100644 --- a/chrome/browser/extensions/extension.cc +++ b/chrome/browser/extensions/extension.cc @@ -26,6 +26,7 @@ const wchar_t* Extension::kVersionKey = L"version"; const wchar_t* Extension::kZipHashKey = L"zip_hash"; const wchar_t* Extension::kPluginsDirKey = L"plugins_dir"; const wchar_t* Extension::kThemeKey = L"theme"; +const wchar_t* Extension::kToolstripKey = L"toolstrip"; const char* Extension::kRunAtDocumentStartValue = "document_start"; const char* Extension::kRunAtDocumentEndValue = "document_end"; @@ -70,6 +71,8 @@ const char* Extension::kInvalidZipHashError = "Required key 'zip_hash' is missing or invalid."; const char* Extension::kInvalidPluginsDirError = "Invalid value for 'plugins_dir'."; +const char* Extension::kInvalidToolstripError = + "Invalid value for 'toolstrip'."; const size_t Extension::kIdSize = 20; // SHA1 (160 bits) == 20 bytes @@ -260,6 +263,16 @@ bool Extension::InitFromValue(const DictionaryValue& source, plugins_dir_ = path_.AppendASCII(plugins_dir); } + // Initialize toolstrip (optional). + if (source.HasKey(kToolstripKey)) { + std::string toolstrip_path; + if (!source.GetString(kToolstripKey, &toolstrip_path)) { + *error = kInvalidToolstripError; + return false; + } + toolstrip_url_ = GetResourceURL(extension_url_, toolstrip_path); + } + if (source.HasKey(kThemeKey)) { DictionaryValue* dict_value; if (source.GetDictionary(kThemeKey, &dict_value)) { diff --git a/chrome/browser/extensions/extension.h b/chrome/browser/extensions/extension.h index 5ca86d3..87290ca 100644 --- a/chrome/browser/extensions/extension.h +++ b/chrome/browser/extensions/extension.h @@ -42,6 +42,7 @@ class Extension { static const wchar_t* kZipHashKey; static const wchar_t* kPluginsDirKey; static const wchar_t* kThemeKey; + static const wchar_t* kToolstripKey; // Some values expected in manifests. static const char* kRunAtDocumentStartValue; @@ -65,6 +66,7 @@ class Extension { static const char* kInvalidVersionError; static const char* kInvalidZipHashError; static const char* kInvalidPluginsDirError; + static const char* kInvalidToolstripError; // The number of bytes in a legal id. static const size_t kIdSize; @@ -85,6 +87,9 @@ class Extension { static FilePath GetResourcePath(const FilePath& extension_path, const std::string& relative_path); + // Initialize the extension from a parsed manifest. + bool InitFromValue(const DictionaryValue& value, std::string* error); + // Returns an absolute path to a resource inside of an extension if the // extension has a theme defined with the given |resource_id|. Otherwise // the path will be empty. Note that this method is not static as it is @@ -92,53 +97,31 @@ class Extension { // as providing a theme. FilePath GetThemeResourcePath(const int resource_id); - // The path to the folder the extension is stored in. const FilePath& path() const { return path_; } - - // The base URL for the extension. const GURL& url() const { return extension_url_; } - - // A human-readable ID for the extension. The convention is to use something - // like 'com.example.myextension', but this is not currently enforced. An - // extension's ID is used in things like directory structures and URLs, and - // is expected to not change across versions. In the case of conflicts, - // updates will only be allowed if the extension can be validated using the - // previous version's update key. const std::string& id() const { return id_; } - - // The version number for the extension. const Version* version() const { return version_.get(); } - // String representation of the version number. const std::string VersionString() const; - - // A human-readable name of the extension. const std::string& name() const { return name_; } - - // An optional longer description of the extension. const std::string& description() const { return description_; } - - // Paths to the content scripts that the extension contains. - const UserScriptList& content_scripts() const { - return content_scripts_; - } - - // Path to the directory of NPAPI plugins that the extension contains. - const FilePath& plugins_dir() const { - return plugins_dir_; - } - - // Initialize the extension from a parsed manifest. - bool InitFromValue(const DictionaryValue& value, std::string* error); + const UserScriptList& content_scripts() const { return content_scripts_; } + const FilePath& plugins_dir() const { return plugins_dir_; } + const GURL& toolstrip_url() const { return toolstrip_url_; } private: - // The path to the directory the extension is stored in. + // The absolute path to the directory the extension is stored in. FilePath path_; // The base extension url for the extension. GURL extension_url_; - // The extension's ID. + // A human-readable ID for the extension. The convention is to use something + // like 'com.example.myextension', but this is not currently enforced. An + // extension's ID is used in things like directory structures and URLs, and + // is expected to not change across versions. In the case of conflicts, + // updates will only be allowed if the extension can be validated using the + // previous version's update key. std::string id_; // The extension's version. @@ -147,15 +130,19 @@ class Extension { // The extension's human-readable name. std::string name_; - // An optional description for the extension. + // An optional longer description of the extension. std::string description_; // Paths to the content scripts the extension contains. UserScriptList content_scripts_; - // Path to the directory of NPAPI plugins that the extension contains. + // Optional absolute path to the directory of NPAPI plugins that the extension + // contains. FilePath plugins_dir_; + // Optional URL of an HTML file to be displayed in the toolbar. + GURL toolstrip_url_; + // A SHA1 hash of the contents of the zip file. Note that this key is only // present in the manifest that's prepended to the zip. The inner manifest // will not have this key. diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc index 883ac3a..6cd9c97b 100755 --- a/chrome/browser/extensions/extension_view.cc +++ b/chrome/browser/extensions/extension_view.cc @@ -8,6 +8,8 @@ ExtensionView::ExtensionView(const GURL& url, Profile* profile) : HWNDHtmlView(url, this, false), profile_(profile) { + // TODO(mpcomplete): query this from the renderer somehow? + set_preferred_size(gfx::Size(100, 100)); } void ExtensionView::CreatingRenderer() { diff --git a/chrome/browser/extensions/extension_view.h b/chrome/browser/extensions/extension_view.h index d95b745..6bb9e7a5 100755 --- a/chrome/browser/extensions/extension_view.h +++ b/chrome/browser/extensions/extension_view.h @@ -42,6 +42,8 @@ class ExtensionView : public HWNDHtmlView, private: Profile* profile_; + + DISALLOW_COPY_AND_ASSIGN(ExtensionView); }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ diff --git a/chrome/browser/extensions/extension_view_unittest.cc b/chrome/browser/extensions/extension_view_unittest.cc index 70ebd90..102b9bb 100755 --- a/chrome/browser/extensions/extension_view_unittest.cc +++ b/chrome/browser/extensions/extension_view_unittest.cc @@ -130,7 +130,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionViewTest, Index) { // Now wait for it to load, and grab a pointer to it. Extension* extension = observer.WaitForExtension(); ASSERT_TRUE(extension); - GURL url = Extension::GetResourceURL(extension->url(), "index.html"); + GURL url = Extension::GetResourceURL(extension->url(), "toolstrip.html"); // Start the extension process and wait for it to show a javascript alert. MockExtensionView view(url, profile); diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 32492cc..1b66bea 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -103,13 +103,6 @@ bool ExtensionsService::Init() { return true; } -void ExtensionsService::LaunchExtensionProcess(Extension* extension) { - // TODO(mpcomplete): Do something useful here. - GURL url = Extension::GetResourceURL(extension->url(), "index.html"); - ExtensionView* view = new ExtensionView(url, profile_); - view->InitHidden(); -} - MessageLoop* ExtensionsService::GetMessageLoop() { return message_loop_; } @@ -136,8 +129,7 @@ void ExtensionsService::LoadExtension(const FilePath& extension_path) { scoped_refptr<ExtensionsServiceFrontendInterface>(this))); } -void ExtensionsService::OnExtensionsLoaded( - ExtensionList* new_extensions) { +void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) { extensions_.insert(extensions_.end(), new_extensions->begin(), new_extensions->end()); diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index 56e0afa..5c08685 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -63,10 +63,6 @@ class ExtensionsService : public ExtensionsServiceFrontendInterface { // Initialize and start all installed extensions. bool Init(); - // Start the extension process for this extension. TODO(mpcomplete): not sure - // how this should actually work yet. - void LaunchExtensionProcess(Extension* extension); - // ExtensionsServiceFrontendInterface virtual MessageLoop* GetMessageLoop(); virtual void InstallExtension(const FilePath& extension_path); |