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

Side by Side Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 1336823003: Move chrome::HostDesktopType to ui::HostDesktopType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_session_service_delegate_impl
Patch Set: Fix build on Mac and CrOS Created 5 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_views_delegate.h" 5 #include "chrome/browser/ui/views/chrome_views_delegate.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 bool maximized = false; 195 bool maximized = false;
196 if (dictionary) 196 if (dictionary)
197 dictionary->GetBoolean("maximized", &maximized); 197 dictionary->GetBoolean("maximized", &maximized);
198 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL; 198 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL;
199 199
200 #if defined(USE_ASH) 200 #if defined(USE_ASH)
201 // On Ash environment, a window won't span across displays. Adjust 201 // On Ash environment, a window won't span across displays. Adjust
202 // the bounds to fit the work area. 202 // the bounds to fit the work area.
203 gfx::NativeView window = widget->GetNativeView(); 203 gfx::NativeView window = widget->GetNativeView();
204 if (chrome::GetHostDesktopTypeForNativeView(window) == 204 if (chrome::GetHostDesktopTypeForNativeView(window) ==
205 chrome::HOST_DESKTOP_TYPE_ASH) { 205 ui::HOST_DESKTOP_TYPE_ASH) {
206 gfx::Display display = gfx::Screen::GetScreenFor(window)-> 206 gfx::Display display = gfx::Screen::GetScreenFor(window)->
207 GetDisplayMatching(*bounds); 207 GetDisplayMatching(*bounds);
208 bounds->AdjustToFit(display.work_area()); 208 bounds->AdjustToFit(display.work_area());
209 ash::wm::GetWindowState(window)->set_minimum_visibility(true); 209 ash::wm::GetWindowState(window)->set_minimum_visibility(true);
210 } 210 }
211 #endif 211 #endif
212 return true; 212 return true;
213 } 213 }
214 214
215 void ChromeViewsDelegate::NotifyAccessibilityEvent( 215 void ChromeViewsDelegate::NotifyAccessibilityEvent(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 #if defined(OS_WIN) 277 #if defined(OS_WIN)
278 // On desktop Linux Chrome must run in an environment that supports a variety 278 // On desktop Linux Chrome must run in an environment that supports a variety
279 // of window managers, some of which do not play nicely with parts of our UI 279 // of window managers, some of which do not play nicely with parts of our UI
280 // that have specific expectations about window sizing and placement. For this 280 // that have specific expectations about window sizing and placement. For this
281 // reason windows opened as top level (!params.child) are always constrained 281 // reason windows opened as top level (!params.child) are always constrained
282 // by the browser frame, so we can position them correctly. This has some 282 // by the browser frame, so we can position them correctly. This has some
283 // negative side effects, like dialogs being clipped by the browser frame, but 283 // negative side effects, like dialogs being clipped by the browser frame, but
284 // the side effects are not as bad as the poor window manager interactions. On 284 // the side effects are not as bad as the poor window manager interactions. On
285 // Windows however these WM interactions are not an issue, so we open windows 285 // Windows however these WM interactions are not an issue, so we open windows
286 // requested as top_level as actual top level windows on the desktop. 286 // requested as top_level as actual top level windows on the desktop.
287 use_non_toplevel_window = use_non_toplevel_window && 287 use_non_toplevel_window =
288 use_non_toplevel_window &&
288 (params->child || 289 (params->child ||
289 chrome::GetHostDesktopTypeForNativeView(params->parent) != 290 chrome::GetHostDesktopTypeForNativeView(params->parent) !=
290 chrome::HOST_DESKTOP_TYPE_NATIVE); 291 ui::HOST_DESKTOP_TYPE_NATIVE);
291 292
292 if (!ui::win::IsAeroGlassEnabled()) { 293 if (!ui::win::IsAeroGlassEnabled()) {
293 // If we don't have composition (either because Glass is not enabled or 294 // If we don't have composition (either because Glass is not enabled or
294 // because it was disabled at the command line), anything that requires 295 // because it was disabled at the command line), anything that requires
295 // transparency will be broken with a toplevel window, so force the use of 296 // transparency will be broken with a toplevel window, so force the use of
296 // a non toplevel window. 297 // a non toplevel window.
297 if (params->opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW && 298 if (params->opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW &&
298 params->type != views::Widget::InitParams::TYPE_MENU) 299 params->type != views::Widget::InitParams::TYPE_MENU)
299 use_non_toplevel_window = true; 300 use_non_toplevel_window = true;
300 } else { 301 } else {
301 // If we're on Vista+ with composition enabled, then we can use toplevel 302 // If we're on Vista+ with composition enabled, then we can use toplevel
302 // windows for most things (they get blended via WS_EX_COMPOSITED, which 303 // windows for most things (they get blended via WS_EX_COMPOSITED, which
303 // allows for animation effects, but also exceeding the bounds of the parent 304 // allows for animation effects, but also exceeding the bounds of the parent
304 // window). 305 // window).
305 if (chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH && 306 if (chrome::GetActiveDesktop() != ui::HOST_DESKTOP_TYPE_ASH &&
306 params->parent && 307 params->parent &&
307 params->type != views::Widget::InitParams::TYPE_CONTROL && 308 params->type != views::Widget::InitParams::TYPE_CONTROL &&
308 params->type != views::Widget::InitParams::TYPE_WINDOW) { 309 params->type != views::Widget::InitParams::TYPE_WINDOW) {
309 // When we set this to false, we get a DesktopNativeWidgetAura from the 310 // When we set this to false, we get a DesktopNativeWidgetAura from the
310 // default case (not handled in this function). 311 // default case (not handled in this function).
311 use_non_toplevel_window = false; 312 use_non_toplevel_window = false;
312 } 313 }
313 } 314 }
314 #endif // OS_WIN 315 #endif // OS_WIN
315 #endif // USE_AURA 316 #endif // USE_AURA
(...skipping 12 matching lines...) Expand all
328 if (!params->parent && !params->context) 329 if (!params->parent && !params->context)
329 params->context = ash::Shell::GetPrimaryRootWindow(); 330 params->context = ash::Shell::GetPrimaryRootWindow();
330 #elif defined(USE_AURA) 331 #elif defined(USE_AURA)
331 // While the majority of the time, context wasn't plumbed through due to the 332 // While the majority of the time, context wasn't plumbed through due to the
332 // existence of a global WindowTreeClient, if this window is toplevel, it's 333 // existence of a global WindowTreeClient, if this window is toplevel, it's
333 // possible that there is no contextual state that we can use. 334 // possible that there is no contextual state that we can use.
334 if (params->parent == NULL && params->context == NULL && !params->child) { 335 if (params->parent == NULL && params->context == NULL && !params->child) {
335 // We need to make a decision about where to place this window based on the 336 // We need to make a decision about where to place this window based on the
336 // desktop type. 337 // desktop type.
337 switch (chrome::GetActiveDesktop()) { 338 switch (chrome::GetActiveDesktop()) {
338 case chrome::HOST_DESKTOP_TYPE_NATIVE: 339 case ui::HOST_DESKTOP_TYPE_NATIVE:
339 // If we're native, we should give this window its own toplevel desktop 340 // If we're native, we should give this window its own toplevel desktop
340 // widget. 341 // widget.
341 params->native_widget = new views::DesktopNativeWidgetAura(delegate); 342 params->native_widget = new views::DesktopNativeWidgetAura(delegate);
342 break; 343 break;
343 #if defined(USE_ASH) 344 #if defined(USE_ASH)
344 case chrome::HOST_DESKTOP_TYPE_ASH: 345 case ui::HOST_DESKTOP_TYPE_ASH:
345 // If we're in ash, give this window the context of the main monitor. 346 // If we're in ash, give this window the context of the main monitor.
346 params->context = ash::Shell::GetPrimaryRootWindow(); 347 params->context = ash::Shell::GetPrimaryRootWindow();
347 break; 348 break;
348 #endif 349 #endif
349 default: 350 default:
350 NOTREACHED(); 351 NOTREACHED();
351 } 352 }
352 } else if (use_non_toplevel_window) { 353 } else if (use_non_toplevel_window) {
353 views::NativeWidgetAura* native_widget = 354 views::NativeWidgetAura* native_widget =
354 new views::NativeWidgetAura(delegate); 355 new views::NativeWidgetAura(delegate);
355 if (params->parent) { 356 if (params->parent) {
356 Profile* parent_profile = reinterpret_cast<Profile*>( 357 Profile* parent_profile = reinterpret_cast<Profile*>(
357 params->parent->GetNativeWindowProperty(Profile::kProfileKey)); 358 params->parent->GetNativeWindowProperty(Profile::kProfileKey));
358 native_widget->SetNativeWindowProperty(Profile::kProfileKey, 359 native_widget->SetNativeWindowProperty(Profile::kProfileKey,
359 parent_profile); 360 parent_profile);
360 } 361 }
361 params->native_widget = native_widget; 362 params->native_widget = native_widget;
362 } else { 363 } else {
363 // TODO(erg): Once we've threaded context to everywhere that needs it, we 364 // TODO(erg): Once we've threaded context to everywhere that needs it, we
364 // should remove this check here. 365 // should remove this check here.
365 gfx::NativeView to_check = 366 gfx::NativeView to_check =
366 params->context ? params->context : params->parent; 367 params->context ? params->context : params->parent;
367 if (chrome::GetHostDesktopTypeForNativeView(to_check) == 368 if (chrome::GetHostDesktopTypeForNativeView(to_check) ==
368 chrome::HOST_DESKTOP_TYPE_NATIVE) { 369 ui::HOST_DESKTOP_TYPE_NATIVE) {
369 params->native_widget = new views::DesktopNativeWidgetAura(delegate); 370 params->native_widget = new views::DesktopNativeWidgetAura(delegate);
370 } 371 }
371 } 372 }
372 #endif 373 #endif
373 } 374 }
374 375
375 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 376 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
376 bool ChromeViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { 377 bool ChromeViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) {
377 // On Ubuntu Unity, the system always provides a title bar for maximized 378 // On Ubuntu Unity, the system always provides a title bar for maximized
378 // windows. 379 // windows.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 return content::BrowserThread::GetBlockingPool(); 435 return content::BrowserThread::GetBlockingPool();
435 } 436 }
436 437
437 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) 438 #if !defined(USE_AURA) && !defined(USE_CHROMEOS)
438 views::Widget::InitParams::WindowOpacity 439 views::Widget::InitParams::WindowOpacity
439 ChromeViewsDelegate::GetOpacityForInitParams( 440 ChromeViewsDelegate::GetOpacityForInitParams(
440 const views::Widget::InitParams& params) { 441 const views::Widget::InitParams& params) {
441 return views::Widget::InitParams::OPAQUE_WINDOW; 442 return views::Widget::InitParams::OPAQUE_WINDOW;
442 } 443 }
443 #endif 444 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698