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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CHROME_BROWSER_SIMPLE_XP_FRAME_H__
#define CHROME_BROWSER_SIMPLE_XP_FRAME_H__
#include "chrome/browser/views/location_bar_view.h"
#include "chrome/browser/views/tab_icon_view.h"
#include "chrome/browser/xp_frame.h"
#include "chrome/views/menu_button.h"
#include "chrome/views/view_menu_delegate.h"
class SimpleXPFrameTitleBar;
class WebAppIconManager;
namespace ChromeViews {
class Label;
}
////////////////////////////////////////////////////////////////////////////////
//
// A simple frame that contains a browser object. This frame doesn't show any
// tab. It is used for web applications. It will likely be used in the future
// for detached popups.
//
////////////////////////////////////////////////////////////////////////////////
class SimpleXPFrame : public XPFrame,
public LocationBarView::Delegate {
public:
// Invoked by ChromeFrame::CreateChromeFrame to create a new SimpleXPFrame.
// An empty |bounds| means that Windows should decide where to place the
// window.
static SimpleXPFrame* CreateFrame(const gfx::Rect& bounds, Browser* browser);
virtual ~SimpleXPFrame();
// Overridden from XPFrame.
virtual void Init();
virtual void Layout();
virtual bool IsTabStripVisible() const { return false; }
virtual bool IsToolBarVisible() const { return false; }
virtual bool SupportsBookmarkBar() const { return false; }
virtual LRESULT OnNCHitTest(const CPoint& pt);
virtual void SetWindowTitle(const std::wstring& title);
virtual void ValidateThrobber();
virtual void ShowTabContents(TabContents* selected_contents);
virtual void UpdateTitleBar();
// Return the currently visible contents.
TabContents* GetCurrentContents();
void RunMenu(const CPoint& pt, HWND hwnd);
// Returns true if this popup contains a popup which has been created
// by a browser with a minimal chrome.
bool IsApplication() const;
// LocationBarView delegate.
virtual TabContents* GetTabContents();
virtual void OnInputInProgress(bool in_progress);
protected:
explicit SimpleXPFrame(Browser* browser);
// The default implementation has a title bar. Override if not needed.
virtual bool IsTitleBarVisible() { return true; }
// Overriden to create the WebAppIconManager, then invoke super.
virtual void InitAfterHWNDCreated();
private:
// Set the current window icon. Use NULL for a default icon.
void SetCurrentIcon(HICON icon);
// Update the location bar if it is visible.
void UpdateLocationBar();
// The simple frame title bar including favicon, menu and title.
SimpleXPFrameTitleBar* title_bar_;
// The optional URL field.
//SimplifiedURLField* url_field_;
LocationBarView* location_bar_;
// Handles the icon for web apps.
scoped_ptr<WebAppIconManager> icon_manager_;
DISALLOW_EVIL_CONSTRUCTORS(SimpleXPFrame);
};
class SimpleXPFrameTitleBar;
////////////////////////////////////////////////////////////////////////////////
//
// A custom menu button for the custom title bar.
//
////////////////////////////////////////////////////////////////////////////////
class TitleBarMenuButton : public ChromeViews::MenuButton {
public:
explicit TitleBarMenuButton(SimpleXPFrameTitleBar* title_bar);
virtual ~TitleBarMenuButton();
// Set the contents view which is the view presenting the menu icon.
void SetContents(ChromeViews::View* contents);
// overridden from View
virtual void GetPreferredSize(CSize *out);
virtual void Paint(ChromeCanvas* canvas);
virtual bool OnMousePressed(const ChromeViews::MouseEvent& e);
private:
// The drop arrow icon.
SkBitmap* drop_arrow_;
// The contents is an additional view positioned before the drop down.
ChromeViews::View* contents_;
// The title bar that created this instance.
SimpleXPFrameTitleBar* title_bar_;
DISALLOW_EVIL_CONSTRUCTORS(TitleBarMenuButton);
};
////////////////////////////////////////////////////////////////////////////////
//
// Custom title bar.
//
////////////////////////////////////////////////////////////////////////////////
class SimpleXPFrameTitleBar : public ChromeViews::View,
public TabIconView::TabContentsProvider,
public ChromeViews::ViewMenuDelegate {
public:
explicit SimpleXPFrameTitleBar(SimpleXPFrame* parent);
virtual ~SimpleXPFrameTitleBar();
// Overriden from TabIconView::TabContentsProvider:
virtual TabContents* GetCurrentTabContents();
virtual SkBitmap GetFavIcon();
virtual void RunMenu(ChromeViews::View* source, const CPoint& pt, HWND hwnd);
virtual void Layout();
bool WillHandleMouseEvent(int x, int y);
void SetWindowTitle(std::wstring s);
void ValidateThrobber();
void CloseWindow();
// Updates the state of the tab icon.
void Update();
TabIconView* tab_icon_view() const { return tab_icon_.get(); }
private:
// The menu button.
TitleBarMenuButton* menu_button_;
// The tab icon.
scoped_ptr<TabIconView> tab_icon_;
// The corresponding SimpleXPFrame.
SimpleXPFrame* parent_;
// The window title.
ChromeViews::Label* label_;
// Lazily created chrome icon. Created and used as the icon in the
// TabIconView for all non-Application windows.
SkBitmap* chrome_icon_;
DISALLOW_EVIL_CONSTRUCTORS(SimpleXPFrameTitleBar);
};
#endif // CHROME_BROWSER_SIMPLE_XP_FRAME_H__
|