| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "base/version.h" | 16 #include "base/version.h" |
| 17 #include "chrome/browser/extensions/user_script_master.h" | 17 #include "chrome/browser/extensions/user_script_master.h" |
| 18 #include "chrome/common/extensions/extension_action.h" | 18 #include "chrome/common/extensions/extension_action.h" |
| 19 #include "chrome/common/extensions/extension_message_bundle.h" | 19 #include "chrome/common/extensions/extension_message_bundle.h" |
| 20 #include "chrome/common/extensions/extension_resource.h" | 20 #include "chrome/common/extensions/extension_resource.h" |
| 21 #include "chrome/common/extensions/user_script.h" | 21 #include "chrome/common/extensions/user_script.h" |
| 22 #include "chrome/common/extensions/url_pattern.h" | 22 #include "chrome/common/extensions/url_pattern.h" |
| 23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 24 | 24 |
| 25 // Represents a Chrome extension. | 25 // Represents a Chrome extension. |
| 26 class Extension { | 26 class Extension { |
| 27 public: | 27 public: |
| 28 typedef std::vector<URLPattern> HostPermissions; | 28 typedef std::vector<URLPattern> HostPermissions; |
| 29 typedef std::map<const std::string, GURL> URLOverrideMap; |
| 29 | 30 |
| 30 // What an extension was loaded from. | 31 // What an extension was loaded from. |
| 31 enum Location { | 32 enum Location { |
| 32 INVALID, | 33 INVALID, |
| 33 INTERNAL, // A crx file from the internal Extensions directory. | 34 INTERNAL, // A crx file from the internal Extensions directory. |
| 34 EXTERNAL_PREF, // A crx file from an external directory (via prefs). | 35 EXTERNAL_PREF, // A crx file from an external directory (via prefs). |
| 35 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the | 36 EXTERNAL_REGISTRY, // A crx file from an external directory (via eg the |
| 36 // registry on Windows). | 37 // registry on Windows). |
| 37 LOAD // --load-extension. | 38 LOAD // --load-extension. |
| 38 }; | 39 }; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 248 |
| 248 // Getter/setter for l10n message bundle. | 249 // Getter/setter for l10n message bundle. |
| 249 const ExtensionMessageBundle* message_bundle() const { | 250 const ExtensionMessageBundle* message_bundle() const { |
| 250 return message_bundle_.get(); | 251 return message_bundle_.get(); |
| 251 } | 252 } |
| 252 void set_message_bundle(ExtensionMessageBundle* message_bundle) { | 253 void set_message_bundle(ExtensionMessageBundle* message_bundle) { |
| 253 message_bundle_.reset(message_bundle); | 254 message_bundle_.reset(message_bundle); |
| 254 } | 255 } |
| 255 | 256 |
| 256 // Chrome URL overrides (see ExtensionOverrideUI). | 257 // Chrome URL overrides (see ExtensionOverrideUI). |
| 257 DictionaryValue* GetChromeURLOverrides() const { | 258 const URLOverrideMap& GetChromeURLOverrides() const { |
| 258 return chrome_url_overrides_.get(); | 259 return chrome_url_overrides_; |
| 259 } | 260 } |
| 260 | 261 |
| 261 // Runtime data: | 262 // Runtime data: |
| 262 // Put dynamic data about the state of a running extension below. | 263 // Put dynamic data about the state of a running extension below. |
| 263 | 264 |
| 264 // Whether the background page, if any, is ready. We don't load other | 265 // Whether the background page, if any, is ready. We don't load other |
| 265 // components until then. If there is no background page, we consider it to | 266 // components until then. If there is no background page, we consider it to |
| 266 // be ready. | 267 // be ready. |
| 267 bool GetBackgroundPageReady(); | 268 bool GetBackgroundPageReady(); |
| 268 void SetBackgroundPageReady(); | 269 void SetBackgroundPageReady(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 GURL update_url_; | 370 GURL update_url_; |
| 370 | 371 |
| 371 // A copy of the manifest that this extension was created from. | 372 // A copy of the manifest that this extension was created from. |
| 372 scoped_ptr<DictionaryValue> manifest_value_; | 373 scoped_ptr<DictionaryValue> manifest_value_; |
| 373 | 374 |
| 374 // Handles the l10n messages replacement and parsing. | 375 // Handles the l10n messages replacement and parsing. |
| 375 scoped_ptr<ExtensionMessageBundle> message_bundle_; | 376 scoped_ptr<ExtensionMessageBundle> message_bundle_; |
| 376 | 377 |
| 377 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs | 378 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs |
| 378 // which override the handling of those URLs. | 379 // which override the handling of those URLs. |
| 379 scoped_ptr<DictionaryValue> chrome_url_overrides_; | 380 URLOverrideMap chrome_url_overrides_; |
| 380 | 381 |
| 381 // Runtime data: | 382 // Runtime data: |
| 382 | 383 |
| 383 // True if the background page is ready. | 384 // True if the background page is ready. |
| 384 bool background_page_ready_; | 385 bool background_page_ready_; |
| 385 | 386 |
| 386 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); | 387 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); |
| 387 | 388 |
| 388 DISALLOW_COPY_AND_ASSIGN(Extension); | 389 DISALLOW_COPY_AND_ASSIGN(Extension); |
| 389 }; | 390 }; |
| 390 | 391 |
| 391 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 392 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |