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

Unified Diff: chrome/browser/ui/views/action_box_menu.h

Issue 10533086: Action box menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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/action_box_menu.h
diff --git a/chrome/browser/ui/views/action_box_menu.h b/chrome/browser/ui/views/action_box_menu.h
new file mode 100644
index 0000000000000000000000000000000000000000..1adbd0db293f0354f4afdc9a3b4f258add9b43c8
--- /dev/null
+++ b/chrome/browser/ui/views/action_box_menu.h
@@ -0,0 +1,100 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_
+#define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_
+#pragma once
+
+#include <map>
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/ui/views/browser_actions_host_delegate.h"
+#include "content/public/browser/notification_observer.h"
+#include "ui/base/models/menu_model.h"
+#include "ui/views/controls/menu/menu_delegate.h"
+
+class ActionBoxMenuModel;
+class BrowserActionView;
+
+namespace views {
+class MenuRunner;
+class View;
+}
+
+namespace gfx {
+class Size;
+}
+
+// ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes.
+class ActionBoxMenu
+ : public views::MenuDelegate,
+ public BrowserActionsHostDelegate,
+ public content::NotificationObserver {
+ public:
+ ActionBoxMenu(Browser* browser, ActionBoxMenuModel* model,
+ bool bookmark_item_state);
+ virtual ~ActionBoxMenu();
+
+ void Init();
Aaron Boodman 2012/06/12 05:53:44 Make private.
yefimt 2012/06/13 01:24:21 It is called from ActionBoxButtonView. Potentially
+
+ // Shows the menu relative to the specified view.
+ void RunMenu(views::MenuButton* host);
+
+ // BrowserActionsHostDelegate overrides:
Aaron Boodman 2012/06/12 05:53:44 Make these private.
yefimt 2012/06/13 01:24:21 Done.
+ virtual Browser* GetBrowser() const OVERRIDE;
+ virtual int GetCurrentTabId() const OVERRIDE;
+ virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE;
+ virtual void OnBrowserActionVisibilityChanged() OVERRIDE;
+ virtual gfx::Size GetContentOffset() const OVERRIDE;
+
+ // Overridden from views::DragController:
+ virtual void WriteDragDataForView(views::View* sender,
+ const gfx::Point& press_pt,
+ ui::OSExchangeData* data) OVERRIDE;
+ virtual int GetDragOperationsForView(views::View* sender,
+ const gfx::Point& p) OVERRIDE;
+ virtual bool CanStartDragForView(views::View* sender,
+ const gfx::Point& press_pt,
+ const gfx::Point& p) OVERRIDE;
+
+ // content::NotificationObserver overrides:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ private:
+ views::MenuItemView* AddBookmarkMenuItem(views::MenuItemView* parent,
+ int* index,
+ int* next_id);
+
+ // Populates |parent| with all the child menus in |model|. Recursively invokes
+ // |PopulateMenu| for any submenu. |next_id| is incremented for every menu
+ // that is created.
+ void PopulateMenu(views::MenuItemView* parent,
+ ActionBoxMenuModel* model,
+ int* next_id);
+
+ Browser* browser_;
+
+ // The views menu. Owned by |menu_runner_|.
+ views::MenuItemView* root_;
+
+ scoped_ptr<views::MenuRunner> menu_runner_;
+
+ // The model that tracks the order of the toolbar icons.
+ ActionBoxMenuModel* model_;
+
+ bool bookmark_item_state_;
+
+ int model_index_offset_;
+
+ typedef std::vector<BrowserActionView*> BrowserActionViews;
+ BrowserActionViews browser_action_views_;
+
+ // content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_

Powered by Google App Engine
This is Rietveld 408576698