OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/extensions/shell_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/shell_window_views.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // views::NonClientFrameView implementation. | 33 // views::NonClientFrameView implementation. |
34 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | 34 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; |
35 virtual gfx::Rect GetWindowBoundsForClientBounds( | 35 virtual gfx::Rect GetWindowBoundsForClientBounds( |
36 const gfx::Rect& client_bounds) const OVERRIDE; | 36 const gfx::Rect& client_bounds) const OVERRIDE; |
37 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 37 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
38 virtual void GetWindowMask(const gfx::Size& size, | 38 virtual void GetWindowMask(const gfx::Size& size, |
39 gfx::Path* window_mask) OVERRIDE; | 39 gfx::Path* window_mask) OVERRIDE; |
40 virtual void ResetWindowControls() OVERRIDE {} | 40 virtual void ResetWindowControls() OVERRIDE {} |
41 virtual void UpdateWindowIcon() OVERRIDE {} | 41 virtual void UpdateWindowIcon() OVERRIDE {} |
42 virtual gfx::Size GetMinimumSize() OVERRIDE; | |
43 virtual gfx::Size GetMaximumSize() OVERRIDE; | |
44 | |
45 void set_min_size(gfx::Size size) { min_size_ = size; } | |
46 void set_max_size(gfx::Size size) { max_size_ = size; } | |
47 | 42 |
48 private: | 43 private: |
49 DISALLOW_COPY_AND_ASSIGN(ShellWindowFrameView); | 44 DISALLOW_COPY_AND_ASSIGN(ShellWindowFrameView); |
50 | |
51 gfx::Size min_size_; | |
52 gfx::Size max_size_; | |
53 }; | 45 }; |
54 | 46 |
55 ShellWindowFrameView::ShellWindowFrameView(): min_size_() { | 47 ShellWindowFrameView::ShellWindowFrameView() { |
56 } | 48 } |
57 | 49 |
58 ShellWindowFrameView::~ShellWindowFrameView() { | 50 ShellWindowFrameView::~ShellWindowFrameView() { |
59 } | 51 } |
60 | 52 |
61 gfx::Rect ShellWindowFrameView::GetBoundsForClientView() const { | 53 gfx::Rect ShellWindowFrameView::GetBoundsForClientView() const { |
62 return gfx::Rect(0, 0, width(), height()); | 54 return gfx::Rect(0, 0, width(), height()); |
63 } | 55 } |
64 | 56 |
65 gfx::Rect ShellWindowFrameView::GetWindowBoundsForClientBounds( | 57 gfx::Rect ShellWindowFrameView::GetWindowBoundsForClientBounds( |
(...skipping 26 matching lines...) Expand all Loading... |
92 if (y >= height() - kResizeBorderWidth) | 84 if (y >= height() - kResizeBorderWidth) |
93 return HTBOTTOM; | 85 return HTBOTTOM; |
94 return HTCAPTION; | 86 return HTCAPTION; |
95 } | 87 } |
96 | 88 |
97 void ShellWindowFrameView::GetWindowMask(const gfx::Size& size, | 89 void ShellWindowFrameView::GetWindowMask(const gfx::Size& size, |
98 gfx::Path* window_mask) { | 90 gfx::Path* window_mask) { |
99 // Don't touch it. | 91 // Don't touch it. |
100 } | 92 } |
101 | 93 |
102 gfx::Size ShellWindowFrameView::GetMinimumSize() { | |
103 return min_size_; | |
104 } | |
105 | |
106 gfx::Size ShellWindowFrameView::GetMaximumSize() { | |
107 return max_size_; | |
108 } | |
109 | |
110 ShellWindowViews::ShellWindowViews(ExtensionHost* host) | 94 ShellWindowViews::ShellWindowViews(ExtensionHost* host) |
111 : ShellWindow(host) { | 95 : ShellWindow(host) { |
112 host_->view()->SetContainer(this); | 96 host_->view()->SetContainer(this); |
113 window_ = new views::Widget; | 97 window_ = new views::Widget; |
114 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 98 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
115 params.delegate = this; | 99 params.delegate = this; |
116 params.remove_standard_frame = true; | 100 params.remove_standard_frame = true; |
117 int width = host_->extension()->launch_width(); | 101 gfx::Rect bounds(10, 10, kDefaultWidth, kDefaultHeight); |
118 int height = host_->extension()->launch_height(); | |
119 // TODO(jeremya): we should figure out a better way to position the window. | |
120 gfx::Rect bounds(10, 10, width, height); | |
121 params.bounds = bounds; | 102 params.bounds = bounds; |
122 window_->Init(params); | 103 window_->Init(params); |
123 #if defined(OS_WIN) && !defined(USE_AURA) | 104 #if defined(OS_WIN) && !defined(USE_AURA) |
124 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( | 105 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( |
125 host_->extension()->id()); | 106 host_->extension()->id()); |
126 ui::win::SetAppIdForWindow( | 107 ui::win::SetAppIdForWindow( |
127 ShellIntegration::GetAppId(UTF8ToWide(app_name), | 108 ShellIntegration::GetAppId(UTF8ToWide(app_name), |
128 host_->profile()->GetPath()), | 109 host_->profile()->GetPath()), |
129 GetWidget()->GetTopLevelWidget()->GetNativeWindow()); | 110 GetWidget()->GetTopLevelWidget()->GetNativeWindow()); |
130 #endif | 111 #endif |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 bool ShellWindowViews::CanMaximize() const { | 206 bool ShellWindowViews::CanMaximize() const { |
226 return true; | 207 return true; |
227 } | 208 } |
228 | 209 |
229 views::View* ShellWindowViews::GetContentsView() { | 210 views::View* ShellWindowViews::GetContentsView() { |
230 return host_->view(); | 211 return host_->view(); |
231 } | 212 } |
232 | 213 |
233 views::NonClientFrameView* ShellWindowViews::CreateNonClientFrameView( | 214 views::NonClientFrameView* ShellWindowViews::CreateNonClientFrameView( |
234 views::Widget* widget) { | 215 views::Widget* widget) { |
235 ShellWindowFrameView* frame_view = new ShellWindowFrameView(); | 216 return new ShellWindowFrameView(); |
236 gfx::Size min_size(host_->extension()->launch_min_width(), | |
237 host_->extension()->launch_min_height()); | |
238 gfx::Size max_size(host_->extension()->launch_max_width(), | |
239 host_->extension()->launch_max_height()); | |
240 frame_view->set_min_size(min_size); | |
241 frame_view->set_max_size(max_size); | |
242 return frame_view; | |
243 } | 217 } |
244 | 218 |
245 string16 ShellWindowViews::GetWindowTitle() const { | 219 string16 ShellWindowViews::GetWindowTitle() const { |
246 return UTF8ToUTF16(host_->extension()->name()); | 220 return UTF8ToUTF16(host_->extension()->name()); |
247 } | 221 } |
248 | 222 |
249 views::Widget* ShellWindowViews::GetWidget() { | 223 views::Widget* ShellWindowViews::GetWidget() { |
250 return window_; | 224 return window_; |
251 } | 225 } |
252 | 226 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 rgn->op(0, height - kResizeBorderWidth, width, height, SkRegion::kUnion_Op); | 262 rgn->op(0, height - kResizeBorderWidth, width, height, SkRegion::kUnion_Op); |
289 } | 263 } |
290 host_->render_view_host()->GetView()->SetClickthroughRegion(rgn); | 264 host_->render_view_host()->GetView()->SetClickthroughRegion(rgn); |
291 #endif | 265 #endif |
292 } | 266 } |
293 | 267 |
294 // static | 268 // static |
295 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { | 269 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { |
296 return new ShellWindowViews(host); | 270 return new ShellWindowViews(host); |
297 } | 271 } |
OLD | NEW |