| 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 "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "apps/ui/views/app_window_frame_view.h" | 10 #include "apps/ui/views/app_window_frame_view.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {} | 105 ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {} |
| 106 | 106 |
| 107 void ChromeNativeAppWindowViews::OnBeforeWidgetInit( | 107 void ChromeNativeAppWindowViews::OnBeforeWidgetInit( |
| 108 const AppWindow::CreateParams& create_params, | 108 const AppWindow::CreateParams& create_params, |
| 109 views::Widget::InitParams* init_params, | 109 views::Widget::InitParams* init_params, |
| 110 views::Widget* widget) { | 110 views::Widget* widget) { |
| 111 } | 111 } |
| 112 | 112 |
| 113 void ChromeNativeAppWindowViews::OnBeforePanelWidgetInit( | 113 void ChromeNativeAppWindowViews::OnBeforePanelWidgetInit( |
| 114 bool use_default_bounds, | |
| 115 views::Widget::InitParams* init_params, | 114 views::Widget::InitParams* init_params, |
| 116 views::Widget* widget) { | 115 views::Widget* widget) { |
| 117 } | 116 } |
| 118 | 117 |
| 119 void ChromeNativeAppWindowViews::InitializeDefaultWindow( | 118 void ChromeNativeAppWindowViews::InitializeDefaultWindow( |
| 120 const AppWindow::CreateParams& create_params) { | 119 const AppWindow::CreateParams& create_params) { |
| 121 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); | 120 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); |
| 122 init_params.delegate = this; | 121 init_params.delegate = this; |
| 123 init_params.remove_standard_frame = IsFrameless() || has_frame_color_; | 122 init_params.remove_standard_frame = IsFrameless() || has_frame_color_; |
| 124 init_params.use_system_default_icon = true; | 123 init_params.use_system_default_icon = true; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (preferred_size_.width() == 0) | 206 if (preferred_size_.width() == 0) |
| 208 preferred_size_.set_width(kDefaultPanelWidth); | 207 preferred_size_.set_width(kDefaultPanelWidth); |
| 209 else if (preferred_size_.width() < kMinPanelWidth) | 208 else if (preferred_size_.width() < kMinPanelWidth) |
| 210 preferred_size_.set_width(kMinPanelWidth); | 209 preferred_size_.set_width(kMinPanelWidth); |
| 211 | 210 |
| 212 if (preferred_size_.height() == 0) | 211 if (preferred_size_.height() == 0) |
| 213 preferred_size_.set_height(kDefaultPanelHeight); | 212 preferred_size_.set_height(kDefaultPanelHeight); |
| 214 else if (preferred_size_.height() < kMinPanelHeight) | 213 else if (preferred_size_.height() < kMinPanelHeight) |
| 215 preferred_size_.set_height(kMinPanelHeight); | 214 preferred_size_.set_height(kMinPanelHeight); |
| 216 | 215 |
| 217 // When a panel is not docked it will be placed at a default origin in the | 216 // A panel will be placed at a default origin in the currently active target |
| 218 // currently active target root window. | 217 // root window. |
| 219 // TODO(afakhry): Remove Docked Windows in M58. | 218 params.bounds = gfx::Rect(preferred_size_); |
| 220 bool use_default_bounds = create_params.state != ui::SHOW_STATE_DOCKED; | 219 OnBeforePanelWidgetInit(¶ms, widget()); |
| 221 // Sanitize initial origin reseting it in case it was not specified. | |
| 222 using BoundsSpecification = AppWindow::BoundsSpecification; | |
| 223 bool position_specified = | |
| 224 initial_window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && | |
| 225 initial_window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; | |
| 226 params.bounds = (use_default_bounds || !position_specified) ? | |
| 227 gfx::Rect(preferred_size_) : | |
| 228 gfx::Rect(initial_window_bounds.origin(), preferred_size_); | |
| 229 OnBeforePanelWidgetInit(use_default_bounds, ¶ms, widget()); | |
| 230 widget()->Init(params); | 220 widget()->Init(params); |
| 231 widget()->set_focus_on_creation(create_params.focused); | 221 widget()->set_focus_on_creation(create_params.focused); |
| 232 } | 222 } |
| 233 | 223 |
| 234 views::NonClientFrameView* | 224 views::NonClientFrameView* |
| 235 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() { | 225 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() { |
| 236 return views::WidgetDelegateView::CreateNonClientFrameView(widget()); | 226 return views::WidgetDelegateView::CreateNonClientFrameView(widget()); |
| 237 } | 227 } |
| 238 | 228 |
| 239 // ui::BaseWindow implementation. | 229 // ui::BaseWindow implementation. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 InitializePanelWindow(create_params); | 365 InitializePanelWindow(create_params); |
| 376 } else { | 366 } else { |
| 377 InitializeDefaultWindow(create_params); | 367 InitializeDefaultWindow(create_params); |
| 378 } | 368 } |
| 379 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 369 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
| 380 Profile::FromBrowserContext(app_window->browser_context()), | 370 Profile::FromBrowserContext(app_window->browser_context()), |
| 381 widget()->GetFocusManager(), | 371 widget()->GetFocusManager(), |
| 382 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 372 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 383 NULL)); | 373 NULL)); |
| 384 } | 374 } |
| OLD | NEW |