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

Side by Side Diff: chrome/browser/ui/views/apps/chrome_native_app_window_views.cc

Issue 1056793006: [Docking] Persists docked state on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [Docking] Makes docked state persistent on Chrome OS (comments) Created 5 years, 7 months 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
OLDNEW
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
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_bounds,
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
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
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 // When a panel is not docked it will be placed at a default origin in the
214 OnBeforePanelWidgetInit(&params, widget()); 215 // currently active target root window.
216 bool use_default_bounds = create_params.state != ui::SHOW_STATE_DOCKED;
217 // Sanitize initial origin reseting it in case it was not specified.
218 using BoundsSpecification = AppWindow::BoundsSpecification;
219 bool position_specified =
220 initial_window_bounds.x() != BoundsSpecification::kUnspecifiedPosition &&
221 initial_window_bounds.y() != BoundsSpecification::kUnspecifiedPosition;
222 params.bounds = (use_default_bounds || !position_specified) ?
223 gfx::Rect(preferred_size_) :
224 gfx::Rect(initial_window_bounds.origin(), preferred_size_);
225 OnBeforePanelWidgetInit(use_default_bounds, &params, widget());
215 widget()->Init(params); 226 widget()->Init(params);
216 widget()->set_focus_on_creation(create_params.focused); 227 widget()->set_focus_on_creation(create_params.focused);
217 } 228 }
218 229
219 views::NonClientFrameView* 230 views::NonClientFrameView*
220 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() { 231 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() {
221 return views::WidgetDelegateView::CreateNonClientFrameView(widget()); 232 return views::WidgetDelegateView::CreateNonClientFrameView(widget());
222 } 233 }
223 234
224 apps::AppWindowFrameView* 235 apps::AppWindowFrameView*
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 InitializePanelWindow(create_params); 409 InitializePanelWindow(create_params);
399 } else { 410 } else {
400 InitializeDefaultWindow(create_params); 411 InitializeDefaultWindow(create_params);
401 } 412 }
402 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 413 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
403 Profile::FromBrowserContext(app_window->browser_context()), 414 Profile::FromBrowserContext(app_window->browser_context()),
404 widget()->GetFocusManager(), 415 widget()->GetFocusManager(),
405 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 416 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
406 NULL)); 417 NULL));
407 } 418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698