| OLD | NEW |
| 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/frame/desktop_browser_frame_aura.h" | 5 #include "chrome/browser/ui/views/frame/desktop_browser_frame_aura.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 8 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host.h" | 8 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_shutdown.h" | 9 #include "chrome/browser/ui/views/frame/browser_shutdown.h" |
| 11 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 12 #include "chrome/browser/web_applications/web_app.h" | 11 #include "chrome/browser/web_applications/web_app.h" |
| 13 #include "chrome/common/chrome_switches.h" | |
| 14 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
| 18 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 19 #include "ui/base/models/simple_menu_model.h" | 17 #include "ui/base/models/simple_menu_model.h" |
| 20 #include "ui/gfx/font.h" | 18 #include "ui/gfx/font.h" |
| 21 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 20 #include "ui/views/widget/widget.h" |
| 22 #include "ui/wm/core/visibility_controller.h" | 21 #include "ui/wm/core/visibility_controller.h" |
| 23 | 22 |
| 24 #if defined(OS_LINUX) | |
| 25 #include "chrome/browser/shell_integration_linux.h" | |
| 26 #endif | |
| 27 | |
| 28 using aura::Window; | 23 using aura::Window; |
| 29 | 24 |
| 30 /////////////////////////////////////////////////////////////////////////////// | 25 /////////////////////////////////////////////////////////////////////////////// |
| 31 // DesktopBrowserFrameAura, public: | 26 // DesktopBrowserFrameAura, public: |
| 32 | 27 |
| 33 DesktopBrowserFrameAura::DesktopBrowserFrameAura( | 28 DesktopBrowserFrameAura::DesktopBrowserFrameAura( |
| 34 BrowserFrame* browser_frame, | 29 BrowserFrame* browser_frame, |
| 35 BrowserView* browser_view) | 30 BrowserView* browser_view) |
| 36 : views::DesktopNativeWidgetAura(browser_frame), | 31 : views::DesktopNativeWidgetAura(browser_frame), |
| 37 browser_view_(browser_view), | 32 browser_view_(browser_view), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 wm::SetChildWindowVisibilityChangesAnimated( | 72 wm::SetChildWindowVisibilityChangesAnimated( |
| 78 GetNativeView()->GetRootWindow()); | 73 GetNativeView()->GetRootWindow()); |
| 79 } | 74 } |
| 80 | 75 |
| 81 //////////////////////////////////////////////////////////////////////////////// | 76 //////////////////////////////////////////////////////////////////////////////// |
| 82 // DesktopBrowserFrameAura, NativeBrowserFrame implementation: | 77 // DesktopBrowserFrameAura, NativeBrowserFrame implementation: |
| 83 | 78 |
| 84 views::Widget::InitParams DesktopBrowserFrameAura::GetWidgetParams() { | 79 views::Widget::InitParams DesktopBrowserFrameAura::GetWidgetParams() { |
| 85 views::Widget::InitParams params; | 80 views::Widget::InitParams params; |
| 86 params.native_widget = this; | 81 params.native_widget = this; |
| 82 return params; |
| 83 } |
| 87 | 84 |
| 88 #if defined(OS_LINUX) | 85 bool DesktopBrowserFrameAura::UseCustomFrame() const { |
| 89 // Set up a custom WM_CLASS for some sorts of window types. This allows | 86 return true; |
| 90 // task switchers in X11 environments to distinguish between main browser | |
| 91 // windows and e.g app windows. | |
| 92 const base::CommandLine& command_line = | |
| 93 *base::CommandLine::ForCurrentProcess(); | |
| 94 const Browser& browser = *browser_view_->browser(); | |
| 95 params.wm_class_class = shell_integration_linux::GetProgramClassName(); | |
| 96 params.wm_class_name = params.wm_class_class; | |
| 97 if (browser.is_app() && !browser.is_devtools()) { | |
| 98 // This window is a hosted app or v1 packaged app. | |
| 99 // NOTE: v2 packaged app windows are created by ChromeNativeAppWindowViews. | |
| 100 params.wm_class_name = web_app::GetWMClassFromAppName(browser.app_name()); | |
| 101 } else if (command_line.HasSwitch(switches::kUserDataDir)) { | |
| 102 // Set the class name to e.g. "Chrome (/tmp/my-user-data)". The | |
| 103 // class name will show up in the alt-tab list in gnome-shell if | |
| 104 // you're running a binary that doesn't have a matching .desktop | |
| 105 // file. | |
| 106 const std::string user_data_dir = | |
| 107 command_line.GetSwitchValueNative(switches::kUserDataDir); | |
| 108 params.wm_class_name += " (" + user_data_dir + ")"; | |
| 109 } | |
| 110 const char kX11WindowRoleBrowser[] = "browser"; | |
| 111 const char kX11WindowRolePopup[] = "pop-up"; | |
| 112 params.wm_role_name = browser_view_->browser()->is_type_tabbed() ? | |
| 113 std::string(kX11WindowRoleBrowser) : std::string(kX11WindowRolePopup); | |
| 114 params.remove_standard_frame = browser_frame_->UseCustomFrame(); | |
| 115 #endif // defined(OS_LINUX) | |
| 116 | |
| 117 return params; | |
| 118 } | 87 } |
| 119 | 88 |
| 120 bool DesktopBrowserFrameAura::UsesNativeSystemMenu() const { | 89 bool DesktopBrowserFrameAura::UsesNativeSystemMenu() const { |
| 121 return browser_desktop_window_tree_host_->UsesNativeSystemMenu(); | 90 return browser_desktop_window_tree_host_->UsesNativeSystemMenu(); |
| 122 } | 91 } |
| 123 | 92 |
| 124 int DesktopBrowserFrameAura::GetMinimizeButtonOffset() const { | 93 int DesktopBrowserFrameAura::GetMinimizeButtonOffset() const { |
| 125 return browser_desktop_window_tree_host_->GetMinimizeButtonOffset(); | 94 return browser_desktop_window_tree_host_->GetMinimizeButtonOffset(); |
| 126 } | 95 } |
| 127 | 96 |
| 128 bool DesktopBrowserFrameAura::ShouldSaveWindowPlacement() const { | 97 bool DesktopBrowserFrameAura::ShouldSaveWindowPlacement() const { |
| 129 // The placement can always be stored. | 98 // The placement can always be stored. |
| 130 return true; | 99 return true; |
| 131 } | 100 } |
| 132 | 101 |
| 133 void DesktopBrowserFrameAura::GetWindowPlacement( | 102 void DesktopBrowserFrameAura::GetWindowPlacement( |
| 134 gfx::Rect* bounds, | 103 gfx::Rect* bounds, |
| 135 ui::WindowShowState* show_state) const { | 104 ui::WindowShowState* show_state) const { |
| 136 *bounds = GetWidget()->GetRestoredBounds(); | 105 *bounds = GetWidget()->GetRestoredBounds(); |
| 137 if (IsMaximized()) | 106 if (IsMaximized()) |
| 138 *show_state = ui::SHOW_STATE_MAXIMIZED; | 107 *show_state = ui::SHOW_STATE_MAXIMIZED; |
| 139 else if (IsMinimized()) | 108 else if (IsMinimized()) |
| 140 *show_state = ui::SHOW_STATE_MINIMIZED; | 109 *show_state = ui::SHOW_STATE_MINIMIZED; |
| 141 else | 110 else |
| 142 *show_state = ui::SHOW_STATE_NORMAL; | 111 *show_state = ui::SHOW_STATE_NORMAL; |
| 143 } | 112 } |
| OLD | NEW |