diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 20:25:01 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 20:25:01 +0000 |
commit | c3a4bd9985658b8a5b229983a3ed85042005f0cf (patch) | |
tree | 6200f270a1063021b79c9d304dfe8a619fe86445 | |
parent | 55a0ffd864ee04c0b76cbed90cb7f00aabed1192 (diff) | |
download | chromium_src-c3a4bd9985658b8a5b229983a3ed85042005f0cf.zip chromium_src-c3a4bd9985658b8a5b229983a3ed85042005f0cf.tar.gz chromium_src-c3a4bd9985658b8a5b229983a3ed85042005f0cf.tar.bz2 |
FBTF: Remove a few SkBitmap instances (and other headers that were next to them).
BUG=none
TEST=compiles
Review URL: http://codereview.chromium.org/3161027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56590 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 159 insertions, 79 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 7fc30ee..ef7731c 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -5,6 +5,7 @@ #include "chrome/browser/autocomplete/search_provider.h" #include <algorithm> +#include <cmath> #include "app/l10n_util.h" #include "base/callback.h" @@ -601,7 +602,8 @@ int SearchProvider::CalculateRelevanceForHistory(const Time& time, // points, while the relevance of a search two weeks ago is discounted about // 450 points. const double elapsed_time = std::max((Time::Now() - time).InSecondsF(), 0.); - const int score_discount = static_cast<int>(6.5 * pow(elapsed_time, 0.3)); + const int score_discount = + static_cast<int>(6.5 * std::pow(elapsed_time, 0.3)); // Don't let scores go below 0. Negative relevance scores are meaningful in // a different way. diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm index 2ad5819..8abafd3 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm @@ -19,6 +19,7 @@ #include "grit/generated_resources.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" +#include "third_party/skia/include/core/SkBitmap.h" namespace { diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar/location_bar_view_mac.h index a573e30..d32bc7a 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.h @@ -20,7 +20,6 @@ #include "chrome/browser/location_bar.h" #include "chrome/browser/toolbar_model.h" #include "chrome/common/content_settings_types.h" -#include "third_party/skia/include/core/SkBitmap.h" @class AutocompleteTextField; class CommandUpdater; @@ -33,6 +32,7 @@ class LocationIconDecoration; class PageActionDecoration; class Profile; class SelectedKeywordDecoration; +class SkBitmap; class StarDecoration; class ToolbarModel; diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm index 1c40542..fd1acb9 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm @@ -51,6 +51,7 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "skia/ext/skia_utils_mac.h" +#include "third_party/skia/include/core/SkBitmap.h" // TODO(shess): This code is mostly copied from the gtk diff --git a/chrome/browser/cocoa/table_row_nsimage_cache.h b/chrome/browser/cocoa/table_row_nsimage_cache.h index 6030208..84dbb69 100644 --- a/chrome/browser/cocoa/table_row_nsimage_cache.h +++ b/chrome/browser/cocoa/table_row_nsimage_cache.h @@ -9,7 +9,8 @@ #import <Cocoa/Cocoa.h> #include "base/scoped_nsobject.h" -#include "third_party/skia/include/core/SkBitmap.h" + +class SkBitmap; // There are several dialogs that display tabular data with one SkBitmap // per row. This class converts these SkBitmaps to NSImages on demand, and diff --git a/chrome/browser/cocoa/table_row_nsimage_cache.mm b/chrome/browser/cocoa/table_row_nsimage_cache.mm index 11d5bb5..ed10af7 100644 --- a/chrome/browser/cocoa/table_row_nsimage_cache.mm +++ b/chrome/browser/cocoa/table_row_nsimage_cache.mm @@ -6,6 +6,7 @@ #include "base/logging.h" #include "skia/ext/skia_utils_mac.h" +#include "third_party/skia/include/core/SkBitmap.h" TableRowNSImageCache::TableRowNSImageCache(Table* model) : model_(model), diff --git a/chrome/browser/cocoa/table_row_nsimage_cache_unittest.mm b/chrome/browser/cocoa/table_row_nsimage_cache_unittest.mm index 271534a..1cc8471 100644 --- a/chrome/browser/cocoa/table_row_nsimage_cache_unittest.mm +++ b/chrome/browser/cocoa/table_row_nsimage_cache_unittest.mm @@ -5,6 +5,7 @@ #include "chrome/browser/cocoa/table_row_nsimage_cache.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/skia/include/core/SkBitmap.h" namespace { diff --git a/chrome/browser/cocoa/task_manager_mac.h b/chrome/browser/cocoa/task_manager_mac.h index 5f87504..b655c41 100644 --- a/chrome/browser/cocoa/task_manager_mac.h +++ b/chrome/browser/cocoa/task_manager_mac.h @@ -14,6 +14,7 @@ #include "chrome/browser/task_manager.h" @class WindowSizeAutosaver; +class SkBitmap; class TaskManagerMac; // This class is responsible for loading the task manager window and for @@ -75,8 +76,8 @@ class TaskManagerMac : public TaskManagerModelObserver, void WindowWasClosed(); // TableRowNSImageCache::Table - virtual int RowCount() const { return model_->ResourceCount(); } - virtual SkBitmap GetIcon(int r) const { return model_->GetResourceIcon(r); } + virtual int RowCount() const; + virtual SkBitmap GetIcon(int r) const; // Creates the task manager if it doesn't exist; otherwise, it activates the // existing task manager window. diff --git a/chrome/browser/cocoa/task_manager_mac.mm b/chrome/browser/cocoa/task_manager_mac.mm index 07cfafca..c977dd9 100644 --- a/chrome/browser/cocoa/task_manager_mac.mm +++ b/chrome/browser/cocoa/task_manager_mac.mm @@ -14,6 +14,7 @@ #import "chrome/browser/cocoa/window_size_autosaver.h" #include "chrome/common/pref_names.h" #include "grit/generated_resources.h" +#include "third_party/skia/include/core/SkBitmap.h" namespace { @@ -535,6 +536,14 @@ void TaskManagerMac::WindowWasClosed() { instance_ = NULL; } +int TaskManagerMac::RowCount() const { + return model_->ResourceCount(); +} + +SkBitmap TaskManagerMac::GetIcon(int r) const { + return model_->GetResourceIcon(r); +} + // static void TaskManagerMac::Show() { if (instance_) { diff --git a/chrome/browser/cocoa/task_manager_mac_unittest.mm b/chrome/browser/cocoa/task_manager_mac_unittest.mm index 570fe7e..a1e6b29 100644 --- a/chrome/browser/cocoa/task_manager_mac_unittest.mm +++ b/chrome/browser/cocoa/task_manager_mac_unittest.mm @@ -12,6 +12,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" #include "testing/platform_test.h" +#include "third_party/skia/include/core/SkBitmap.h" namespace { diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc index 32cb780..e76efb8 100644 --- a/chrome/browser/custom_home_pages_table_model.cc +++ b/chrome/browser/custom_home_pages_table_model.cc @@ -17,9 +17,30 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "gfx/codec/png_codec.h" +#include "googleurl/src/gurl.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "net/base/net_util.h" +#include "third_party/skia/include/core/SkBitmap.h" + +struct CustomHomePagesTableModel::Entry { + Entry() : title_handle(0), fav_icon_handle(0) {} + + // URL of the page. + GURL url; + + // Page title. If this is empty, we'll display the URL as the entry. + std::wstring title; + + // Icon for the page. + SkBitmap icon; + + // If non-zero, indicates we're loading the title for the page. + HistoryService::Handle title_handle; + + // If non-zero, indicates we're loading the favicon for the page. + FaviconService::Handle fav_icon_handle; +}; CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) : default_favicon_(NULL), @@ -29,6 +50,9 @@ CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) default_favicon_ = rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); } +CustomHomePagesTableModel::~CustomHomePagesTableModel() { +} + void CustomHomePagesTableModel::SetURLs(const std::vector<GURL>& urls) { entries_.resize(urls.size()); for (size_t i = 0; i < urls.size(); ++i) { diff --git a/chrome/browser/custom_home_pages_table_model.h b/chrome/browser/custom_home_pages_table_model.h index 639d480..4115daa 100644 --- a/chrome/browser/custom_home_pages_table_model.h +++ b/chrome/browser/custom_home_pages_table_model.h @@ -12,10 +12,10 @@ #include "app/table_model.h" #include "chrome/browser/history/history.h" #include "chrome/browser/favicon_service.h" -#include "googleurl/src/gurl.h" -#include "third_party/skia/include/core/SkBitmap.h" +class GURL; class Profile; +class SkBitmap; class TableModelObserver; // CustomHomePagesTableModel is the model for the TableView showing the list @@ -24,7 +24,7 @@ class TableModelObserver; class CustomHomePagesTableModel : public TableModel { public: explicit CustomHomePagesTableModel(Profile* profile); - virtual ~CustomHomePagesTableModel() {} + virtual ~CustomHomePagesTableModel(); // Sets the set of urls that this model contains. void SetURLs(const std::vector<GURL>& urls); @@ -52,24 +52,7 @@ class CustomHomePagesTableModel : public TableModel { private: // Each item in the model is represented as an Entry. Entry stores the URL, // title, and favicon of the page. - struct Entry { - Entry() : title_handle(0), fav_icon_handle(0) {} - - // URL of the page. - GURL url; - - // Page title. If this is empty, we'll display the URL as the entry. - std::wstring title; - - // Icon for the page. - SkBitmap icon; - - // If non-zero, indicates we're loading the title for the page. - HistoryService::Handle title_handle; - - // If non-zero, indicates we're loading the favicon for the page. - FaviconService::Handle fav_icon_handle; - }; + struct Entry; // Loads the title and favicon for the specified entry. void LoadTitleAndFavIcon(Entry* entry); diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index 063b16d..accb80e 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -133,6 +133,9 @@ ExtensionInstallUI::ExtensionInstallUI(Profile* profile) prompt_type_(NUM_PROMPT_TYPES), ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {} +ExtensionInstallUI::~ExtensionInstallUI() { +} + void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, Extension* extension) { DCHECK(ui_loop_ == MessageLoop::current()); diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index 3c46699..e2d626a 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -52,7 +52,7 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { explicit ExtensionInstallUI(Profile* profile); - virtual ~ExtensionInstallUI() {} + virtual ~ExtensionInstallUI(); // This is called by the installer to verify whether the installation should // proceed. This is declared virtual for testing. diff --git a/chrome/browser/gtk/keyword_editor_view.cc b/chrome/browser/gtk/keyword_editor_view.cc index 6786f45..fa80d23 100644 --- a/chrome/browser/gtk/keyword_editor_view.cc +++ b/chrome/browser/gtk/keyword_editor_view.cc @@ -23,6 +23,7 @@ #include "gfx/gtk_util.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" +#include "third_party/skia/include/core/SkBitmap.h" namespace { diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc index 5298a1d..f2fbfe4 100644 --- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc +++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc @@ -23,6 +23,7 @@ #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "net/base/net_util.h" +#include "third_party/skia/include/core/SkBitmap.h" namespace { diff --git a/chrome/browser/possible_url_model.cc b/chrome/browser/possible_url_model.cc index 44fccf1..0577f4d 100644 --- a/chrome/browser/possible_url_model.cc +++ b/chrome/browser/possible_url_model.cc @@ -6,8 +6,10 @@ #include "app/resource_bundle.h" #include "app/table_model_observer.h" +#include "app/text_elider.h" #include "base/callback.h" #include "base/i18n/rtl.h" +#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/cancelable_request.h" #include "chrome/browser/favicon_service.h" @@ -17,6 +19,7 @@ #include "gfx/codec/png_codec.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" +#include "third_party/skia/include/core/SkBitmap.h" using base::Time; using base::TimeDelta; @@ -31,6 +34,20 @@ const int kPossibleURLTimeScope = 30; } // anonymous namespace +// Contains the data needed to show a result. +struct PossibleURLModel::Result { + Result() : index(0) {} + + GURL url; + // Index of this Result in results_. This is used as the key into + // fav_icon_map_ to lookup the favicon for the url, as well as the index + // into results_ when the favicon is received. + size_t index; + gfx::SortedDisplayURL display_url; + std::wstring title; +}; + + PossibleURLModel::PossibleURLModel() : profile_(NULL), observer_(NULL) { @@ -40,6 +57,9 @@ PossibleURLModel::PossibleURLModel() } } +PossibleURLModel::~PossibleURLModel() { +} + void PossibleURLModel::Reload(Profile *profile) { profile_ = profile; consumer_.CancelAllRequests(); @@ -85,6 +105,10 @@ void PossibleURLModel::OnHistoryQueryComplete(HistoryService::Handle h, observer_->OnModelChanged(); } +int PossibleURLModel::RowCount() { + return static_cast<int>(results_.size()); +} + const GURL& PossibleURLModel::GetURL(int row) { if (row < 0 || row >= RowCount()) { NOTREACHED(); diff --git a/chrome/browser/possible_url_model.h b/chrome/browser/possible_url_model.h index d1afa8c..e586af0 100644 --- a/chrome/browser/possible_url_model.h +++ b/chrome/browser/possible_url_model.h @@ -11,10 +11,9 @@ #include <vector> #include "app/table_model.h" -#include "app/text_elider.h" -#include "base/string_util.h" #include "chrome/browser/history/history.h" -#include "third_party/skia/include/core/SkBitmap.h" + +class SkBitmap; //////////////////////////////////////////////////////////////////////////////// // @@ -26,18 +25,14 @@ class PossibleURLModel : public TableModel { public: PossibleURLModel(); - - virtual ~PossibleURLModel() { - } + virtual ~PossibleURLModel(); void Reload(Profile *profile); void OnHistoryQueryComplete(HistoryService::Handle h, history::QueryResults* result); - virtual int RowCount() { - return static_cast<int>(results_.size()); - } + virtual int RowCount(); const GURL& GetURL(int row); @@ -60,19 +55,6 @@ class PossibleURLModel : public TableModel { } private: - // Contains the data needed to show a result. - struct Result { - Result() : index(0) {} - - GURL url; - // Index of this Result in results_. This is used as the key into - // fav_icon_map_ to lookup the favicon for the url, as well as the index - // into results_ when the favicon is received. - size_t index; - gfx::SortedDisplayURL display_url; - std::wstring title; - }; - // The current profile. Profile* profile_; @@ -83,6 +65,7 @@ class PossibleURLModel : public TableModel { CancelableRequestConsumerT<size_t, NULL> consumer_; // The results we're showing. + struct Result; std::vector<Result> results_; // Map Result::index -> Favicon. diff --git a/chrome/browser/search_engines/template_url_table_model.cc b/chrome/browser/search_engines/template_url_table_model.cc index dede399..2749f33 100644 --- a/chrome/browser/search_engines/template_url_table_model.cc +++ b/chrome/browser/search_engines/template_url_table_model.cc @@ -18,6 +18,7 @@ #include "gfx/codec/png_codec.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" +#include "third_party/skia/include/core/SkBitmap.h" // Group IDs used by TemplateURLTableModel. static const int kMainGroupID = 0; diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index 384128d..63b5da0 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -20,6 +20,7 @@ #include "chrome/common/notification_type.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/password_form.h" //////////////////////////////////////////////////////////////////////////////// @@ -32,6 +33,12 @@ using base::Time; using webkit_glue::FormField; using webkit_glue::PasswordForm; +WDAppImagesResult::WDAppImagesResult() : has_all_images(false) { +} + +WDAppImagesResult::~WDAppImagesResult() { +} + WebDataService::WebDataService() : is_running_(false), db_(NULL), diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index 120fdc4..6aced50 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -15,7 +15,6 @@ #include "base/ref_counted.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/search_engines/template_url.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/form_field.h" class AutofillChange; @@ -25,6 +24,7 @@ class CreditCard; struct IE7PasswordInfo; #endif class MessageLoop; +class SkBitmap; class Task; class WebDatabase; @@ -77,7 +77,8 @@ typedef std::vector<AutofillChange> AutofillChangeList; // Result from GetWebAppImages. struct WDAppImagesResult { - WDAppImagesResult() : has_all_images(false) {} + WDAppImagesResult(); + ~WDAppImagesResult(); // True if SetWebAppHasAllImages(true) was invoked. bool has_all_images; diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc index 17b0baf..81582a1 100644 --- a/chrome/browser/webdata/web_database.cc +++ b/chrome/browser/webdata/web_database.cc @@ -22,7 +22,9 @@ #include "chrome/browser/webdata/autofill_change.h" #include "chrome/common/notification_service.h" #include "gfx/codec/png_codec.h" +#include "webkit/glue/form_field.h" #include "webkit/glue/password_form.h" +#include "third_party/skia/include/core/SkBitmap.h" // Encryptor is now in place for Windows and Mac. The Linux implementation // currently obfuscates only. Mac Encryptor implementation can block the diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h index 1a8d83b8..34b7aa6 100644 --- a/chrome/browser/webdata/web_database.h +++ b/chrome/browser/webdata/web_database.h @@ -14,8 +14,6 @@ #include "base/gtest_prod_util.h" #include "base/scoped_ptr.h" #include "chrome/browser/search_engines/template_url.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "webkit/glue/form_field.h" class AutofillChange; class AutofillEntry; @@ -23,6 +21,7 @@ class AutoFillProfile; class CreditCard; class FilePath; class NotificationService; +class SkBitmap; class WebDatabaseTest; namespace base { @@ -30,6 +29,7 @@ class Time; } namespace webkit_glue { +class FormField; struct PasswordForm; } diff --git a/chrome/common/extensions/extension_action.cc b/chrome/common/extensions/extension_action.cc index e73cf8d..27ba4ec 100644 --- a/chrome/common/extensions/extension_action.cc +++ b/chrome/common/extensions/extension_action.cc @@ -7,10 +7,12 @@ #include <algorithm> #include "app/resource_bundle.h" +#include "base/logging.h" #include "base/utf_string_conversions.h" #include "gfx/canvas_skia.h" #include "gfx/font.h" #include "gfx/rect.h" +#include "googleurl/src/gurl.h" #include "grit/app_resources.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkTypeface.h" @@ -90,6 +92,45 @@ SkPaint* GetTextPaint() { const int ExtensionAction::kDefaultTabId = -1; +ExtensionAction::ExtensionAction() { +} + +ExtensionAction::~ExtensionAction() { +} + +void ExtensionAction::SetPopupUrl(int tab_id, const GURL& url) { + // We store |url| even if it is empty, rather than removing a URL from the + // map. If an extension has a default popup, and removes it for a tab via + // the API, we must remember that there is no popup for that specific tab. + // If we removed the tab's URL, GetPopupURL would incorrectly return the + // default URL. + SetValue(&popup_url_, tab_id, url); +} + +bool ExtensionAction::HasPopup(int tab_id) { + return !GetPopupUrl(tab_id).is_empty(); +} + +GURL ExtensionAction::GetPopupUrl(int tab_id) { + return GetValue(&popup_url_, tab_id); +} + +void ExtensionAction::SetIcon(int tab_id, const SkBitmap& bitmap) { + SetValue(&icon_, tab_id, bitmap); +} + +SkBitmap ExtensionAction::GetIcon(int tab_id) { + return GetValue(&icon_, tab_id); +} + +void ExtensionAction::SetIconIndex(int tab_id, int index) { + if (static_cast<size_t>(index) >= icon_paths_.size()) { + NOTREACHED(); + return; + } + SetValue(&icon_index_, tab_id, index); +} + void ExtensionAction::ClearAllValuesForTab(int tab_id) { title_.erase(tab_id); icon_.erase(tab_id); diff --git a/chrome/common/extensions/extension_action.h b/chrome/common/extensions/extension_action.h index a48de32..3316514 100644 --- a/chrome/common/extensions/extension_action.h +++ b/chrome/common/extensions/extension_action.h @@ -11,10 +11,7 @@ #include <vector> #include "base/basictypes.h" -#include "base/logging.h" #include "base/scoped_ptr.h" -#include "googleurl/src/gurl.h" -#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" namespace gfx { @@ -22,6 +19,9 @@ class Canvas; class Rect; } +class GURL; +class SkBitmap; + // ExtensionAction encapsulates the state of a browser or page action. // Instances can have both global and per-tab state. If a property does not have // a per-tab value, the global value is used instead. @@ -31,6 +31,9 @@ class ExtensionAction { // parameter. static const int kDefaultTabId; + ExtensionAction(); + ~ExtensionAction(); + // extension id std::string extension_id() const { return extension_id_; } void set_extension_id(const std::string& extension_id) { @@ -46,22 +49,13 @@ class ExtensionAction { // Set the url which the popup will load when the user clicks this action's // icon. Setting an empty URL will disable the popup for a given tab. - void SetPopupUrl(int tab_id, const GURL& url) { - // We store |url| even if it is empty, rather than removing a URL from the - // map. If an extension has a default popup, and removes it for a tab via - // the API, we must remember that there is no popup for that specific tab. - // If we removed the tab's URL, GetPopupURL would incorrectly return the - // default URL. - SetValue(&popup_url_, tab_id, url); - } + void SetPopupUrl(int tab_id, const GURL& url); // Use HasPopup() to see if a popup should be displayed. - bool HasPopup(int tab_id) { - return !GetPopupUrl(tab_id).is_empty(); - } + bool HasPopup(int tab_id); // Get the URL to display in a popup. - GURL GetPopupUrl(int tab_id) { return GetValue(&popup_url_, tab_id); } + GURL GetPopupUrl(int tab_id); // Set this action's title on a specific tab. void SetTitle(int tab_id, const std::string& title) { @@ -80,21 +74,15 @@ class ExtensionAction { // for the path. // Set this action's icon bitmap on a specific tab. - void SetIcon(int tab_id, const SkBitmap& bitmap) { - SetValue(&icon_, tab_id, bitmap); - } + void SetIcon(int tab_id, const SkBitmap& bitmap); + // Get the icon for a tab, or the default if no icon was set. - SkBitmap GetIcon(int tab_id) { return GetValue(&icon_, tab_id); } + SkBitmap GetIcon(int tab_id); // Set this action's icon index for a specific tab. For use with // icon_paths(), only used in page actions. - void SetIconIndex(int tab_id, int index) { - if (static_cast<size_t>(index) >= icon_paths_.size()) { - NOTREACHED(); - return; - } - SetValue(&icon_index_, tab_id, index); - } + void SetIconIndex(int tab_id, int index); + // Get this action's icon index for a tab, or the default if no icon index // was set. int GetIconIndex(int tab_id) { diff --git a/chrome/common/extensions/extension_action_unittest.cc b/chrome/common/extensions/extension_action_unittest.cc index 2c5c762..7292ed9 100644 --- a/chrome/common/extensions/extension_action_unittest.cc +++ b/chrome/common/extensions/extension_action_unittest.cc @@ -7,6 +7,7 @@ #include "base/path_service.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension_action.h" +#include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/image_decoder.h" diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 1bed28b..0f8e201 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -25,11 +25,13 @@ #include "chrome/common/json_value_serializer.h" #include "chrome/common/url_constants.h" #include "gfx/codec/png_codec.h" +#include "googleurl/src/gurl.h" #include "net/base/mime_sniffer.h" #include "skia/ext/image_operations.h" #include "chrome/test/ui_test_utils.h" #include "net/base/mock_host_resolver.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/skia/include/core/SkBitmap.h" namespace keys = extension_manifest_keys; namespace values = extension_manifest_values; |