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

Side by Side Diff: chrome/browser/views/extensions/extension_shelf.h

Issue 204022: ExtensionShelf now uses the BookmarkExtensionBackground, just like the Bookma... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_ 5 #ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_
6 #define CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_ 6 #define CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_
7 7
8 #include "app/gfx/canvas.h" 8 #include "app/gfx/canvas.h"
9 #include "app/slide_animation.h" 9 #include "app/slide_animation.h"
10 #include "base/task.h" 10 #include "base/task.h"
11 #include "chrome/browser/extensions/extension_shelf_model.h" 11 #include "chrome/browser/extensions/extension_shelf_model.h"
12 #include "chrome/browser/extensions/extensions_service.h" 12 #include "chrome/browser/extensions/extensions_service.h"
13 #include "chrome/browser/views/browser_bubble.h" 13 #include "chrome/browser/views/browser_bubble.h"
14 #include "chrome/browser/views/detachable_toolbar_view.h"
14 #include "views/view.h" 15 #include "views/view.h"
15 16
16 class Browser; 17 class Browser;
17 namespace views { 18 namespace views {
18 class Label; 19 class Label;
19 class MouseEvent; 20 class MouseEvent;
20 } 21 }
21 22
22 // A shelf that contains Extension toolstrips. 23 // A shelf that contains Extension toolstrips.
23 class ExtensionShelf : public views::View, 24 class ExtensionShelf : public DetachableToolbarView,
24 public ExtensionContainer, 25 public ExtensionContainer,
25 public ExtensionShelfModelObserver, 26 public ExtensionShelfModelObserver,
26 public AnimationDelegate, 27 public AnimationDelegate,
27 public NotificationObserver { 28 public NotificationObserver {
28 public: 29 public:
29 explicit ExtensionShelf(Browser* browser); 30 explicit ExtensionShelf(Browser* browser);
30 virtual ~ExtensionShelf(); 31 virtual ~ExtensionShelf();
31 32
32 // Get the current model. 33 // Get the current model.
33 ExtensionShelfModel* model() { return model_; } 34 ExtensionShelfModel* model() { return model_; }
34 35
35 // Returns whether the extension shelf is detached from the Chrome frame.
36 bool IsDetachedStyle();
37
38 // Toggles a preference for whether to always show the extension shelf. 36 // Toggles a preference for whether to always show the extension shelf.
39 static void ToggleWhenExtensionShelfVisible(Profile* profile); 37 static void ToggleWhenExtensionShelfVisible(Profile* profile);
40 38
41 // View 39 // DetachableToolbarView methods:
42 virtual void Paint(gfx::Canvas* canvas); 40 virtual bool IsOnTop() const;
41 virtual bool IsDetached() const;
42 virtual double GetAnimationValue() const {
43 return size_animation_->GetCurrentValue();
44 }
45
46 // View methods:
47 virtual void PaintChildren(gfx::Canvas* canvas);
43 virtual gfx::Size GetPreferredSize(); 48 virtual gfx::Size GetPreferredSize();
44 virtual void Layout(); 49 virtual void Layout();
45 virtual void OnMouseExited(const views::MouseEvent& event); 50 virtual void OnMouseExited(const views::MouseEvent& event);
46 virtual void OnMouseEntered(const views::MouseEvent& event); 51 virtual void OnMouseEntered(const views::MouseEvent& event);
47 virtual bool GetAccessibleName(std::wstring* name); 52 virtual bool GetAccessibleName(std::wstring* name);
48 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); 53 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
49 virtual void SetAccessibleName(const std::wstring& name); 54 virtual void SetAccessibleName(const std::wstring& name);
55 virtual void ThemeChanged();
50 56
51 // ExtensionContainer 57 // ExtensionContainer methods:
52 virtual void OnExtensionMouseEvent(ExtensionView* view); 58 virtual void OnExtensionMouseEvent(ExtensionView* view);
53 virtual void OnExtensionMouseLeave(ExtensionView* view); 59 virtual void OnExtensionMouseLeave(ExtensionView* view);
54 60
55 // ExtensionShelfModelObserver 61 // ExtensionShelfModelObserver methods:
56 virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index); 62 virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index);
57 virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index); 63 virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index);
58 virtual void ToolstripDraggingFrom(ExtensionHost* toolstrip, int index); 64 virtual void ToolstripDraggingFrom(ExtensionHost* toolstrip, int index);
59 virtual void ToolstripMoved(ExtensionHost* toolstrip, 65 virtual void ToolstripMoved(ExtensionHost* toolstrip,
60 int from_index, 66 int from_index,
61 int to_index); 67 int to_index);
62 virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip); 68 virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip);
63 virtual void ExtensionShelfEmpty(); 69 virtual void ExtensionShelfEmpty();
64 virtual void ShelfModelReloaded(); 70 virtual void ShelfModelReloaded();
65 virtual void ShelfModelDeleting(); 71 virtual void ShelfModelDeleting();
66 72
67 // AnimationDelegate 73 // AnimationDelegate methods:
68 virtual void AnimationProgressed(const Animation* animation); 74 virtual void AnimationProgressed(const Animation* animation);
69 virtual void AnimationEnded(const Animation* animation); 75 virtual void AnimationEnded(const Animation* animation);
70 76
71 // NotificationObserver 77 // NotificationObserver methods:
72 virtual void Observe(NotificationType type, 78 virtual void Observe(NotificationType type,
73 const NotificationSource& source, 79 const NotificationSource& source,
74 const NotificationDetails& details); 80 const NotificationDetails& details);
75 81
76 protected: 82 protected:
77 // View 83 // View methods:
78 virtual void ChildPreferredSizeChanged(View* child); 84 virtual void ChildPreferredSizeChanged(View* child);
79 85
80 private: 86 private:
81 class Toolstrip; 87 class Toolstrip;
82 friend class Toolstrip; 88 friend class Toolstrip;
83 class PlaceholderView; 89 class PlaceholderView;
84 90
85 // Dragging toolstrips 91 // Dragging toolstrips
86 void DropExtension(Toolstrip* handle, const gfx::Point& pt, bool cancel); 92 void DropExtension(Toolstrip* handle, const gfx::Point& pt, bool cancel);
87 93
88 // Expand the specified toolstrip, navigating to |url| if non-empty, 94 // Expand the specified toolstrip, navigating to |url| if non-empty,
89 // and setting the |height|. 95 // and setting the |height|.
90 void ExpandToolstrip(ExtensionHost* host, const GURL& url, int height); 96 void ExpandToolstrip(ExtensionHost* host, const GURL& url, int height);
91 97
92 // Collapse the specified toolstrip, navigating to |url| if non-empty. 98 // Collapse the specified toolstrip, navigating to |url| if non-empty.
93 void CollapseToolstrip(ExtensionHost* host, const GURL& url); 99 void CollapseToolstrip(ExtensionHost* host, const GURL& url);
94 100
95 // Inits the background bitmap. 101 // Initializes the background bitmaps for all views.
96 void InitBackground(gfx::Canvas* canvas, const SkRect& subset); 102 void InitBackground(gfx::Canvas* canvas, const SkRect& subset);
97 103
98 // Returns the Toolstrip at |x| coordinate. If |x| is out of bounds, returns 104 // Returns the Toolstrip at |x| coordinate. If |x| is out of bounds, returns
99 // NULL. 105 // NULL.
100 Toolstrip* ToolstripAtX(int x); 106 Toolstrip* ToolstripAtX(int x);
101 107
102 // Returns the Toolstrip at |index|. 108 // Returns the Toolstrip at |index|.
103 Toolstrip* ToolstripAtIndex(int index); 109 Toolstrip* ToolstripAtIndex(int index);
104 110
105 // Returns the toolstrip associated with |view|. 111 // Returns the toolstrip associated with |view|.
106 Toolstrip* ToolstripForView(ExtensionView* view); 112 Toolstrip* ToolstripForView(ExtensionView* view);
107 113
108 // Loads initial state from |model_|. 114 // Loads initial state from |model_|.
109 void LoadFromModel(); 115 void LoadFromModel();
110 116
111 // This method computes the bounds for the extension shelf items. If 117 // This method computes the bounds for the extension shelf items. If
112 // |compute_bounds_only| = TRUE, the bounds for the items are just computed, 118 // |compute_bounds_only| = TRUE, the bounds for the items are just computed,
113 // but are not set. This mode is used by GetPreferredSize() to obtain the 119 // but are not set. This mode is used by GetPreferredSize() to obtain the
114 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set. 120 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set.
115 gfx::Size LayoutItems(bool compute_bounds_only); 121 gfx::Size LayoutItems(bool compute_bounds_only);
116 122
117 // Returns whether the extension shelf always shown (checks pref value). 123 // Returns whether the extension shelf always shown (checks pref value).
118 bool IsAlwaysShown(); 124 bool IsAlwaysShown() const;
119 125
120 // Returns whether the extension shelf is being displayed over the new tab 126 // Returns whether the extension shelf is being displayed over the new tab
121 // page. 127 // page.
122 bool OnNewTabPage(); 128 bool OnNewTabPage() const;
123 129
124 NotificationRegistrar registrar_; 130 NotificationRegistrar registrar_;
125 131
126 // Background bitmap to draw under extension views. 132 // Background bitmap to draw under extension views.
127 SkBitmap background_; 133 bool background_needs_repaint_;
134
135 // Whether the background we are remembering is for detached mode or not.
136 // This allows us to switch backgrounds and remember if we've done so, so that
137 // we don't have to do it over and over again.
138 bool background_for_detached_;
128 139
129 // The browser this extension shelf belongs to. 140 // The browser this extension shelf belongs to.
130 Browser* browser_; 141 Browser* browser_;
131 142
132 // The model representing the toolstrips on the shelf. 143 // The model representing the toolstrips on the shelf.
133 ExtensionShelfModel* model_; 144 ExtensionShelfModel* model_;
134 145
135 // Storage of strings needed for accessibility. 146 // Storage of strings needed for accessibility.
136 std::wstring accessible_name_; 147 std::wstring accessible_name_;
137 148
138 // Animation controlling showing and hiding of the shelf. 149 // Animation controlling showing and hiding of the shelf.
139 scoped_ptr<SlideAnimation> size_animation_; 150 scoped_ptr<SlideAnimation> size_animation_;
140 151
141 DISALLOW_COPY_AND_ASSIGN(ExtensionShelf); 152 DISALLOW_COPY_AND_ASSIGN(ExtensionShelf);
142 }; 153 };
143 154
144 #endif // CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_ 155 #endif // CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_bar_view.cc ('k') | chrome/browser/views/extensions/extension_shelf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698