diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 21:09:56 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 21:09:56 +0000 |
commit | ba69a7db718bd6815e154b36cead5d0e25d9e45e (patch) | |
tree | 57a415ee022130e50bd27e8346fc02f6d2a238cc | |
parent | d55aaa139da94452ebd6812bfa9241ba050978d9 (diff) | |
download | chromium_src-ba69a7db718bd6815e154b36cead5d0e25d9e45e.zip chromium_src-ba69a7db718bd6815e154b36cead5d0e25d9e45e.tar.gz chromium_src-ba69a7db718bd6815e154b36cead5d0e25d9e45e.tar.bz2 |
Moving ContextualAction class to common/extensions and in the process renaming it ExtensionAction.
No code change.
BUG=None
TEST=Page actions and browser actions should work as before (no change)
Review URL: http://codereview.chromium.org/242035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27406 0039d316-1c4b-4281-b951-d872f2087c98
19 files changed, 134 insertions, 134 deletions
diff --git a/chrome/browser/extensions/extension_file_util.cc b/chrome/browser/extensions/extension_file_util.cc index 5c49e05..28a7482 100644 --- a/chrome/browser/extensions/extension_file_util.cc +++ b/chrome/browser/extensions/extension_file_util.cc @@ -212,10 +212,10 @@ bool ValidateExtension(Extension* extension, std::string* error) { } // Validate icon location for page actions. - const ContextualActionMap& page_actions = extension->page_actions(); - for (ContextualActionMap::const_iterator i(page_actions.begin()); + const ExtensionActionMap& page_actions = extension->page_actions(); + for (ExtensionActionMap::const_iterator i(page_actions.begin()); i != page_actions.end(); ++i) { - ContextualAction* page_action = i->second; + ExtensionAction* page_action = i->second; const std::vector<std::string>& icon_paths = page_action->icon_paths(); for (std::vector<std::string>::const_iterator iter = icon_paths.begin(); iter != icon_paths.end(); ++iter) { @@ -228,7 +228,7 @@ bool ValidateExtension(Extension* extension, std::string* error) { } // Validate icon location for browser actions. - const ContextualAction* browser_action = extension->browser_action(); + const ExtensionAction* browser_action = extension->browser_action(); if (browser_action) { const std::vector<std::string>& icon_paths = browser_action->icon_paths(); for (std::vector<std::string>::const_iterator iter = icon_paths.begin(); diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc index 2e9f64d..82fa1c4 100644 --- a/chrome/browser/extensions/extension_page_actions_module.cc +++ b/chrome/browser/extensions/extension_page_actions_module.cc @@ -70,9 +70,9 @@ bool PageActionFunction::SetPageActionEnabled(bool enable) { return false; } - const ContextualAction* page_action = - extension->GetContextualAction(page_action_id, - ContextualAction::PAGE_ACTION); + const ExtensionAction* page_action = + extension->GetExtensionAction(page_action_id, + ExtensionAction::PAGE_ACTION); if (!page_action) { error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoPageActionError, page_action_id); diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index d241360..96e7a25 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -107,7 +107,7 @@ void ExtensionProcessManager::RegisterExtensionProcess( std::vector<std::string> page_action_ids; Extension* extension = extension_service->GetExtensionById(extension_id); - for (ContextualActionMap::const_iterator i = + for (ExtensionActionMap::const_iterator i = extension->page_actions().begin(); i != extension->page_actions().end(); ++i) { page_action_ids.push_back(i->first); diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 04ddba2..1258e849 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -144,12 +144,12 @@ void ExtensionsService::Init() { GarbageCollectExtensions(); } -std::vector<ContextualAction*> ExtensionsService::GetPageActions() const { - return GetContextualActions(ContextualAction::PAGE_ACTION); +std::vector<ExtensionAction*> ExtensionsService::GetPageActions() const { + return GetExtensionActions(ExtensionAction::PAGE_ACTION); } -std::vector<ContextualAction*> ExtensionsService::GetBrowserActions() const { - return GetContextualActions(ContextualAction::BROWSER_ACTION); +std::vector<ExtensionAction*> ExtensionsService::GetBrowserActions() const { + return GetExtensionActions(ExtensionAction::BROWSER_ACTION); } void ExtensionsService::InstallExtension(const FilePath& extension_path) { @@ -324,21 +324,21 @@ void ExtensionsService::LoadInstalledExtension( } } -std::vector<ContextualAction*> ExtensionsService::GetContextualActions( - ContextualAction::ContextualActionType action_type) const { - std::vector<ContextualAction*> result; +std::vector<ExtensionAction*> ExtensionsService::GetExtensionActions( + ExtensionAction::ExtensionActionType action_type) const { + std::vector<ExtensionAction*> result; // TODO(finnur): Sort the icons in some meaningful way. for (ExtensionList::const_iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { - if (action_type == ContextualAction::PAGE_ACTION) { - const ContextualActionMap* page_actions = &(*iter)->page_actions(); - for (ContextualActionMap::const_iterator i(page_actions->begin()); + if (action_type == ExtensionAction::PAGE_ACTION) { + const ExtensionActionMap* page_actions = &(*iter)->page_actions(); + for (ExtensionActionMap::const_iterator i(page_actions->begin()); i != page_actions->end(); ++i) { result.push_back(i->second); } } else { - ContextualAction* browser_action = (*iter)->browser_action(); + ExtensionAction* browser_action = (*iter)->browser_action(); if (browser_action) result.push_back(browser_action); } diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index 12f3416..d683585 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -104,11 +104,11 @@ class ExtensionsService // Retrieves a vector of all page actions, irrespective of which extension // they belong to. - std::vector<ContextualAction*> GetPageActions() const; + std::vector<ExtensionAction*> GetPageActions() const; // Retrieves a vector of all browser actions, irrespective of which extension // they belong to. - std::vector<ContextualAction*> GetBrowserActions() const; + std::vector<ExtensionAction*> GetBrowserActions() const; // Install the extension file at |extension_path|. Will install as an // update if an older version is already installed. @@ -238,8 +238,8 @@ class ExtensionsService // Retrieves a vector of all page actions or browser actions, irrespective of // which extension they belong to. - std::vector<ContextualAction*> GetContextualActions( - ContextualAction::ContextualActionType action_type) const; + std::vector<ExtensionAction*> GetExtensionActions( + ExtensionAction::ExtensionActionType action_type) const; // The profile this ExtensionsService is part of. Profile* profile_; diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index eb32632..3a7544f 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -401,7 +401,7 @@ void LocationBarViewGtk::FocusSearch() { } void LocationBarViewGtk::UpdatePageActions() { - std::vector<ContextualAction*> page_actions; + std::vector<ExtensionAction*> page_actions; if (profile_->GetExtensionsService()) page_actions = profile_->GetExtensionsService()->GetPageActions(); @@ -674,7 +674,7 @@ gboolean LocationBarViewGtk::OnSecurityIconPressed( LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( LocationBarViewGtk* owner, Profile* profile, - const ContextualAction* page_action) + const ExtensionAction* page_action) : owner_(owner), profile_(profile), page_action_(page_action) { @@ -719,7 +719,7 @@ void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( current_tab_id_ = ExtensionTabUtil::GetTabId(contents); current_url_ = url; - const ContextualActionState* state = + const ExtensionActionState* state = contents->GetPageActionState(page_action_); bool visible = state != NULL; if (visible) { diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index c0497add..21d4d75 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -28,7 +28,7 @@ class BubblePositioner; class Browser; class CommandUpdater; class GtkThemeProvider; -class ContextualAction; +class ExtensionAction; class Profile; class SkBitmap; class TabContents; @@ -104,7 +104,7 @@ class LocationBarViewGtk : public AutocompleteEditController, public: PageActionViewGtk( LocationBarViewGtk* owner, Profile* profile, - const ContextualAction* page_action); + const ExtensionAction* page_action); virtual ~PageActionViewGtk(); GtkWidget* widget() { return event_box_.get(); } @@ -129,7 +129,7 @@ class LocationBarViewGtk : public AutocompleteEditController, // The PageAction that this view represents. The PageAction is not owned by // us, it resides in the extension of this particular profile. - const ContextualAction* page_action_; + const ExtensionAction* page_action_; // The icons representing different states for the page action. std::vector<GdkPixbuf*> pixbufs_; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index d36d53f..fab3ccc 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -51,8 +51,8 @@ #include "chrome/browser/search_engines/template_url_fetcher.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension_action.h" #include "chrome/common/notification_service.h" -#include "chrome/common/page_action.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/render_messages.h" @@ -586,7 +586,7 @@ void TabContents::SetIsCrashed(bool state) { NotifyNavigationStateChanged(INVALIDATE_TAB); } -void TabContents::SetPageActionEnabled(const ContextualAction* page_action, +void TabContents::SetPageActionEnabled(const ExtensionAction* page_action, bool enable, const std::string& title, int icon_id) { @@ -599,14 +599,14 @@ void TabContents::SetPageActionEnabled(const ContextualAction* page_action, if (enable) { enabled_page_actions_[page_action].reset( - new ContextualActionState(title, icon_id)); + new ExtensionActionState(title, icon_id)); } else { enabled_page_actions_.erase(page_action); } } -const ContextualActionState* TabContents::GetPageActionState( - const ContextualAction* page_action) { +const ExtensionActionState* TabContents::GetPageActionState( + const ExtensionAction* page_action) { if (enabled_page_actions_.end() == enabled_page_actions_.find(page_action)) return NULL; diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 74669b3..5ce6acb 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -30,10 +30,10 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/page_navigator.h" #include "chrome/browser/tab_contents/render_view_host_manager.h" +#include "chrome/common/extensions/extension_action.h" #include "chrome/common/gears_api.h" #include "chrome/common/navigation_types.h" #include "chrome/common/notification_registrar.h" -#include "chrome/common/page_action.h" #include "chrome/common/property_bag.h" #include "chrome/common/renderer_preferences.h" #include "net/base/load_states.h" @@ -261,15 +261,15 @@ class TabContents : public PageNavigator, // this tab. The parameter |title| (if not empty) can be used to override the // page action title for this tab and |icon_id| specifies an icon index // (defined in the manifest) to use instead of the first icon (for this tab). - void SetPageActionEnabled(const ContextualAction* page_action, bool enable, + void SetPageActionEnabled(const ExtensionAction* page_action, bool enable, const std::string& title, int icon_id); // Returns the page action state for this tab. The pair returns contains // the title (string) for the page action and the icon index to use (int). // If this function returns NULL it means the page action is not enabled for // this tab. - const ContextualActionState* GetPageActionState( - const ContextualAction* page_action); + const ExtensionActionState* GetPageActionState( + const ExtensionAction* page_action); // Whether the tab is in the process of being destroyed. // Added as a tentative work-around for focus related bug #4633. This allows @@ -1106,7 +1106,7 @@ class TabContents : public PageNavigator, // that can be used to override the title and icon used for the page action). // This map is cleared every time the mainframe navigates and populated by the // PageAction extension API. - std::map< const ContextualAction*, linked_ptr<ContextualActionState> > + std::map< const ExtensionAction*, linked_ptr<ExtensionActionState> > enabled_page_actions_; // Data for misc internal state ---------------------------------------------- diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index 52e3531..2499692 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -11,9 +11,9 @@ #include "chrome/browser/image_loading_tracker.h" #include "chrome/browser/profile.h" #include "chrome/browser/views/toolbar_view.h" +#include "chrome/common/extensions/extension_action.h" #include "chrome/common/notification_source.h" #include "chrome/common/notification_type.h" -#include "chrome/common/page_action.h" #include "third_party/skia/include/core/SkBitmap.h" #include "views/controls/button/image_button.h" @@ -27,13 +27,13 @@ static const int kIconHorizontalPadding = 10; // BrowserActionImageView // The BrowserActionImageView is a specialization of the ImageButton class. -// It acts on a ContextualAction, in this case a BrowserAction and handles +// It acts on a ExtensionAction, in this case a BrowserAction and handles // loading the image for the button asynchronously on the file thread to class BrowserActionImageView : public views::ImageButton, public views::ButtonListener, public ImageLoadingTracker::Observer { public: - BrowserActionImageView(ContextualAction* browser_action, + BrowserActionImageView(ExtensionAction* browser_action, Extension* extension, BrowserActionsContainer* panel); ~BrowserActionImageView(); @@ -45,9 +45,9 @@ class BrowserActionImageView : public views::ImageButton, virtual void OnImageLoaded(SkBitmap* image, size_t index); private: - // The browser action this view represents. The ContextualAction is not owned + // The browser action this view represents. The ExtensionAction is not owned // by this class. - ContextualAction* browser_action_; + ExtensionAction* browser_action_; // The icons representing different states for the browser action. std::vector<SkBitmap> browser_action_icons_; @@ -64,7 +64,7 @@ class BrowserActionImageView : public views::ImageButton, }; BrowserActionImageView::BrowserActionImageView( - ContextualAction* browser_action, Extension* extension, + ExtensionAction* browser_action, Extension* extension, BrowserActionsContainer* panel) : ImageButton(this), browser_action_(browser_action), @@ -137,7 +137,7 @@ void BrowserActionsContainer::RefreshBrowserActionViews() { if (!extension_service) // The |extension_service| can be NULL in Incognito. return; - std::vector<ContextualAction*> browser_actions; + std::vector<ExtensionAction*> browser_actions; browser_actions = extension_service->GetBrowserActions(); if (browser_action_views_.size() != browser_actions.size()) { @@ -171,7 +171,7 @@ void BrowserActionsContainer::OnBrowserActionVisibilityChanged() { } void BrowserActionsContainer::OnBrowserActionExecuted( - const ContextualAction& browser_action) { + const ExtensionAction& browser_action) { int window_id = ExtensionTabUtil::GetWindowId(toolbar_->browser()); ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( profile_, browser_action.extension_id(), window_id); diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h index 73d4f13..85b2c6c 100644 --- a/chrome/browser/views/browser_actions_container.h +++ b/chrome/browser/views/browser_actions_container.h @@ -11,7 +11,7 @@ #include "chrome/common/notification_registrar.h" #include "views/view.h" -class ContextualAction; +class ExtensionAction; class Profile; class ToolbarView; namespace views { @@ -41,7 +41,7 @@ class BrowserActionsContainer : public views::View, void OnBrowserActionVisibilityChanged(); // Called when the user clicks on the browser action icon. - void OnBrowserActionExecuted(const ContextualAction& browser_action); + void OnBrowserActionExecuted(const ExtensionAction& browser_action); // Overridden from views::View: virtual gfx::Size GetPreferredSize(); diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index e558dd2..35503a0 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -35,8 +35,8 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/info_bubble.h" +#include "chrome/common/extensions/extension_action.h" #include "chrome/common/extensions/extension.h" -#include "chrome/common/page_action.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "views/focus/focus_manager.h" @@ -644,7 +644,7 @@ void LocationBarView::DeletePageActionViews() { } void LocationBarView::RefreshPageActionViews() { - std::vector<ContextualAction*> page_actions; + std::vector<ExtensionAction*> page_actions; if (profile_->GetExtensionsService()) page_actions = profile_->GetExtensionsService()->GetPageActions(); @@ -1183,7 +1183,7 @@ void LocationBarView::SecurityImageView::ShowInfoBubble() { LocationBarView::PageActionImageView::PageActionImageView( LocationBarView* owner, Profile* profile, - const ContextualAction* page_action, + const ExtensionAction* page_action, const BubblePositioner* bubble_positioner) : LocationBarImageView(bubble_positioner), owner_(owner), @@ -1250,7 +1250,7 @@ void LocationBarView::PageActionImageView::UpdateVisibility( current_tab_id_ = ExtensionTabUtil::GetTabId(contents); current_url_ = url; - const ContextualActionState* state = + const ExtensionActionState* state = contents->GetPageActionState(page_action_); bool visible = state != NULL; if (visible) { diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index 6ab77d7..b315e75 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -347,7 +347,7 @@ class LocationBarView : public LocationBar, public: PageActionImageView(LocationBarView* owner, Profile* profile, - const ContextualAction* page_action, + const ExtensionAction* page_action, const BubblePositioner* bubble_positioner); virtual ~PageActionImageView(); @@ -374,7 +374,7 @@ class LocationBarView : public LocationBar, // The PageAction that this view represents. The PageAction is not owned by // us, it resides in the extension of this particular profile. - const ContextualAction* page_action_; + const ExtensionAction* page_action_; // The icons representing different states for the page action. std::vector<SkBitmap> page_action_icons_; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index dda8b5c..c1d37f6 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -462,6 +462,8 @@ 'common/extensions/extension_error_reporter.h', 'common/extensions/extension_error_utils.cc', 'common/extensions/extension_error_utils.h', + 'common/extensions/extension_action.cc', + 'common/extensions/extension_action.h', 'common/extensions/extension_message_bundle.cc', 'common/extensions/extension_message_bundle.h', 'common/extensions/extension_unpacker.cc', @@ -563,8 +565,6 @@ 'common/notification_type.h', 'common/owned_widget_gtk.cc', 'common/owned_widget_gtk.h', - 'common/page_action.h', - 'common/page_action.cc', 'common/page_transition_types.h', 'common/page_zoom.h', 'common/platform_util.h', diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index d68e91f..8aaefa4 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -149,13 +149,13 @@ GURL Extension::GetResourceURL(const GURL& extension_url, return ret_val; } -const ContextualAction* Extension::GetContextualAction( - std::string id, ContextualAction::ContextualActionType action_type) const { - if (action_type == ContextualAction::BROWSER_ACTION) { +const ExtensionAction* Extension::GetExtensionAction( + std::string id, ExtensionAction::ExtensionActionType action_type) const { + if (action_type == ExtensionAction::BROWSER_ACTION) { DCHECK(id.empty()); // Multiple browser actions are not allowed. return browser_action_.get(); } else { - ContextualActionMap::const_iterator it = page_actions_.find(id); + ExtensionActionMap::const_iterator it = page_actions_.find(id); if (it == page_actions_.end()) return NULL; @@ -313,10 +313,10 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, // Helper method that loads a PageAction or BrowserAction object from a // dictionary in the page_actions list or browser_action key of the manifest. -ContextualAction* Extension::LoadContextualActionHelper( +ExtensionAction* Extension::LoadExtensionActionHelper( const DictionaryValue* page_action, int definition_index, - std::string* error, ContextualAction::ContextualActionType action_type) { - scoped_ptr<ContextualAction> result(new ContextualAction()); + std::string* error, ExtensionAction::ExtensionActionType action_type) { + scoped_ptr<ExtensionAction> result(new ExtensionAction()); result->set_extension_id(id()); result->set_type(action_type); @@ -345,7 +345,7 @@ ContextualAction* Extension::LoadContextualActionHelper( ++icon_count; } - if (action_type == ContextualAction::BROWSER_ACTION) { + if (action_type == ExtensionAction::BROWSER_ACTION) { result->set_id(""); // Not needed (only 1 browser action per extension). } else { // Read the page action |id|. @@ -933,9 +933,9 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id, return false; } - ContextualAction* contextual_action = - LoadContextualActionHelper(page_action_value, i, error, - ContextualAction::PAGE_ACTION); + ExtensionAction* contextual_action = + LoadExtensionActionHelper(page_action_value, i, error, + ExtensionAction::PAGE_ACTION); if (!contextual_action) return false; // Failed to parse page action definition. page_actions_[contextual_action->id()] = contextual_action; @@ -951,8 +951,8 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id, } browser_action_.reset( - LoadContextualActionHelper(browser_action_value, 0, error, - ContextualAction::BROWSER_ACTION)); + LoadExtensionActionHelper(browser_action_value, 0, error, + ExtensionAction::BROWSER_ACTION)); if (!browser_action_.get()) return false; // Failed to parse browser action definition. } @@ -1060,7 +1060,7 @@ std::set<FilePath> Extension::GetBrowserImages() { } // page action icons - for (ContextualActionMap::const_iterator it = page_actions().begin(); + for (ExtensionActionMap::const_iterator it = page_actions().begin(); it != page_actions().end(); ++it) { const std::vector<std::string>& icon_paths = it->second->icon_paths(); for (std::vector<std::string>::const_iterator iter = icon_paths.begin(); diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 6c085ab..af16698 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -15,10 +15,10 @@ #include "base/values.h" #include "base/version.h" #include "chrome/browser/extensions/user_script_master.h" +#include "chrome/common/extensions/extension_action.h" #include "chrome/common/extensions/extension_message_bundle.h" #include "chrome/common/extensions/user_script.h" #include "chrome/common/extensions/url_pattern.h" -#include "chrome/common/page_action.h" #include "googleurl/src/gurl.h" // Represents a Chrome extension. @@ -194,8 +194,8 @@ class Extension { const std::string& public_key() const { return public_key_; } const std::string& description() const { return description_; } const UserScriptList& content_scripts() const { return content_scripts_; } - const ContextualActionMap& page_actions() const { return page_actions_; } - ContextualAction* browser_action() const { return browser_action_.get(); } + const ExtensionActionMap& page_actions() const { return page_actions_; } + ExtensionAction* browser_action() const { return browser_action_.get(); } const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { return privacy_blacklists_; } @@ -227,8 +227,8 @@ class Extension { const std::map<int, std::string>& icons() { return icons_; } // Retrieves a page action or browser action by |id|. - const ContextualAction* GetContextualAction( - std::string id, ContextualAction::ContextualActionType action_type) const; + const ExtensionAction* GetExtensionAction( + std::string id, ExtensionAction::ExtensionActionType action_type) const; // Returns the origin of this extension. This function takes a |registry_path| // so that the registry location can be overwritten during testing. @@ -293,13 +293,13 @@ class Extension { std::string* error, UserScript* result); - // Helper method that loads a ContextualAction object from a + // Helper method that loads a ExtensionAction object from a // dictionary in the page_action or browser_action section of the manifest. - ContextualAction* LoadContextualActionHelper( + ExtensionAction* LoadExtensionActionHelper( const DictionaryValue* contextual_action, int definition_index, std::string* error, - ContextualAction::ContextualActionType action_type); + ExtensionAction::ExtensionActionType action_type); // Figures out if a source contains keys not associated with themes - we // don't want to allow scripts and such to be bundled with themes. @@ -335,10 +335,10 @@ class Extension { UserScriptList content_scripts_; // A list of page actions. - ContextualActionMap page_actions_; + ExtensionActionMap page_actions_; // The extension's browser action, if any. - scoped_ptr<ContextualAction> browser_action_; + scoped_ptr<ExtensionAction> browser_action_; // Optional list of privacy blacklistrom. std::vector<PrivacyBlacklistInfo> privacy_blacklists_; diff --git a/chrome/common/page_action.cc b/chrome/common/extensions/extension_action.cc index f2b6f24..2d3291e 100644 --- a/chrome/common/page_action.cc +++ b/chrome/common/extensions/extension_action.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/page_action.h" +#include "chrome/common/extensions/extension_action.h" -ContextualAction::ContextualAction() +ExtensionAction::ExtensionAction() : type_(PAGE_ACTION) { } -ContextualAction::~ContextualAction() { +ExtensionAction::~ExtensionAction() { } diff --git a/chrome/common/page_action.h b/chrome/common/extensions/extension_action.h index 8594ace..445f98e 100644 --- a/chrome/common/page_action.h +++ b/chrome/common/extensions/extension_action.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_PAGE_ACTION_H_ -#define CHROME_COMMON_PAGE_ACTION_H_ +#ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ +#define CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ #include <map> #include <string> @@ -11,21 +11,21 @@ #include "base/basictypes.h" -class ContextualAction { +class ExtensionAction { public: - ContextualAction(); - virtual ~ContextualAction(); + ExtensionAction(); + virtual ~ExtensionAction(); typedef enum { PAGE_ACTION = 0, BROWSER_ACTION = 1, - } ContextualActionType; + } ExtensionActionType; std::string id() const { return id_; } void set_id(const std::string& id) { id_ = id; } - ContextualActionType type() const { return type_; } - void set_type(ContextualActionType type) { type_ = type; } + ExtensionActionType type() const { return type_; } + void set_type(ExtensionActionType type) { type_ = type; } std::string extension_id() const { return extension_id_; } void set_extension_id(const std::string& extension_id) { @@ -41,31 +41,31 @@ class ContextualAction { } private: - // The id for the ContextualAction, for example: "RssPageAction". + // The id for the ExtensionAction, for example: "RssPageAction". // For BrowserActions this is blank. std::string id_; - // The type of the ContextualAction, either PageAction or BrowserAction. - ContextualActionType type_; + // The type of the ExtensionAction, either PageAction or BrowserAction. + ExtensionActionType type_; - // The id for the extension this ContextualAction belongs to (as defined in + // The id for the extension this ExtensionAction belongs to (as defined in // the extension manifest). std::string extension_id_; - // The name of the ContextualAction. + // The name of the ExtensionAction. std::string name_; // The paths to the icons that this PageIcon can show. std::vector<std::string> icon_paths_; }; -typedef std::map<std::string, ContextualAction*> ContextualActionMap; +typedef std::map<std::string, ExtensionAction*> ExtensionActionMap; // This class keeps track of what values each tab uses to override the default -// values of the ContextualAction. -class ContextualActionState { +// values of the ExtensionAction. +class ExtensionActionState { public: - ContextualActionState(std::string title, int icon_index) + ExtensionActionState(std::string title, int icon_index) : title_(title), icon_index_(icon_index) { } @@ -79,7 +79,7 @@ class ContextualActionState { // The icon to use. int icon_index_; - DISALLOW_COPY_AND_ASSIGN(ContextualActionState); + DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); }; -#endif // CHROME_COMMON_PAGE_ACTION_H_ +#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 6348315..249c719 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -279,24 +279,24 @@ TEST(ExtensionTest, GetResourceURLAndPath) { TEST(ExtensionTest, LoadPageActionHelper) { Extension extension; std::string error_msg; - scoped_ptr<ContextualAction> action; + scoped_ptr<ExtensionAction> action; DictionaryValue input; // First try with an empty dictionary. We should get nothing back. - ASSERT_EQ(NULL, extension.LoadContextualActionHelper( - &input, 0, &error_msg, ContextualAction::PAGE_ACTION)); + ASSERT_EQ(NULL, extension.LoadExtensionActionHelper( + &input, 0, &error_msg, ExtensionAction::PAGE_ACTION)); ASSERT_STRNE("", error_msg.c_str()); error_msg = ""; // Now try the same, but as a browser action. Ensure same results. - ASSERT_EQ(NULL, extension.LoadContextualActionHelper( - &input, 0, &error_msg, ContextualAction::BROWSER_ACTION)); + ASSERT_EQ(NULL, extension.LoadExtensionActionHelper( + &input, 0, &error_msg, ExtensionAction::BROWSER_ACTION)); ASSERT_STRNE("", error_msg.c_str()); error_msg = ""; // Now setup some values to use in the page action. - const std::string id("MyContextualActionId"); - const std::string name("MyContextualActionName"); + const std::string id("MyExtensionActionId"); + const std::string name("MyExtensionActionName"); std::string img1("image1.png"); std::string img2("image2.png"); @@ -309,8 +309,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { input.Set(keys::kPageActionIcons, icons); // Parse as page action and read back the values from the object. - action.reset(extension.LoadContextualActionHelper( - &input, 0, &error_msg, ContextualAction::PAGE_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + &input, 0, &error_msg, ExtensionAction::PAGE_ACTION)); ASSERT_TRUE(NULL != action.get()); ASSERT_STREQ("", error_msg.c_str()); ASSERT_STREQ(id.c_str(), action->id().c_str()); @@ -318,11 +318,11 @@ TEST(ExtensionTest, LoadPageActionHelper) { ASSERT_EQ(2u, action->icon_paths().size()); ASSERT_STREQ(img1.c_str(), action->icon_paths()[0].c_str()); ASSERT_STREQ(img2.c_str(), action->icon_paths()[1].c_str()); - ASSERT_EQ(ContextualAction::PAGE_ACTION, action->type()); + ASSERT_EQ(ExtensionAction::PAGE_ACTION, action->type()); // Now try the same, but as a browser action. - action.reset(extension.LoadContextualActionHelper( - &input, 0, &error_msg, ContextualAction::BROWSER_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + &input, 0, &error_msg, ExtensionAction::BROWSER_ACTION)); ASSERT_TRUE(NULL != action.get()); ASSERT_STREQ("", error_msg.c_str()); // Browser actions don't have an id, page actions do. @@ -331,23 +331,23 @@ TEST(ExtensionTest, LoadPageActionHelper) { ASSERT_EQ(2u, action->icon_paths().size()); ASSERT_STREQ(img1.c_str(), action->icon_paths()[0].c_str()); ASSERT_STREQ(img2.c_str(), action->icon_paths()[1].c_str()); - ASSERT_EQ(ContextualAction::BROWSER_ACTION, action->type()); + ASSERT_EQ(ExtensionAction::BROWSER_ACTION, action->type()); // Explicitly set the same type and parse again. input.SetString(keys::kType, values::kPageActionTypeTab); - action.reset(extension.LoadContextualActionHelper( - &input, 0, &error_msg, ContextualAction::BROWSER_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + &input, 0, &error_msg, ExtensionAction::BROWSER_ACTION)); ASSERT_TRUE(NULL != action.get()); ASSERT_STREQ("", error_msg.c_str()); - ASSERT_EQ(ContextualAction::BROWSER_ACTION, action->type()); + ASSERT_EQ(ExtensionAction::BROWSER_ACTION, action->type()); // Explicitly set the PAGE_ACTION type and parse again. input.SetString(keys::kType, values::kPageActionTypePermanent); - action.reset(extension.LoadContextualActionHelper( - &input, 0, &error_msg, ContextualAction::PAGE_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + &input, 0, &error_msg, ExtensionAction::PAGE_ACTION)); ASSERT_TRUE(NULL != action.get()); ASSERT_STREQ("", error_msg.c_str()); - ASSERT_EQ(ContextualAction::PAGE_ACTION, action->type()); + ASSERT_EQ(ExtensionAction::PAGE_ACTION, action->type()); // Make a deep copy of the input and remove one key at a time and see if we // get the right error. @@ -356,8 +356,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { // First remove id key. copy.reset(static_cast<DictionaryValue*>(input.DeepCopy())); copy->Remove(keys::kPageActionId, NULL); - action.reset(extension.LoadContextualActionHelper( - copy.get(), 0, &error_msg, ContextualAction::PAGE_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + copy.get(), 0, &error_msg, ExtensionAction::PAGE_ACTION)); ASSERT_TRUE(NULL == action.get()); ASSERT_TRUE(MatchPattern(error_msg.c_str(), errors::kInvalidPageActionId)); @@ -366,8 +366,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { // Same test (id key), but with browser action. copy.reset(static_cast<DictionaryValue*>(input.DeepCopy())); copy->Remove(keys::kPageActionId, NULL); - action.reset(extension.LoadContextualActionHelper( - copy.get(), 0, &error_msg, ContextualAction::BROWSER_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + copy.get(), 0, &error_msg, ExtensionAction::BROWSER_ACTION)); // Having no id is valid for browser actions. ASSERT_TRUE(NULL != action.get()); ASSERT_STREQ("", error_msg.c_str()); @@ -376,8 +376,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { // Then remove the name key. copy.reset(static_cast<DictionaryValue*>(input.DeepCopy())); copy->Remove(keys::kName, NULL); - action.reset(extension.LoadContextualActionHelper( - copy.get(), 0, &error_msg, ContextualAction::PAGE_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + copy.get(), 0, &error_msg, ExtensionAction::PAGE_ACTION)); ASSERT_TRUE(NULL == action.get()); ASSERT_TRUE(MatchPattern(error_msg.c_str(), errors::kInvalidName)); @@ -386,8 +386,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { // Same test (name key), but with browser action. copy.reset(static_cast<DictionaryValue*>(input.DeepCopy())); copy->Remove(keys::kName, NULL); - action.reset(extension.LoadContextualActionHelper( - copy.get(), 0, &error_msg, ContextualAction::BROWSER_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + copy.get(), 0, &error_msg, ExtensionAction::BROWSER_ACTION)); ASSERT_TRUE(NULL == action.get()); ASSERT_TRUE(MatchPattern(error_msg.c_str(), errors::kInvalidName)); @@ -396,8 +396,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { // Then remove the icon paths key. copy.reset(static_cast<DictionaryValue*>(input.DeepCopy())); copy->Remove(keys::kPageActionIcons, NULL); - action.reset(extension.LoadContextualActionHelper( - copy.get(), 0, &error_msg, ContextualAction::PAGE_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + copy.get(), 0, &error_msg, ExtensionAction::PAGE_ACTION)); ASSERT_TRUE(NULL == action.get()); ASSERT_TRUE(MatchPattern(error_msg.c_str(), errors::kInvalidPageActionIconPaths)); @@ -406,8 +406,8 @@ TEST(ExtensionTest, LoadPageActionHelper) { // Same test (name key), but with browser action. copy.reset(static_cast<DictionaryValue*>(input.DeepCopy())); copy->Remove(keys::kPageActionIcons, NULL); - action.reset(extension.LoadContextualActionHelper( - copy.get(), 0, &error_msg, ContextualAction::BROWSER_ACTION)); + action.reset(extension.LoadExtensionActionHelper( + copy.get(), 0, &error_msg, ExtensionAction::BROWSER_ACTION)); ASSERT_TRUE(NULL == action.get()); ASSERT_TRUE(MatchPattern(error_msg.c_str(), errors::kInvalidPageActionIconPaths)); |