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