From 671e6c1cecf01e46dc0267e020971aa0f98de0a2 Mon Sep 17 00:00:00 2001 From: "finnur@chromium.org" Date: Sat, 26 Sep 2009 03:18:46 +0000 Subject: Implement Browser Actions extensions. Browser Actions are like Page Actions, except they appear next to the Omnibox and are always visible. For details see http://code.google.com/p/chromium/wiki/BrowserActions. Added a simple browser action sample that adds a Print button to the chrome toolbar (which brings up the Print dialog for the current page). Removed |type| from PageActions, which is currently ignored and was already removed from the docs. Each extension can only have 1 browser_action. Each browser action can specify more than one icon, but only the first is used. And no API has been added yet (besides the event definition). BUG=22099 TEST=Install the sample browser action, navigate to google.com, press the print button. A print dialog should come up. Review URL: http://codereview.chromium.org/243001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27319 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/gtk/location_bar_view_gtk.cc | 12 +++++++----- chrome/browser/gtk/location_bar_view_gtk.h | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'chrome/browser/gtk') diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index 2d0fa41..eb32632 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -401,14 +401,14 @@ void LocationBarViewGtk::FocusSearch() { } void LocationBarViewGtk::UpdatePageActions() { - std::vector page_actions; + std::vector page_actions; if (profile_->GetExtensionsService()) page_actions = profile_->GetExtensionsService()->GetPageActions(); // Initialize on the first call, or re-inialize if more extensions have been // loaded or added after startup. if (page_actions.size() != page_action_views_.size()) { - page_action_views_.reset(); // Delete the old views (if any). + page_action_views_.reset(); // Delete the old views (if any). for (size_t i = 0; i < page_actions.size(); ++i) { page_action_views_.push_back( @@ -673,7 +673,8 @@ gboolean LocationBarViewGtk::OnSecurityIconPressed( // LocationBarViewGtk::PageActionViewGtk LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( - LocationBarViewGtk* owner, Profile* profile, const PageAction* page_action) + LocationBarViewGtk* owner, Profile* profile, + const ContextualAction* page_action) : owner_(owner), profile_(profile), page_action_(page_action) { @@ -705,7 +706,7 @@ LocationBarViewGtk::PageActionViewGtk::~PageActionViewGtk() { tracker_->StopTrackingImageLoad(); image_.Destroy(); event_box_.Destroy(); - for (size_t i=0; i < pixbufs_.size(); ++i) { + for (size_t i = 0; i < pixbufs_.size(); ++i) { if (pixbufs_[i]) g_object_unref(pixbufs_[i]); } @@ -718,7 +719,8 @@ void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( current_tab_id_ = ExtensionTabUtil::GetTabId(contents); current_url_ = url; - const PageActionState* state = contents->GetPageActionState(page_action_); + const ContextualActionState* state = + contents->GetPageActionState(page_action_); bool visible = state != NULL; if (visible) { // Set the tooltip. diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index 541126e..c0497add 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 PageAction; +class ContextualAction; class Profile; class SkBitmap; class TabContents; @@ -104,7 +104,7 @@ class LocationBarViewGtk : public AutocompleteEditController, public: PageActionViewGtk( LocationBarViewGtk* owner, Profile* profile, - const PageAction* page_action); + const ContextualAction* 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 PageAction* page_action_; + const ContextualAction* page_action_; // The icons representing different states for the page action. std::vector pixbufs_; -- cgit v1.1