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

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 (rebased) Created 5 years, 8 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 OnBeforeWidgetInit(create_params, &init_params, widget()); 135 OnBeforeWidgetInit(create_params, &init_params, widget());
136 widget()->Init(init_params); 136 widget()->Init(init_params);
137 137
138 // The frame insets are required to resolve the bounds specifications 138 // The frame insets are required to resolve the bounds specifications
139 // correctly. So we set the window bounds and constraints now. 139 // correctly. So we set the window bounds and constraints now.
140 gfx::Insets frame_insets = GetFrameInsets(); 140 gfx::Insets frame_insets = GetFrameInsets();
141 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); 141 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets);
142 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), 142 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets),
143 create_params.GetContentMaximumSize(frame_insets)); 143 create_params.GetContentMaximumSize(frame_insets));
144 if (!window_bounds.IsEmpty()) { 144 if (!window_bounds.IsEmpty()) {
145 typedef AppWindow::BoundsSpecification BoundsSpecification; 145 using BoundsSpecification = AppWindow::BoundsSpecification;
146 bool position_specified = 146 bool position_specified =
147 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && 147 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition &&
148 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; 148 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition;
149 if (!position_specified) 149 if (!position_specified)
150 widget()->CenterWindow(window_bounds.size()); 150 widget()->CenterWindow(window_bounds.size());
151 else 151 else
152 widget()->SetBounds(window_bounds); 152 widget()->SetBounds(window_bounds);
153 } 153 }
154 154
155 #if defined(OS_CHROMEOS) 155 #if defined(OS_CHROMEOS)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (preferred_size_.width() == 0) 203 if (preferred_size_.width() == 0)
204 preferred_size_.set_width(kDefaultPanelWidth); 204 preferred_size_.set_width(kDefaultPanelWidth);
205 else if (preferred_size_.width() < kMinPanelWidth) 205 else if (preferred_size_.width() < kMinPanelWidth)
206 preferred_size_.set_width(kMinPanelWidth); 206 preferred_size_.set_width(kMinPanelWidth);
207 207
208 if (preferred_size_.height() == 0) 208 if (preferred_size_.height() == 0)
209 preferred_size_.set_height(kDefaultPanelHeight); 209 preferred_size_.set_height(kDefaultPanelHeight);
210 else if (preferred_size_.height() < kMinPanelHeight) 210 else if (preferred_size_.height() < kMinPanelHeight)
211 preferred_size_.set_height(kMinPanelHeight); 211 preferred_size_.set_height(kMinPanelHeight);
212 212
213 params.bounds = gfx::Rect(preferred_size_); 213 // When a panel is not docked |initial_window_bounds|'s origin is reset to
214 // |kUnspecifiedPosition| to trigger placing it in the currently active
215 // target root window.
216 using BoundsSpecification = AppWindow::BoundsSpecification;
217 if (create_params.state != ui::SHOW_STATE_DOCKED) {
218 initial_window_bounds.set_origin(
219 gfx::Point(BoundsSpecification::kUnspecifiedPosition,
220 BoundsSpecification::kUnspecifiedPosition));
221 }
222 params.bounds = gfx::Rect(initial_window_bounds.origin(), preferred_size_);
benwells 2015/04/28 23:46:01 This logic is a bit hard to follow. I can see that
varkha 2015/04/29 16:54:16 Done.
214 OnBeforePanelWidgetInit(&params, widget()); 223 OnBeforePanelWidgetInit(&params, widget());
224 bool position_specified =
225 params.bounds.x() != BoundsSpecification::kUnspecifiedPosition &&
226 params.bounds.y() != BoundsSpecification::kUnspecifiedPosition;
227 if (!position_specified)
228 params.bounds = gfx::Rect(preferred_size_);
215 widget()->Init(params); 229 widget()->Init(params);
216 widget()->set_focus_on_creation(create_params.focused); 230 widget()->set_focus_on_creation(create_params.focused);
217 } 231 }
218 232
219 views::NonClientFrameView* 233 views::NonClientFrameView*
220 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() { 234 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() {
221 return views::WidgetDelegateView::CreateNonClientFrameView(widget()); 235 return views::WidgetDelegateView::CreateNonClientFrameView(widget());
222 } 236 }
223 237
224 apps::AppWindowFrameView* 238 apps::AppWindowFrameView*
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 InitializePanelWindow(create_params); 412 InitializePanelWindow(create_params);
399 } else { 413 } else {
400 InitializeDefaultWindow(create_params); 414 InitializeDefaultWindow(create_params);
401 } 415 }
402 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 416 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
403 Profile::FromBrowserContext(app_window->browser_context()), 417 Profile::FromBrowserContext(app_window->browser_context()),
404 widget()->GetFocusManager(), 418 widget()->GetFocusManager(),
405 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 419 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
406 NULL)); 420 NULL));
407 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698