OLD | NEW |
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 #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/common/extensions/extension_extent.h" | 17 #include "chrome/common/extensions/extension_extent.h" |
18 #include "chrome/common/extensions/user_script.h" | 18 #include "chrome/common/extensions/user_script.h" |
19 #include "chrome/common/extensions/url_pattern.h" | 19 #include "chrome/common/extensions/url_pattern.h" |
| 20 #include "gfx/size.h" |
20 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
21 #include "testing/gtest/include/gtest/gtest_prod.h" | 22 #include "testing/gtest/include/gtest/gtest_prod.h" |
22 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
23 | 24 |
24 class ExtensionAction; | 25 class ExtensionAction; |
25 class ExtensionResource; | 26 class ExtensionResource; |
26 | 27 |
27 // Represents a Chrome extension. | 28 // Represents a Chrome extension. |
28 class Extension { | 29 class Extension { |
29 public: | 30 public: |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // be ready. | 348 // be ready. |
348 bool GetBackgroundPageReady(); | 349 bool GetBackgroundPageReady(); |
349 void SetBackgroundPageReady(); | 350 void SetBackgroundPageReady(); |
350 | 351 |
351 // Getter and setter for the flag that specifies whether the extension is | 352 // Getter and setter for the flag that specifies whether the extension is |
352 // being upgraded. | 353 // being upgraded. |
353 bool being_upgraded() const { return being_upgraded_; } | 354 bool being_upgraded() const { return being_upgraded_; } |
354 void set_being_upgraded(bool value) { being_upgraded_ = value; } | 355 void set_being_upgraded(bool value) { being_upgraded_ = value; } |
355 | 356 |
356 // Image cache related methods. These are only valid on the UI thread and | 357 // Image cache related methods. These are only valid on the UI thread and |
357 // not maintained by this class. See ImageLoadingTracker for usage. | 358 // not maintained by this class. See ImageLoadingTracker for usage. The |
| 359 // |original_size| parameter should be the size of the image at |source| |
| 360 // before any scaling may have been done to produce the pixels in |image|. |
358 void SetCachedImage(const ExtensionResource& source, | 361 void SetCachedImage(const ExtensionResource& source, |
359 const SkBitmap& image); | 362 const SkBitmap& image, |
360 bool HasCachedImage(const ExtensionResource& source); | 363 const gfx::Size& original_size); |
361 SkBitmap GetCachedImage(const ExtensionResource& source); | 364 bool HasCachedImage(const ExtensionResource& source, |
| 365 const gfx::Size& max_size); |
| 366 SkBitmap GetCachedImage(const ExtensionResource& source, |
| 367 const gfx::Size& max_size); |
362 | 368 |
363 private: | 369 private: |
364 typedef std::map<FilePath, SkBitmap> ImageCache; | 370 // We keep a cache of images loaded from extension resources based on their |
| 371 // path and a string representation of a size that may have been used to |
| 372 // scale it (or the empty string if the image is at its original size). |
| 373 typedef std::pair<FilePath, std::string> ImageCacheKey; |
| 374 typedef std::map<ImageCacheKey, SkBitmap> ImageCache; |
| 375 |
| 376 // Helper function for implementing HasCachedImage/GetCachedImage. A return |
| 377 // value of NULL means there is no matching image cached (we allow caching an |
| 378 // empty SkBitmap). |
| 379 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, |
| 380 const gfx::Size& max_size); |
365 | 381 |
366 // Helper method that loads a UserScript object from a | 382 // Helper method that loads a UserScript object from a |
367 // dictionary in the content_script list of the manifest. | 383 // dictionary in the content_script list of the manifest. |
368 bool LoadUserScriptHelper(const DictionaryValue* content_script, | 384 bool LoadUserScriptHelper(const DictionaryValue* content_script, |
369 int definition_index, | 385 int definition_index, |
370 std::string* error, | 386 std::string* error, |
371 UserScript* result); | 387 UserScript* result); |
372 | 388 |
373 // Helper method that loads either the include_globs or exclude_globs list | 389 // Helper method that loads either the include_globs or exclude_globs list |
374 // from an entry in the content_script lists of the manifest. | 390 // from an entry in the content_script lists of the manifest. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 LaunchContainer launch_container_; | 534 LaunchContainer launch_container_; |
519 | 535 |
520 // Launch full screen by default. | 536 // Launch full screen by default. |
521 bool launch_fullscreen_; | 537 bool launch_fullscreen_; |
522 | 538 |
523 // The default size of the container when launching. Only respected for | 539 // The default size of the container when launching. Only respected for |
524 // containers like panels and windows. | 540 // containers like panels and windows. |
525 int launch_width_; | 541 int launch_width_; |
526 int launch_height_; | 542 int launch_height_; |
527 | 543 |
528 // Cached images for this extension. This maps from the relative_path of the | 544 // Cached images for this extension. |
529 // resource to the cached image. | |
530 ImageCache image_cache_; | 545 ImageCache image_cache_; |
531 | 546 |
532 // The omnibox keyword for this extension, or empty if there is none. | 547 // The omnibox keyword for this extension, or empty if there is none. |
533 std::string omnibox_keyword_; | 548 std::string omnibox_keyword_; |
534 | 549 |
535 // Runtime data: | 550 // Runtime data: |
536 | 551 |
537 // True if the background page is ready. | 552 // True if the background page is ready. |
538 bool background_page_ready_; | 553 bool background_page_ready_; |
539 | 554 |
(...skipping 26 matching lines...) Expand all Loading... |
566 scoped_ptr<DictionaryValue> extension_manifest; | 581 scoped_ptr<DictionaryValue> extension_manifest; |
567 std::string extension_id; | 582 std::string extension_id; |
568 FilePath extension_path; | 583 FilePath extension_path; |
569 Extension::Location extension_location; | 584 Extension::Location extension_location; |
570 | 585 |
571 private: | 586 private: |
572 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo); | 587 DISALLOW_COPY_AND_ASSIGN(ExtensionInfo); |
573 }; | 588 }; |
574 | 589 |
575 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 590 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
OLD | NEW |