OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "apps/ui/views/native_app_window_views.h" | 5 #include "apps/ui/views/native_app_window_views.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 frameless_(false), | 30 frameless_(false), |
31 transparent_background_(false), | 31 transparent_background_(false), |
32 resizable_(false) {} | 32 resizable_(false) {} |
33 | 33 |
34 void NativeAppWindowViews::Init(AppWindow* app_window, | 34 void NativeAppWindowViews::Init(AppWindow* app_window, |
35 const AppWindow::CreateParams& create_params) { | 35 const AppWindow::CreateParams& create_params) { |
36 app_window_ = app_window; | 36 app_window_ = app_window; |
37 frameless_ = create_params.frame == AppWindow::FRAME_NONE; | 37 frameless_ = create_params.frame == AppWindow::FRAME_NONE; |
38 transparent_background_ = create_params.transparent_background; | 38 transparent_background_ = create_params.transparent_background; |
39 resizable_ = create_params.resizable; | 39 resizable_ = create_params.resizable; |
40 size_constraints_.set_minimum_size(create_params.minimum_size); | |
41 size_constraints_.set_maximum_size(create_params.maximum_size); | |
42 Observe(app_window_->web_contents()); | 40 Observe(app_window_->web_contents()); |
43 | 41 |
44 window_ = new views::Widget; | 42 window_ = new views::Widget; |
45 InitializeWindow(app_window, create_params); | 43 InitializeWindow(app_window, create_params); |
46 | 44 |
47 OnViewWasResized(); | 45 OnViewWasResized(); |
48 window_->AddObserver(this); | 46 window_->AddObserver(this); |
49 } | 47 } |
50 | 48 |
51 NativeAppWindowViews::~NativeAppWindowViews() { | 49 NativeAppWindowViews::~NativeAppWindowViews() { |
52 web_view_->SetWebContents(NULL); | 50 web_view_->SetWebContents(NULL); |
53 } | 51 } |
54 | 52 |
55 void NativeAppWindowViews::InitializeWindow( | 53 void NativeAppWindowViews::InitializeWindow( |
56 AppWindow* app_window, | 54 AppWindow* app_window, |
57 const AppWindow::CreateParams& create_params) { | 55 const AppWindow::CreateParams& create_params) { |
58 // Stub implementation. See also ChromeNativeAppWindowViews. | 56 // Stub implementation. See also ChromeNativeAppWindowViews. |
59 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); | 57 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); |
60 init_params.delegate = this; | 58 init_params.delegate = this; |
61 init_params.top_level = true; | 59 init_params.top_level = true; |
62 init_params.keep_on_top = create_params.always_on_top; | 60 init_params.keep_on_top = create_params.always_on_top; |
63 window_->Init(init_params); | 61 window_->Init(init_params); |
64 window_->CenterWindow(create_params.bounds.size()); | 62 window_->CenterWindow( |
| 63 create_params.GetInitialWindowBounds(gfx::Insets()).size()); |
65 } | 64 } |
66 | 65 |
67 // ui::BaseWindow implementation. | 66 // ui::BaseWindow implementation. |
68 | 67 |
69 bool NativeAppWindowViews::IsActive() const { | 68 bool NativeAppWindowViews::IsActive() const { |
70 return window_->IsActive(); | 69 return window_->IsActive(); |
71 } | 70 } |
72 | 71 |
73 bool NativeAppWindowViews::IsMaximized() const { | 72 bool NativeAppWindowViews::IsMaximized() const { |
74 return window_->IsMaximized(); | 73 return window_->IsMaximized(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 client_bounds); | 400 client_bounds); |
402 return window_bounds.InsetsFrom(client_bounds); | 401 return window_bounds.InsetsFrom(client_bounds); |
403 } | 402 } |
404 | 403 |
405 void NativeAppWindowViews::HideWithApp() {} | 404 void NativeAppWindowViews::HideWithApp() {} |
406 | 405 |
407 void NativeAppWindowViews::ShowWithApp() {} | 406 void NativeAppWindowViews::ShowWithApp() {} |
408 | 407 |
409 void NativeAppWindowViews::UpdateShelfMenu() {} | 408 void NativeAppWindowViews::UpdateShelfMenu() {} |
410 | 409 |
411 gfx::Size NativeAppWindowViews::GetMinimumSize() const { | 410 gfx::Size NativeAppWindowViews::GetContentMinimumSize() const { |
412 return size_constraints_.GetMinimumSize(); | 411 return size_constraints_.GetMinimumSize(); |
413 } | 412 } |
414 | 413 |
415 void NativeAppWindowViews::SetMinimumSize(const gfx::Size& size) { | 414 void NativeAppWindowViews::SetContentMinimumSize(const gfx::Size& size) { |
416 size_constraints_.set_minimum_size(size); | 415 size_constraints_.set_minimum_size(size); |
417 } | 416 } |
418 | 417 |
419 gfx::Size NativeAppWindowViews::GetMaximumSize() const { | 418 gfx::Size NativeAppWindowViews::GetContentMaximumSize() const { |
420 return size_constraints_.GetMaximumSize(); | 419 return size_constraints_.GetMaximumSize(); |
421 } | 420 } |
422 | 421 |
423 void NativeAppWindowViews::SetMaximumSize(const gfx::Size& size) { | 422 void NativeAppWindowViews::SetContentMaximumSize(const gfx::Size& size) { |
424 size_constraints_.set_maximum_size(size); | 423 size_constraints_.set_maximum_size(size); |
425 } | 424 } |
426 | 425 |
427 } // namespace apps | 426 } // namespace apps |
OLD | NEW |