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

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: Fix PanelLayoutManager 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 frameless_(win_params.frame == ShellWindow::FRAME_NONE) {
32 window_ = new views::Widget;
33 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL);
34 params.delegate = this;
35
36 preferred_size_ = gfx::Size(win_params.bounds.width(),
37 win_params.bounds.height());
38 if (preferred_size_.width() == 0)
39 preferred_size_.set_width(kDefaultWidth);
40 else if (preferred_size_.width() < kMinWidth)
41 preferred_size_.set_width(kMinWidth);
42
43 if (preferred_size_.height() == 0)
44 preferred_size_.set_height(kDefaultHeight);
45 else if (preferred_size_.height() < kMinHeight)
46 preferred_size_.set_height(kMinHeight);
47
48 params.bounds = gfx::Rect(preferred_size_.width(), preferred_size_.height());
49 window_->Init(params);
jeremya 2012/11/19 00:04:24 Bounds should refer to content bounds, not window
stevenjb 2012/11/19 21:38:44 I looked at how this is done in the _views impl in
50 }
51
52 ShellUtilityWindowAsh::~ShellUtilityWindowAsh() {
53 web_view_->SetWebContents(NULL);
54 }
55
56 // BaseWindow implementation:
57
58 bool ShellUtilityWindowAsh::IsActive() const {
59 return window_->IsActive();
60 }
61
62 bool ShellUtilityWindowAsh::IsMaximized() const {
63 return window_->IsMaximized();
64 }
65
66 bool ShellUtilityWindowAsh::IsMinimized() const {
67 return window_->IsMinimized();
68 }
69
70 bool ShellUtilityWindowAsh::IsFullscreen() const {
71 return window_->IsFullscreen();
72 }
73
74 gfx::NativeWindow ShellUtilityWindowAsh::GetNativeWindow() {
75 return window_->GetNativeWindow();
76 }
77
78 gfx::Rect ShellUtilityWindowAsh::GetRestoredBounds() const {
79 return window_->GetRestoredBounds();
80 }
81
82 gfx::Rect ShellUtilityWindowAsh::GetBounds() const {
83 return window_->GetWindowBoundsInScreen();
84 }
85
86 void ShellUtilityWindowAsh::Show() {
87 window_->Show();
88 }
89
90 void ShellUtilityWindowAsh::ShowInactive() {
91 window_->ShowInactive();
92 }
93
94 void ShellUtilityWindowAsh::Hide() {
95 window_->Hide();
96 }
97
98 void ShellUtilityWindowAsh::Close() {
99 window_->Close();
100 }
101
102 void ShellUtilityWindowAsh::Activate() {
103 window_->Activate();
104 }
105
106 void ShellUtilityWindowAsh::Deactivate() {
107 window_->Deactivate();
108 }
109
110 void ShellUtilityWindowAsh::Maximize() {
111 // Maximize is not implemented for panels.
112 }
113
114 void ShellUtilityWindowAsh::Minimize() {
115 window_->Minimize();
116 }
117
118 void ShellUtilityWindowAsh::Restore() {
119 window_->Restore();
120 }
121
122 void ShellUtilityWindowAsh::SetBounds(const gfx::Rect& bounds) {
123 window_->SetBounds(bounds);
124 }
125
126 void ShellUtilityWindowAsh::FlashFrame(bool flash) {
127 // TODO(stevenjb): Implement
128 NOTIMPLEMENTED();
129 }
130
131 bool ShellUtilityWindowAsh::IsAlwaysOnTop() const {
132 return true;
133 }
134
135 // views::WidgetDelegate implementation:
136 void ShellUtilityWindowAsh::DeleteDelegate() {
137 shell_window_->OnNativeClose();
138 }
139
140 bool ShellUtilityWindowAsh::CanResize() const {
141 return true;
142 }
143
144 views::View* ShellUtilityWindowAsh::GetContentsView() {
145 return this;
146 }
147
148 views::NonClientFrameView* ShellUtilityWindowAsh::CreateNonClientFrameView(
149 views::Widget* widget) {
150 ash::PanelFrameView::FrameType frame_type =
151 frameless_ ? ash::PanelFrameView::FRAME_NONE
152 : ash::PanelFrameView::FRAME_ASH;
153 ash::PanelFrameView* frame_view = new ash::PanelFrameView(widget, frame_type);
154 return frame_view;
155 }
156
157 string16 ShellUtilityWindowAsh::GetWindowTitle() const {
158 return shell_window_->GetTitle();
159 }
160
161 bool ShellUtilityWindowAsh::ShouldShowWindowTitle() const {
162 return true;
163 }
164
165 views::Widget* ShellUtilityWindowAsh::GetWidget() {
166 return window_;
167 }
168
169 const views::Widget* ShellUtilityWindowAsh::GetWidget() const {
170 return window_;
171 }
172
173 views::View* ShellUtilityWindowAsh::GetInitiallyFocusedView() {
174 return web_view_;
175 }
176
177 // views::View implementation:
178 void ShellUtilityWindowAsh::Layout() {
179 DCHECK(web_view_);
180 web_view_->SetBounds(0, 0, width(), height());
181 }
182
183 void ShellUtilityWindowAsh::ViewHierarchyChanged(
184 bool is_add, views::View *parent, views::View *child) {
185 if (is_add && child == this) {
186 web_view_ = new views::WebView(NULL);
187 AddChildView(web_view_);
188 web_view_->SetWebContents(shell_window_->web_contents());
189 }
190 }
191
192 gfx::Size ShellUtilityWindowAsh::GetPreferredSize() {
193 return preferred_size_;
194 }
195
196 void ShellUtilityWindowAsh::OnFocus() {
197 web_view_->RequestFocus();
198 }
199
200 // NativeShellWindow implementation.
201 void ShellUtilityWindowAsh::SetFullscreen(bool fullscreen) {
202 }
203
204 bool ShellUtilityWindowAsh::IsFullscreenOrPending() const {
205 return false;
206 }
207
208 void ShellUtilityWindowAsh::UpdateWindowIcon() {
209 window_->UpdateWindowIcon();
210 }
211
212 void ShellUtilityWindowAsh::UpdateWindowTitle() {
213 window_->UpdateWindowTitle();
214 }
215
216 void ShellUtilityWindowAsh::UpdateDraggableRegions(
217 const std::vector<extensions::DraggableRegion>& regions) {
218 }
219
220 void ShellUtilityWindowAsh::HandleKeyboardEvent(
221 const content::NativeWebKeyboardEvent& event) {
222 }
223
224 void ShellUtilityWindowAsh::RenderViewHostChanged() {
225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698