Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: chrome/browser/ui/views/location_bar/page_action_image_view.h

Issue 431173002: Create ExtensionActionView class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/page_action_image_view.h
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.h b/chrome/browser/ui/views/location_bar/page_action_image_view.h
index 0d1a5e0f6923bb68144e9f8796788788c9aa6b53..b83af4c908cee3cb7906203edb1c779df375b967 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.h
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.h
@@ -5,48 +5,39 @@
#ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_
-#include <map>
#include <string>
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/extensions/extension_action.h"
-#include "chrome/browser/extensions/extension_action_icon_factory.h"
-#include "chrome/browser/extensions/extension_context_menu_model.h"
-#include "chrome/browser/ui/views/extensions/extension_popup.h"
-#include "ui/views/context_menu_controller.h"
+#include "chrome/browser/ui/views/extensions/extension_action_view.h"
#include "ui/views/controls/image_view.h"
-#include "ui/views/widget/widget_observer.h"
class Browser;
+class ExtensionAction;
class LocationBarView;
namespace content {
class WebContents;
}
-namespace views {
-class MenuRunner;
-}
// PageActionImageView is used by the LocationBarView to display the icon for a
// given PageAction and notify the extension when the icon is clicked.
-class PageActionImageView : public views::ImageView,
- public ExtensionContextMenuModel::PopupDelegate,
- public views::WidgetObserver,
- public views::ContextMenuController,
- public ExtensionActionIconFactory::Observer {
+class PageActionImageView : public ExtensionActionView::ViewDelegate,
+ public views::ImageView {
public:
PageActionImageView(LocationBarView* owner,
ExtensionAction* page_action,
Browser* browser);
virtual ~PageActionImageView();
- ExtensionAction* page_action() { return page_action_; }
-
- int current_tab_id() { return current_tab_id_; }
-
void set_preview_enabled(bool preview_enabled) {
preview_enabled_ = preview_enabled;
}
+ ExtensionAction* extension_action() {
+ return extension_action_view_->extension_action();
+ }
+ ExtensionActionView* extension_action_view() {
+ return extension_action_view_.get();
+ }
// Overridden from views::View:
virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
@@ -54,66 +45,35 @@ class PageActionImageView : public views::ImageView,
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
- // Overridden from ExtensionContextMenuModel::Delegate
- virtual void InspectPopup() OVERRIDE;
-
- // Overridden from views::WidgetObserver:
- virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
-
- // Overridden from views::ContextMenuController.
- virtual void ShowContextMenuForView(View* source,
- const gfx::Point& point,
- ui::MenuSourceType source_type) OVERRIDE;
-
- // Overriden from ExtensionActionIconFactory::Observer.
- virtual void OnIconUpdated() OVERRIDE;
-
// Overridden from ui::AcceleratorTarget:
sky 2014/08/05 22:29:47 Should ExtensionActionView by the AcceleratorTarge
Devlin 2014/08/05 23:51:10 I thought about it, but for some reason thought it
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual bool CanHandleAccelerators() const OVERRIDE;
// Called to notify the PageAction that it should determine whether to be
- // visible or hidden. |contents| is the WebContents that is active, |url| is
- // the current page URL.
- void UpdateVisibility(content::WebContents* contents, const GURL& url);
-
- // Either notify listeners or show a popup depending on the page action.
- void ExecuteAction(ExtensionPopup::ShowAction show_action);
+ // visible or hidden. |contents| is the WebContents that is active.
+ void UpdateVisibility(content::WebContents* contents);
private:
// Overridden from View.
virtual void PaintChildren(gfx::Canvas* canvas,
const views::CullSet& cull_set) OVERRIDE;
- // Shows the popup, with the given URL.
- void ShowPopupWithURL(const GURL& popup_url,
- ExtensionPopup::ShowAction show_action);
+ // Overridden from ExtensionActionView::ViewDelegate
+ virtual void OnIconUpdated() OVERRIDE;
+ virtual views::View* GetAsView() OVERRIDE;
+ virtual bool IsNestedView() OVERRIDE;
+ virtual views::FocusManager* GetFocusManagerForAccelerator() OVERRIDE;
+ virtual views::Widget* GetParentForContextMenu() OVERRIDE;
+ virtual views::View* GetReferenceViewForPopup() OVERRIDE;
+ virtual content::WebContents* GetCurrentWebContents() OVERRIDE;
+ virtual void HideActivePopup() OVERRIDE;
- // Hides the active popup, if there is one.
- void HidePopup();
+ // The ExtensionActionView implementation.
+ scoped_ptr<ExtensionActionView> extension_action_view_;
// The location bar view that owns us.
LocationBarView* owner_;
- // The PageAction that this view represents. The PageAction is not owned by
- // us, it resides in the extension of this particular profile.
- ExtensionAction* page_action_;
-
- // The corresponding browser.
- Browser* browser_;
-
- // The object that will be used to get the page action icon for us.
- // It may load the icon asynchronously (in which case the initial icon
- // returned by the factory will be transparent), so we have to observe it for
- // updates to the icon.
- scoped_ptr<ExtensionActionIconFactory> icon_factory_;
-
- // The tab id we are currently showing the icon for.
- int current_tab_id_;
-
- // The URL we are currently showing the icon for.
- GURL current_url_;
-
// The string to show for a tooltip;
std::string tooltip_;
@@ -121,15 +81,6 @@ class PageActionImageView : public views::ImageView,
// briefly shown even if it hasn't been enabled by its extension.
bool preview_enabled_;
- // The current popup and the button it came from. NULL if no popup.
- ExtensionPopup* popup_;
-
- // The extension command accelerator this page action is listening for (to
- // show the popup).
- scoped_ptr<ui::Accelerator> page_action_keybinding_;
-
- scoped_ptr<views::MenuRunner> menu_runner_;
-
DISALLOW_IMPLICIT_CONSTRUCTORS(PageActionImageView);
};

Powered by Google App Engine
This is Rietveld 408576698