| 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" | |
| 13 #include "chrome/common/chrome_switches.h" | |
| 14 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 18 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
| 19 #include "ui/base/models/simple_menu_model.h" | 16 #include "ui/base/models/simple_menu_model.h" |
| 20 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
| 21 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 22 #include "ui/wm/core/visibility_controller.h" | 19 #include "ui/wm/core/visibility_controller.h" |
| 23 | 20 |
| 24 #if defined(OS_LINUX) | |
| 25 #include "chrome/browser/shell_integration_linux.h" | |
| 26 #endif | |
| 27 | |
| 28 using aura::Window; | 21 using aura::Window; |
| 29 | 22 |
| 30 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
| 31 // DesktopBrowserFrameAura, public: | 24 // DesktopBrowserFrameAura, public: |
| 32 | 25 |
| 33 DesktopBrowserFrameAura::DesktopBrowserFrameAura( | 26 DesktopBrowserFrameAura::DesktopBrowserFrameAura( |
| 34 BrowserFrame* browser_frame, | 27 BrowserFrame* browser_frame, |
| 35 BrowserView* browser_view) | 28 BrowserView* browser_view) |
| 36 : views::DesktopNativeWidgetAura(browser_frame), | 29 : views::DesktopNativeWidgetAura(browser_frame), |
| 37 browser_view_(browser_view), | 30 browser_view_(browser_view), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 visibility_controller_.reset(new wm::VisibilityController); | 67 visibility_controller_.reset(new wm::VisibilityController); |
| 75 aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), | 68 aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), |
| 76 visibility_controller_.get()); | 69 visibility_controller_.get()); |
| 77 wm::SetChildWindowVisibilityChangesAnimated( | 70 wm::SetChildWindowVisibilityChangesAnimated( |
| 78 GetNativeView()->GetRootWindow()); | 71 GetNativeView()->GetRootWindow()); |
| 79 } | 72 } |
| 80 | 73 |
| 81 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
| 82 // DesktopBrowserFrameAura, NativeBrowserFrame implementation: | 75 // DesktopBrowserFrameAura, NativeBrowserFrame implementation: |
| 83 | 76 |
| 84 views::Widget::InitParams DesktopBrowserFrameAura::GetWidgetParams() { | 77 views::NativeWidget* DesktopBrowserFrameAura::AsNativeWidget() { |
| 85 views::Widget::InitParams params; | 78 return this; |
| 86 params.native_widget = this; | 79 } |
| 87 | 80 |
| 88 #if defined(OS_LINUX) | 81 const views::NativeWidget* DesktopBrowserFrameAura::AsNativeWidget() const { |
| 89 // Set up a custom WM_CLASS for some sorts of window types. This allows | 82 return this; |
| 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 #endif // defined(OS_LINUX) | |
| 115 | |
| 116 return params; | |
| 117 } | 83 } |
| 118 | 84 |
| 119 bool DesktopBrowserFrameAura::UsesNativeSystemMenu() const { | 85 bool DesktopBrowserFrameAura::UsesNativeSystemMenu() const { |
| 120 return browser_desktop_window_tree_host_->UsesNativeSystemMenu(); | 86 return browser_desktop_window_tree_host_->UsesNativeSystemMenu(); |
| 121 } | 87 } |
| 122 | 88 |
| 123 int DesktopBrowserFrameAura::GetMinimizeButtonOffset() const { | 89 int DesktopBrowserFrameAura::GetMinimizeButtonOffset() const { |
| 124 return browser_desktop_window_tree_host_->GetMinimizeButtonOffset(); | 90 return browser_desktop_window_tree_host_->GetMinimizeButtonOffset(); |
| 125 } | 91 } |
| 126 | 92 |
| 127 bool DesktopBrowserFrameAura::ShouldSaveWindowPlacement() const { | 93 bool DesktopBrowserFrameAura::ShouldSaveWindowPlacement() const { |
| 128 // The placement can always be stored. | 94 // The placement can always be stored. |
| 129 return true; | 95 return true; |
| 130 } | 96 } |
| 131 | 97 |
| 132 void DesktopBrowserFrameAura::GetWindowPlacement( | 98 void DesktopBrowserFrameAura::GetWindowPlacement( |
| 133 gfx::Rect* bounds, | 99 gfx::Rect* bounds, |
| 134 ui::WindowShowState* show_state) const { | 100 ui::WindowShowState* show_state) const { |
| 135 *bounds = GetWidget()->GetRestoredBounds(); | 101 *bounds = GetWidget()->GetRestoredBounds(); |
| 136 if (IsMaximized()) | 102 if (IsMaximized()) |
| 137 *show_state = ui::SHOW_STATE_MAXIMIZED; | 103 *show_state = ui::SHOW_STATE_MAXIMIZED; |
| 138 else if (IsMinimized()) | 104 else if (IsMinimized()) |
| 139 *show_state = ui::SHOW_STATE_MINIMIZED; | 105 *show_state = ui::SHOW_STATE_MINIMIZED; |
| 140 else | 106 else |
| 141 *show_state = ui::SHOW_STATE_NORMAL; | 107 *show_state = ui::SHOW_STATE_NORMAL; |
| 142 } | 108 } |
| OLD | NEW |