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