Chromium Code Reviews| 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 "apps/ui/views/app_window_frame_view.h" | 7 #include "apps/ui/views/app_window_frame_view.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/app_mode/app_mode_utils.h" | 9 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 101 |
| 102 ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {} | 102 ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {} |
| 103 | 103 |
| 104 void ChromeNativeAppWindowViews::OnBeforeWidgetInit( | 104 void ChromeNativeAppWindowViews::OnBeforeWidgetInit( |
| 105 const AppWindow::CreateParams& create_params, | 105 const AppWindow::CreateParams& create_params, |
| 106 views::Widget::InitParams* init_params, | 106 views::Widget::InitParams* init_params, |
| 107 views::Widget* widget) { | 107 views::Widget* widget) { |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ChromeNativeAppWindowViews::OnBeforePanelWidgetInit( | 110 void ChromeNativeAppWindowViews::OnBeforePanelWidgetInit( |
| 111 bool use_default_origin, | |
| 111 views::Widget::InitParams* init_params, | 112 views::Widget::InitParams* init_params, |
| 112 views::Widget* widget) { | 113 views::Widget* widget) { |
| 113 } | 114 } |
| 114 | 115 |
| 115 void ChromeNativeAppWindowViews::InitializeDefaultWindow( | 116 void ChromeNativeAppWindowViews::InitializeDefaultWindow( |
| 116 const AppWindow::CreateParams& create_params) { | 117 const AppWindow::CreateParams& create_params) { |
| 117 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); | 118 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); |
| 118 init_params.delegate = this; | 119 init_params.delegate = this; |
| 119 init_params.remove_standard_frame = IsFrameless() || has_frame_color_; | 120 init_params.remove_standard_frame = IsFrameless() || has_frame_color_; |
| 120 init_params.use_system_default_icon = true; | 121 init_params.use_system_default_icon = true; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 135 OnBeforeWidgetInit(create_params, &init_params, widget()); | 136 OnBeforeWidgetInit(create_params, &init_params, widget()); |
| 136 widget()->Init(init_params); | 137 widget()->Init(init_params); |
| 137 | 138 |
| 138 // The frame insets are required to resolve the bounds specifications | 139 // The frame insets are required to resolve the bounds specifications |
| 139 // correctly. So we set the window bounds and constraints now. | 140 // correctly. So we set the window bounds and constraints now. |
| 140 gfx::Insets frame_insets = GetFrameInsets(); | 141 gfx::Insets frame_insets = GetFrameInsets(); |
| 141 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); | 142 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); |
| 142 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), | 143 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), |
| 143 create_params.GetContentMaximumSize(frame_insets)); | 144 create_params.GetContentMaximumSize(frame_insets)); |
| 144 if (!window_bounds.IsEmpty()) { | 145 if (!window_bounds.IsEmpty()) { |
| 145 typedef AppWindow::BoundsSpecification BoundsSpecification; | 146 using BoundsSpecification = AppWindow::BoundsSpecification; |
| 146 bool position_specified = | 147 bool position_specified = |
| 147 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && | 148 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && |
| 148 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; | 149 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; |
| 149 if (!position_specified) | 150 if (!position_specified) |
| 150 widget()->CenterWindow(window_bounds.size()); | 151 widget()->CenterWindow(window_bounds.size()); |
| 151 else | 152 else |
| 152 widget()->SetBounds(window_bounds); | 153 widget()->SetBounds(window_bounds); |
| 153 } | 154 } |
| 154 | 155 |
| 155 #if defined(OS_CHROMEOS) | 156 #if defined(OS_CHROMEOS) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 if (preferred_size_.width() == 0) | 204 if (preferred_size_.width() == 0) |
| 204 preferred_size_.set_width(kDefaultPanelWidth); | 205 preferred_size_.set_width(kDefaultPanelWidth); |
| 205 else if (preferred_size_.width() < kMinPanelWidth) | 206 else if (preferred_size_.width() < kMinPanelWidth) |
| 206 preferred_size_.set_width(kMinPanelWidth); | 207 preferred_size_.set_width(kMinPanelWidth); |
| 207 | 208 |
| 208 if (preferred_size_.height() == 0) | 209 if (preferred_size_.height() == 0) |
| 209 preferred_size_.set_height(kDefaultPanelHeight); | 210 preferred_size_.set_height(kDefaultPanelHeight); |
| 210 else if (preferred_size_.height() < kMinPanelHeight) | 211 else if (preferred_size_.height() < kMinPanelHeight) |
| 211 preferred_size_.set_height(kMinPanelHeight); | 212 preferred_size_.set_height(kMinPanelHeight); |
| 212 | 213 |
| 213 params.bounds = gfx::Rect(preferred_size_); | 214 params.bounds = gfx::Rect(initial_window_bounds.origin(), preferred_size_); |
| 214 OnBeforePanelWidgetInit(¶ms, widget()); | 215 // When a panel is not docked it will be placed at a default origin in the |
| 216 // currently active target root window. | |
| 217 bool use_default_position = create_params.state != ui::SHOW_STATE_DOCKED; | |
| 218 OnBeforePanelWidgetInit(use_default_position, ¶ms, widget()); | |
| 219 using BoundsSpecification = AppWindow::BoundsSpecification; | |
| 220 bool position_specified = | |
|
benwells
2015/04/29 21:46:42
I'm not sure what this check versus BoundsSpecific
varkha
2015/04/30 02:15:31
See if you like this flow better. I need to saniti
| |
| 221 params.bounds.x() != BoundsSpecification::kUnspecifiedPosition && | |
| 222 params.bounds.y() != BoundsSpecification::kUnspecifiedPosition; | |
| 223 if (!position_specified) | |
| 224 params.bounds = gfx::Rect(preferred_size_); | |
| 215 widget()->Init(params); | 225 widget()->Init(params); |
| 216 widget()->set_focus_on_creation(create_params.focused); | 226 widget()->set_focus_on_creation(create_params.focused); |
| 217 } | 227 } |
| 218 | 228 |
| 219 views::NonClientFrameView* | 229 views::NonClientFrameView* |
| 220 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() { | 230 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() { |
| 221 return views::WidgetDelegateView::CreateNonClientFrameView(widget()); | 231 return views::WidgetDelegateView::CreateNonClientFrameView(widget()); |
| 222 } | 232 } |
| 223 | 233 |
| 224 apps::AppWindowFrameView* | 234 apps::AppWindowFrameView* |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 InitializePanelWindow(create_params); | 408 InitializePanelWindow(create_params); |
| 399 } else { | 409 } else { |
| 400 InitializeDefaultWindow(create_params); | 410 InitializeDefaultWindow(create_params); |
| 401 } | 411 } |
| 402 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 412 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
| 403 Profile::FromBrowserContext(app_window->browser_context()), | 413 Profile::FromBrowserContext(app_window->browser_context()), |
| 404 widget()->GetFocusManager(), | 414 widget()->GetFocusManager(), |
| 405 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 415 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 406 NULL)); | 416 NULL)); |
| 407 } | 417 } |
| OLD | NEW |