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

Side by Side Diff: chrome/browser/ui/ash/shell_utility_window_ash.cc

Issue 11363250: Allow Chrome apps to create Ash Panels (apps v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Multi-icon support Created 8 years, 1 month 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/ash/shell_utility_window_ash.h"
6
7 #include "ash/wm/panel_frame_view.h"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "googleurl/src/gurl.h"
11 #include "ui/aura/window.h"
12 #include "ui/views/controls/webview/webview.h"
13 #include "ui/views/widget/widget.h"
14
15 namespace {
16 const int kMinWidth = 100;
17 const int kMinHeight = 100;
18 const int kDefaultWidth = 200;
19 const int kDefaultHeight = 300;
20 }
21
22 ////////////////////////////////////////////////////////////////////////////////
23 // ShellUtilityWindowAsh
24
25 ShellUtilityWindowAsh::ShellUtilityWindowAsh(
26 ShellWindow* shell_window,
27 const ShellWindow::CreateParams& win_params)
28 : shell_window_(shell_window),
29 web_view_(NULL),
30 window_(NULL),
31 panel_frame_view_(NULL),
32 frameless_(win_params.frame == ShellWindow::FRAME_NONE) {
33 window_ = new views::Widget;
34 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL);
35 params.delegate = this;
36
37 preferred_size_ = gfx::Size(win_params.bounds.width(),
38 win_params.bounds.height());
39 if (preferred_size_.width() == 0)
40 preferred_size_.set_width(kDefaultWidth);
41 else if (preferred_size_.width() < kMinWidth)
42 preferred_size_.set_width(kMinWidth);
43
44 if (preferred_size_.height() == 0)
45 preferred_size_.set_height(kDefaultHeight);
46 else if (preferred_size_.height() < kMinHeight)
47 preferred_size_.set_height(kMinHeight);
48
49 params.bounds = gfx::Rect(preferred_size_.width(), preferred_size_.height());
50 window_->Init(params);
51
52 // Resize the window to include the frame insets.
53 gfx::Rect bounds = GetBounds();
54 bounds.Inset(-GetFrameInsets());
55 SetBounds(bounds);
56 }
57
58 ShellUtilityWindowAsh::~ShellUtilityWindowAsh() {
59 web_view_->SetWebContents(NULL);
60 }
61
62 // BaseWindow implementation
63
64 bool ShellUtilityWindowAsh::IsActive() const {
65 return window_->IsActive();
66 }
67
68 bool ShellUtilityWindowAsh::IsMaximized() const {
69 return window_->IsMaximized();
70 }
71
72 bool ShellUtilityWindowAsh::IsMinimized() const {
73 return window_->IsMinimized();
74 }
75
76 bool ShellUtilityWindowAsh::IsFullscreen() const {
77 return window_->IsFullscreen();
78 }
79
80 gfx::NativeWindow ShellUtilityWindowAsh::GetNativeWindow() {
81 return window_->GetNativeWindow();
82 }
83
84 gfx::Rect ShellUtilityWindowAsh::GetRestoredBounds() const {
85 return window_->GetRestoredBounds();
86 }
87
88 gfx::Rect ShellUtilityWindowAsh::GetBounds() const {
89 return window_->GetWindowBoundsInScreen();
90 }
91
92 void ShellUtilityWindowAsh::Show() {
93 window_->Show();
94 }
95
96 void ShellUtilityWindowAsh::ShowInactive() {
97 window_->ShowInactive();
98 }
99
100 void ShellUtilityWindowAsh::Hide() {
101 window_->Hide();
102 }
103
104 void ShellUtilityWindowAsh::Close() {
105 window_->Close();
106 }
107
108 void ShellUtilityWindowAsh::Activate() {
109 window_->Activate();
110 }
111
112 void ShellUtilityWindowAsh::Deactivate() {
113 window_->Deactivate();
114 }
115
116 void ShellUtilityWindowAsh::Maximize() {
117 // Maximize is not implemented for panels.
118 }
119
120 void ShellUtilityWindowAsh::Minimize() {
121 window_->Minimize();
122 }
123
124 void ShellUtilityWindowAsh::Restore() {
125 window_->Restore();
126 }
127
128 void ShellUtilityWindowAsh::SetBounds(const gfx::Rect& bounds) {
129 window_->SetBounds(bounds);
130 }
131
132 void ShellUtilityWindowAsh::FlashFrame(bool flash) {
133 // TODO(stevenjb): Implement
134 NOTIMPLEMENTED();
135 }
136
137 bool ShellUtilityWindowAsh::IsAlwaysOnTop() const {
138 return true;
139 }
140
141 gfx::Insets ShellUtilityWindowAsh::GetFrameInsets() const {
142 if (!panel_frame_view_)
143 return gfx::Insets();
144 return panel_frame_view_->GetFrameInsets();
145 }
146
147 // views::WidgetDelegate implementation
148
149 void ShellUtilityWindowAsh::DeleteDelegate() {
150 shell_window_->OnNativeClose();
151 }
152
153 bool ShellUtilityWindowAsh::CanResize() const {
154 return true;
155 }
156
157 views::View* ShellUtilityWindowAsh::GetContentsView() {
158 return this;
159 }
160
161 views::NonClientFrameView* ShellUtilityWindowAsh::CreateNonClientFrameView(
162 views::Widget* widget) {
163 ash::PanelFrameView::FrameType frame_type = frameless_ ?
164 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
165 panel_frame_view_ = new ash::PanelFrameView(widget, frame_type);
166 return panel_frame_view_;
167 }
168
169 string16 ShellUtilityWindowAsh::GetWindowTitle() const {
170 return shell_window_->GetTitle();
171 }
172
173 bool ShellUtilityWindowAsh::ShouldShowWindowTitle() const {
174 return true;
175 }
176
177 views::Widget* ShellUtilityWindowAsh::GetWidget() {
178 return window_;
179 }
180
181 const views::Widget* ShellUtilityWindowAsh::GetWidget() const {
182 return window_;
183 }
184
185 views::View* ShellUtilityWindowAsh::GetInitiallyFocusedView() {
186 return web_view_;
187 }
188
189 // views::View implementation
190
191 void ShellUtilityWindowAsh::Layout() {
192 DCHECK(web_view_);
193 web_view_->SetBounds(0, 0, width(), height());
194 }
195
196 void ShellUtilityWindowAsh::ViewHierarchyChanged(
197 bool is_add, views::View *parent, views::View *child) {
198 if (is_add && child == this) {
199 web_view_ = new views::WebView(NULL);
200 AddChildView(web_view_);
201 web_view_->SetWebContents(shell_window_->web_contents());
202 }
203 }
204
205 gfx::Size ShellUtilityWindowAsh::GetPreferredSize() {
206 return preferred_size_;
207 }
208
209 void ShellUtilityWindowAsh::OnFocus() {
210 web_view_->RequestFocus();
211 }
212
213 // NativeShellWindow implementation
214
215 void ShellUtilityWindowAsh::SetFullscreen(bool fullscreen) {
216 }
217
218 bool ShellUtilityWindowAsh::IsFullscreenOrPending() const {
219 return false;
220 }
221
222 void ShellUtilityWindowAsh::UpdateWindowIcon() {
223 window_->UpdateWindowIcon();
224 }
225
226 void ShellUtilityWindowAsh::UpdateWindowTitle() {
227 window_->UpdateWindowTitle();
228 }
229
230 void ShellUtilityWindowAsh::UpdateDraggableRegions(
231 const std::vector<extensions::DraggableRegion>& regions) {
232 }
233
234 void ShellUtilityWindowAsh::HandleKeyboardEvent(
235 const content::NativeWebKeyboardEvent& event) {
236 }
237
238 void ShellUtilityWindowAsh::RenderViewHostChanged() {
239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698