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

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

Powered by Google App Engine
This is Rietveld 408576698