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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_frame_view.h

Issue 6975062: Update Panel UI looks on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
12 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" 13 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
13 #include "chrome/browser/ui/views/tab_icon_view.h" 14 #include "chrome/browser/ui/views/tab_icon_view.h"
15 #include "ui/base/models/simple_menu_model.h"
14 #include "views/controls/button/button.h" 16 #include "views/controls/button/button.h"
17 #include "views/controls/menu/view_menu_delegate.h"
15 18
19 class Extension;
16 class PanelBrowserView; 20 class PanelBrowserView;
17 namespace views { 21 namespace views {
18 class ImageButton; 22 class ImageButton;
19 class Label; 23 class Label;
24 class Menu2;
25 class MenuButton;
20 } 26 }
21 27
22 class PanelBrowserFrameView : public BrowserNonClientFrameView, 28 class PanelBrowserFrameView : public BrowserNonClientFrameView,
23 public views::ButtonListener, 29 public views::ButtonListener,
24 public TabIconView::TabIconViewModel { 30 public views::ViewMenuDelegate,
31 public ui::SimpleMenuModel::Delegate,
32 public TabIconView::TabIconViewModel,
33 public ExtensionUninstallDialog::Delegate {
25 public: 34 public:
26 PanelBrowserFrameView(BrowserFrame* frame, PanelBrowserView* browser_view); 35 PanelBrowserFrameView(BrowserFrame* frame, PanelBrowserView* browser_view);
27 virtual ~PanelBrowserFrameView(); 36 virtual ~PanelBrowserFrameView();
28 37
29 void UpdateTitleBar(); 38 void UpdateTitleBar();
30 void OnActivationChanged(bool active); 39 void OnActivationChanged(bool active);
31 40
32 protected: 41 protected:
33 // Overridden from BrowserNonClientFrameView: 42 // Overridden from BrowserNonClientFrameView:
34 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 43 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
(...skipping 18 matching lines...) Expand all
53 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 62 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
54 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; 63 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
55 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; 64 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
56 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; 65 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
57 virtual void OnMouseCaptureLost() OVERRIDE; 66 virtual void OnMouseCaptureLost() OVERRIDE;
58 67
59 // Overridden from views::ButtonListener: 68 // Overridden from views::ButtonListener:
60 virtual void ButtonPressed(views::Button* sender, const views::Event& event) 69 virtual void ButtonPressed(views::Button* sender, const views::Event& event)
61 OVERRIDE; 70 OVERRIDE;
62 71
72 // Overridden from views::ViewMenuDelegate:
73 virtual void RunMenu(View* source, const gfx::Point& pt) OVERRIDE;
74
75 // Overridden from ui::SimpleMenuModel::Delegate:
76 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
77 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
78 virtual bool GetAcceleratorForCommandId(
79 int command_id, ui::Accelerator* accelerator) OVERRIDE;
80 virtual void ExecuteCommand(int command_id) OVERRIDE;
81
63 // Overridden from TabIconView::TabIconViewModel: 82 // Overridden from TabIconView::TabIconViewModel:
64 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; 83 virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
65 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE; 84 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE;
66 85
86 // ExtensionUninstallDialog::Delegate:
87 virtual void ExtensionDialogAccepted() OVERRIDE;
88 virtual void ExtensionDialogCanceled() OVERRIDE;
89
67 private: 90 private:
68 friend class PanelBrowserViewTest; 91 friend class PanelBrowserViewTest;
69 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreatePanel); 92 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreatePanel);
70 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, ShowOrHideInfoButton); 93 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, ShowOrHideSettingsButton);
71 94
72 enum PaintState { 95 enum PaintState {
73 NOT_PAINTED, 96 NOT_PAINTED,
74 PAINT_AS_INACTIVE, 97 PAINT_AS_INACTIVE,
75 PAINT_AS_ACTIVE 98 PAINT_AS_ACTIVE
76 }; 99 };
77 100
101 enum {
102 COMMAND_NAME = 0,
103 COMMAND_CONFIGURE,
104 COMMAND_DISABLE,
105 COMMAND_UNINSTALL,
106 COMMAND_MANAGE
107 };
108
78 class MouseWatcher : public MessageLoopForUI::Observer { 109 class MouseWatcher : public MessageLoopForUI::Observer {
79 public: 110 public:
80 explicit MouseWatcher(PanelBrowserFrameView* view); 111 explicit MouseWatcher(PanelBrowserFrameView* view);
81 virtual ~MouseWatcher(); 112 virtual ~MouseWatcher();
82 113
83 virtual bool IsCursorInViewBounds() const; 114 virtual bool IsCursorInViewBounds() const;
84 115
85 #if defined(OS_WIN) 116 #if defined(OS_WIN)
86 virtual void WillProcessMessage(const MSG& msg) OVERRIDE { } 117 virtual void WillProcessMessage(const MSG& msg) OVERRIDE { }
87 virtual void DidProcessMessage(const MSG& msg) OVERRIDE; 118 virtual void DidProcessMessage(const MSG& msg) OVERRIDE;
(...skipping 22 matching lines...) Expand all
110 // Update control styles to indicate if the title bar is active or not. 141 // Update control styles to indicate if the title bar is active or not.
111 void UpdateControlStyles(PaintState paint_state); 142 void UpdateControlStyles(PaintState paint_state);
112 143
113 // Custom draw the frame. 144 // Custom draw the frame.
114 void PaintFrameBorder(gfx::Canvas* canvas); 145 void PaintFrameBorder(gfx::Canvas* canvas);
115 void PaintClientEdge(gfx::Canvas* canvas); 146 void PaintClientEdge(gfx::Canvas* canvas);
116 147
117 // Called by MouseWatcher to notify if the mouse enters or leaves the window. 148 // Called by MouseWatcher to notify if the mouse enters or leaves the window.
118 void OnMouseEnterOrLeaveWindow(bool mouse_entered); 149 void OnMouseEnterOrLeaveWindow(bool mouse_entered);
119 150
120 // Make info button visible if either of the conditions is met: 151 // Make settings button visible if either of the conditions is met:
121 // 1) The panel is active, i.e. having focus. 152 // 1) The panel is active, i.e. having focus.
122 // 2) The mouse is over the panel. 153 // 2) The mouse is over the panel.
123 void UpdateInfoButtonVisibility(bool active, bool cursor_in_view); 154 void UpdateSettingsButtonVisibility(bool active, bool cursor_in_view);
155
156 const Extension* GetExtension() const;
157
158 void EnsureCreateSettingsMenu();
124 159
125 #ifdef UNIT_TEST 160 #ifdef UNIT_TEST
126 void set_mouse_watcher(MouseWatcher* mouse_watcher) { 161 void set_mouse_watcher(MouseWatcher* mouse_watcher) {
127 mouse_watcher_.reset(mouse_watcher); 162 mouse_watcher_.reset(mouse_watcher);
128 } 163 }
129 #endif 164 #endif
130 165
131 // The frame that hosts this view. This is a weak reference such that frame_ 166 // The frame that hosts this view. This is a weak reference such that frame_
132 // will always be valid in the lifetime of this view. 167 // will always be valid in the lifetime of this view.
133 BrowserFrame* frame_; 168 BrowserFrame* frame_;
134 169
135 // The client view hosted within this non-client frame view that is 170 // The client view hosted within this non-client frame view that is
136 // guaranteed to be freed before the client view. 171 // guaranteed to be freed before the client view.
137 // (see comments about view hierarchies in non_client_view.h) 172 // (see comments about view hierarchies in non_client_view.h)
138 PanelBrowserView* browser_view_; 173 PanelBrowserView* browser_view_;
139 174
140 PaintState paint_state_; 175 PaintState paint_state_;
141 views::ImageButton* info_button_; 176 views::MenuButton* settings_button_;
142 views::ImageButton* close_button_; 177 views::ImageButton* close_button_;
143 TabIconView* title_icon_; 178 TabIconView* title_icon_;
144 views::Label* title_label_; 179 views::Label* title_label_;
145 gfx::Rect client_view_bounds_; 180 gfx::Rect client_view_bounds_;
146 scoped_ptr<MouseWatcher> mouse_watcher_; 181 scoped_ptr<MouseWatcher> mouse_watcher_;
182 scoped_ptr<views::Menu2> settings_menu_;
183 scoped_ptr<ui::SimpleMenuModel> settings_menu_contents_;
184 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
147 185
148 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); 186 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView);
149 }; 187 };
150 188
151 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ 189 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698