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

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

Issue 213743017: Remove title and icon from chrome apps native style title bars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed leak in test Created 6 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 "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/app_mode/app_mode_utils.h" 10 #include "chrome/browser/app_mode/app_mode_utils.h"
11 #include "chrome/browser/chrome_page_zoom.h" 11 #include "chrome/browser/chrome_page_zoom.h"
12 #include "chrome/browser/favicon/favicon_tab_helper.h" 12 #include "chrome/browser/favicon/favicon_tab_helper.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/host_desktop.h" 14 #include "chrome/browser/ui/host_desktop.h"
15 #include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h" 15 #include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h"
16 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" 16 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
17 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" 17 #include "chrome/browser/ui/views/frame/taskbar_decorator.h"
18 #include "chrome/browser/web_applications/web_app.h" 18 #include "chrome/browser/web_applications/web_app.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
21 #include "ui/aura/window.h"
21 #include "ui/base/hit_test.h" 22 #include "ui/base/hit_test.h"
22 #include "ui/base/models/simple_menu_model.h" 23 #include "ui/base/models/simple_menu_model.h"
23 #include "ui/gfx/image/image_skia.h" 24 #include "ui/gfx/image/image_skia.h"
24 #include "ui/views/controls/menu/menu_runner.h" 25 #include "ui/views/controls/menu/menu_runner.h"
25 #include "ui/views/controls/webview/webview.h" 26 #include "ui/views/controls/webview/webview.h"
26 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
27 #include "ui/wm/core/easy_resize_window_targeter.h" 28 #include "ui/wm/core/easy_resize_window_targeter.h"
28 #include "ui/wm/core/shadow_types.h" 29 #include "ui/wm/core/shadow_types.h"
29 30
30 #if defined(OS_LINUX) 31 #if defined(OS_LINUX)
31 #include "chrome/browser/shell_integration_linux.h" 32 #include "chrome/browser/shell_integration_linux.h"
32 #endif 33 #endif
33 34
34 #if defined(USE_ASH) 35 #if defined(USE_ASH)
35 #include "ash/ash_constants.h" 36 #include "ash/ash_constants.h"
36 #include "ash/ash_switches.h" 37 #include "ash/ash_switches.h"
37 #include "ash/frame/custom_frame_view_ash.h" 38 #include "ash/frame/custom_frame_view_ash.h"
38 #include "ash/screen_util.h" 39 #include "ash/screen_util.h"
39 #include "ash/shell.h" 40 #include "ash/shell.h"
40 #include "ash/wm/immersive_fullscreen_controller.h" 41 #include "ash/wm/immersive_fullscreen_controller.h"
41 #include "ash/wm/panels/panel_frame_view.h" 42 #include "ash/wm/panels/panel_frame_view.h"
42 #include "ash/wm/window_state.h" 43 #include "ash/wm/window_state.h"
43 #include "ash/wm/window_state_delegate.h" 44 #include "ash/wm/window_state_delegate.h"
44 #include "ash/wm/window_state_observer.h" 45 #include "ash/wm/window_state_observer.h"
45 #include "chrome/browser/ui/ash/ash_util.h" 46 #include "chrome/browser/ui/ash/ash_util.h"
46 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" 47 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h"
47 #include "ui/aura/client/aura_constants.h" 48 #include "ui/aura/client/aura_constants.h"
48 #include "ui/aura/client/window_tree_client.h" 49 #include "ui/aura/client/window_tree_client.h"
49 #include "ui/aura/window.h"
50 #include "ui/aura/window_observer.h" 50 #include "ui/aura/window_observer.h"
51 #endif 51 #endif
52 52
53 #if defined(USE_AURA)
54 #include "ui/aura/window.h"
55 #endif
56
57 using apps::AppWindow; 53 using apps::AppWindow;
58 54
59 namespace { 55 namespace {
60 56
61 const int kMinPanelWidth = 100; 57 const int kMinPanelWidth = 100;
62 const int kMinPanelHeight = 100; 58 const int kMinPanelHeight = 100;
63 const int kDefaultPanelWidth = 200; 59 const int kDefaultPanelWidth = 200;
64 const int kDefaultPanelHeight = 300; 60 const int kDefaultPanelHeight = 300;
65 const int kResizeInsideBoundsSize = 5;
66 const int kResizeAreaCornerSize = 16;
67 61
68 struct AcceleratorMapping { 62 struct AcceleratorMapping {
69 ui::KeyboardCode keycode; 63 ui::KeyboardCode keycode;
70 int modifiers; 64 int modifiers;
71 int command_id; 65 int command_id;
72 }; 66 };
73 67
74 const AcceleratorMapping kAppWindowAcceleratorMap[] = { 68 const AcceleratorMapping kAppWindowAcceleratorMap[] = {
75 { ui::VKEY_W, ui::EF_CONTROL_DOWN, IDC_CLOSE_WINDOW }, 69 { ui::VKEY_W, ui::EF_CONTROL_DOWN, IDC_CLOSE_WINDOW },
76 { ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_CLOSE_WINDOW }, 70 { ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_CLOSE_WINDOW },
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 native_window->GetRootWindow(), 333 native_window->GetRootWindow(),
340 native_window->GetBoundsInScreen()); 334 native_window->GetBoundsInScreen());
341 widget()->SetBounds(window_bounds); 335 widget()->SetBounds(window_bounds);
342 } 336 }
343 #else 337 #else
344 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other 338 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other
345 // platforms. 339 // platforms.
346 #endif 340 #endif
347 } 341 }
348 342
349 void ChromeNativeAppWindowViews::InstallEasyResizeTargeterOnContainer() const { 343 views::NonClientFrameView*
350 aura::Window* window = widget()->GetNativeWindow(); 344 ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() {
351 gfx::Insets inset(kResizeInsideBoundsSize, kResizeInsideBoundsSize, 345 return views::WidgetDelegateView::CreateNonClientFrameView(widget());
352 kResizeInsideBoundsSize, kResizeInsideBoundsSize);
353 // Add the EasyResizeWindowTargeter on the window, not its root window. The
354 // root window does not have a delegate, which is needed to handle the event
355 // in Linux.
356 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
357 new wm::EasyResizeWindowTargeter(window, inset, inset)));
358 } 346 }
359 347
360 apps::AppWindowFrameView* 348 apps::AppWindowFrameView*
361 ChromeNativeAppWindowViews::CreateAppWindowFrameView() { 349 ChromeNativeAppWindowViews::CreateNonStandardAppFrame() {
362 // By default the user can resize the window from slightly inside the bounds. 350 apps::AppWindowFrameView* frame = new apps::AppWindowFrameView(
363 int resize_inside_bounds_size = kResizeInsideBoundsSize; 351 widget(), this, has_frame_color_, frame_color_);
364 int resize_outside_bounds_size = 0; 352 frame->Init();
365 int resize_outside_scale_for_touch = 1;
366 int resize_area_corner_size = kResizeAreaCornerSize;
367 #if defined(USE_ASH) 353 #if defined(USE_ASH)
368 // For Aura windows on the Ash desktop the sizes are different and the user 354 // For Aura windows on the Ash desktop the sizes are different and the user
369 // can resize the window from slightly outside the bounds as well. 355 // can resize the window from slightly outside the bounds as well.
370 if (chrome::IsNativeWindowInAsh(widget()->GetNativeWindow())) { 356 if (chrome::IsNativeWindowInAsh(widget()->GetNativeWindow())) {
371 resize_inside_bounds_size = ash::kResizeInsideBoundsSize; 357 frame->SetResizeSizes(ash::kResizeInsideBoundsSize,
372 resize_outside_bounds_size = ash::kResizeOutsideBoundsSize; 358 ash::kResizeOutsideBoundsSize,
373 resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch; 359 ash::kResizeAreaCornerSize);
374 resize_area_corner_size = ash::kResizeAreaCornerSize;
375 } 360 }
376 #endif 361 #endif
377 apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView(); 362
378 frame_view->Init(widget(), 363 #if !defined(OS_CHROMEOS)
379 this, 364 // For non-Ash windows, install an easy resize window targeter, which ensures
380 has_frame_color_, 365 // that the root window (not the app) receives mouse events on the edges.
381 frame_color_, 366 if (chrome::GetHostDesktopTypeForNativeWindow(widget()->GetNativeWindow()) !=
382 resize_inside_bounds_size, 367 chrome::HOST_DESKTOP_TYPE_ASH) {
383 resize_outside_bounds_size, 368 aura::Window* window = widget()->GetNativeWindow();
384 resize_outside_scale_for_touch, 369 int resize_inside = frame->resize_inside_bounds_size();
385 resize_area_corner_size); 370 gfx::Insets inset(
386 return frame_view; 371 resize_inside, resize_inside, resize_inside, resize_inside);
372 // Add the EasyResizeWindowTargeter on the window, not its root window. The
373 // root window does not have a delegate, which is needed to handle the event
374 // in Linux.
375 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
376 new wm::EasyResizeWindowTargeter(window, inset, inset)));
377 }
378 #endif
379
380 return frame;
387 } 381 }
388 382
389 // ui::BaseWindow implementation. 383 // ui::BaseWindow implementation.
390 384
391 ui::WindowShowState ChromeNativeAppWindowViews::GetRestoredState() const { 385 ui::WindowShowState ChromeNativeAppWindowViews::GetRestoredState() const {
392 if (IsMaximized()) 386 if (IsMaximized())
393 return ui::SHOW_STATE_MAXIMIZED; 387 return ui::SHOW_STATE_MAXIMIZED;
394 if (IsFullscreen()) { 388 if (IsFullscreen()) {
395 #if defined(USE_ASH) 389 #if defined(USE_ASH)
396 if (immersive_fullscreen_controller_.get() && 390 if (immersive_fullscreen_controller_.get() &&
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 497
504 if (app_window()->window_type_is_panel()) { 498 if (app_window()->window_type_is_panel()) {
505 ash::PanelFrameView::FrameType frame_type = IsFrameless() ? 499 ash::PanelFrameView::FrameType frame_type = IsFrameless() ?
506 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH; 500 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
507 views::NonClientFrameView* frame_view = 501 views::NonClientFrameView* frame_view =
508 new ash::PanelFrameView(widget, frame_type); 502 new ash::PanelFrameView(widget, frame_type);
509 frame_view->set_context_menu_controller(this); 503 frame_view->set_context_menu_controller(this);
510 return frame_view; 504 return frame_view;
511 } 505 }
512 506
513 if (!IsFrameless()) { 507 if (IsFrameless())
514 ash::CustomFrameViewAsh* custom_frame_view = 508 return CreateNonStandardAppFrame();
515 new ash::CustomFrameViewAsh(widget); 509
516 // Non-frameless app windows can be put into immersive fullscreen. 510 ash::CustomFrameViewAsh* custom_frame_view =
517 immersive_fullscreen_controller_.reset( 511 new ash::CustomFrameViewAsh(widget);
518 new ash::ImmersiveFullscreenController()); 512 #if defined(OS_CHROMEOS)
519 custom_frame_view->InitImmersiveFullscreenControllerForView( 513 // Non-frameless app windows can be put into immersive fullscreen.
520 immersive_fullscreen_controller_.get()); 514 // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for
521 custom_frame_view->GetHeaderView()->set_context_menu_controller(this); 515 // Windows Ash.
522 return custom_frame_view; 516 immersive_fullscreen_controller_.reset(
523 } 517 new ash::ImmersiveFullscreenController());
518 custom_frame_view->InitImmersiveFullscreenControllerForView(
519 immersive_fullscreen_controller_.get());
520 #endif
521 custom_frame_view->GetHeaderView()->set_context_menu_controller(this);
522 return custom_frame_view;
524 } 523 }
525 #endif 524 #endif
526 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 525 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
527 return CreateAppWindowFrameView(); 526 // Linux always uses the non standard frame view because the OS draws the
527 // frame (if a frame is needed).
528 return CreateNonStandardAppFrame();
528 #else 529 #else
529 if (IsFrameless() || has_frame_color_) 530 if (IsFrameless() || has_frame_color_)
530 return CreateAppWindowFrameView(); 531 return CreateNonStandardAppFrame();
531 #endif 532 #endif
532 return views::WidgetDelegateView::CreateNonClientFrameView(widget); 533 return CreateStandardDesktopAppFrame();
533 } 534 }
534 535
535 bool ChromeNativeAppWindowViews::WidgetHasHitTestMask() const { 536 bool ChromeNativeAppWindowViews::WidgetHasHitTestMask() const {
536 return shape_ != NULL; 537 return shape_ != NULL;
537 } 538 }
538 539
539 void ChromeNativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const { 540 void ChromeNativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const {
540 shape_->getBoundaryPath(mask); 541 shape_->getBoundaryPath(mask);
541 } 542 }
542 543
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) { 679 create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) {
679 InitializePanelWindow(create_params); 680 InitializePanelWindow(create_params);
680 } else { 681 } else {
681 InitializeDefaultWindow(create_params); 682 InitializeDefaultWindow(create_params);
682 } 683 }
683 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 684 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
684 Profile::FromBrowserContext(app_window->browser_context()), 685 Profile::FromBrowserContext(app_window->browser_context()),
685 widget()->GetFocusManager(), 686 widget()->GetFocusManager(),
686 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 687 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
687 NULL)); 688 NULL));
688
689 #if !defined(OS_CHROMEOS)
690 if ((IsFrameless() || has_frame_color_) &&
691 chrome::GetHostDesktopTypeForNativeWindow(widget()->GetNativeWindow()) !=
692 chrome::HOST_DESKTOP_TYPE_ASH) {
693 InstallEasyResizeTargeterOnContainer();
694 }
695 #endif
696 } 689 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698