Chromium Code Reviews| 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/browser_frame.h" | 5 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/command_line.h" | |
| 8 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 9 #include "chrome/browser/app_mode/app_mode_utils.h" | 10 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 11 #include "chrome/browser/shell_integration.h" | |
| 10 #include "chrome/browser/themes/theme_service.h" | 12 #include "chrome/browser/themes/theme_service.h" |
| 11 #include "chrome/browser/themes/theme_service_factory.h" | 13 #include "chrome/browser/themes/theme_service_factory.h" |
| 12 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 14 #include "chrome/browser/ui/browser_window_state.h" | 16 #include "chrome/browser/ui/browser_window_state.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_root_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_root_view.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 18 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 20 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 19 #include "chrome/browser/ui/views/frame/native_browser_frame.h" | 21 #include "chrome/browser/ui/views/frame/native_browser_frame.h" |
| 20 #include "chrome/browser/ui/views/frame/system_menu_model_builder.h" | 22 #include "chrome/browser/ui/views/frame/system_menu_model_builder.h" |
| 21 #include "chrome/browser/ui/views/frame/top_container_view.h" | 23 #include "chrome/browser/ui/views/frame/top_container_view.h" |
| 24 #include "chrome/browser/web_applications/web_app.h" | |
| 22 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 23 #include "ui/aura/root_window.h" | 26 #include "ui/aura/root_window.h" |
| 24 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 25 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
| 26 #include "ui/base/theme_provider.h" | 29 #include "ui/base/theme_provider.h" |
| 27 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
| 28 #include "ui/views/controls/menu/menu_runner.h" | 31 #include "ui/views/controls/menu/menu_runner.h" |
| 29 #include "ui/views/widget/native_widget.h" | 32 #include "ui/views/widget/native_widget.h" |
| 30 | 33 |
| 31 #if defined(OS_WIN) && !defined(USE_AURA) | 34 #if defined(OS_WIN) && !defined(USE_AURA) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 chrome::GetSavedWindowBoundsAndShowState(browser_view_->browser(), | 70 chrome::GetSavedWindowBoundsAndShowState(browser_view_->browser(), |
| 68 ¶ms.bounds, | 71 ¶ms.bounds, |
| 69 ¶ms.show_state); | 72 ¶ms.show_state); |
| 70 } | 73 } |
| 71 #if defined(USE_ASH) | 74 #if defined(USE_ASH) |
| 72 if (browser_view_->browser()->host_desktop_type() == | 75 if (browser_view_->browser()->host_desktop_type() == |
| 73 chrome::HOST_DESKTOP_TYPE_ASH || chrome::ShouldOpenAshOnStartup()) { | 76 chrome::HOST_DESKTOP_TYPE_ASH || chrome::ShouldOpenAshOnStartup()) { |
| 74 params.context = ash::Shell::GetAllRootWindows()[0]; | 77 params.context = ash::Shell::GetAllRootWindows()[0]; |
| 75 } | 78 } |
| 76 #endif | 79 #endif |
| 80 | |
| 81 #if defined(OS_LINUX) | |
|
Matt Giuca
2013/08/23 05:32:16
FYI: This code is mostly copied from chrome/browse
| |
| 82 // Set up a custom WM_CLASS for some sorts of window types. This allows | |
| 83 // task switchers in X11 environments to distinguish between main browser | |
| 84 // windows and e.g app windows. | |
| 85 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 86 const Browser& browser = *browser_view_->browser(); | |
| 87 params.wm_class_class = ShellIntegration::GetProgramClassName(); | |
| 88 params.wm_class_name = params.wm_class_class; | |
| 89 if (browser.is_app() && !browser.is_devtools()) { | |
| 90 // This window is a hosted app or v1 packaged app. | |
| 91 // NOTE: v2 packaged app windows are created by NativeAppWindowViews. | |
| 92 params.wm_class_name = web_app::GetWMClassFromAppName(browser.app_name()); | |
| 93 } else if (command_line.HasSwitch(switches::kUserDataDir)) { | |
| 94 // Set the class name to e.g. "Chrome (/tmp/my-user-data)". The | |
| 95 // class name will show up in the alt-tab list in gnome-shell if | |
| 96 // you're running a binary that doesn't have a matching .desktop | |
| 97 // file. | |
| 98 const std::string user_data_dir = | |
| 99 command_line.GetSwitchValueNative(switches::kUserDataDir); | |
| 100 params.wm_class_name += " (" + user_data_dir + ")"; | |
| 101 } | |
| 102 #endif // defined(OS_LINUX) | |
| 103 | |
| 77 Init(params); | 104 Init(params); |
| 78 | 105 |
| 79 if (!native_browser_frame_->UsesNativeSystemMenu()) { | 106 if (!native_browser_frame_->UsesNativeSystemMenu()) { |
| 80 DCHECK(non_client_view()); | 107 DCHECK(non_client_view()); |
| 81 non_client_view()->set_context_menu_controller(this); | 108 non_client_view()->set_context_menu_controller(this); |
| 82 } | 109 } |
| 83 } | 110 } |
| 84 | 111 |
| 85 void BrowserFrame::SetThemeProvider(scoped_ptr<ui::ThemeProvider> provider) { | 112 void BrowserFrame::SetThemeProvider(scoped_ptr<ui::ThemeProvider> provider) { |
| 86 owned_theme_provider_ = provider.Pass(); | 113 owned_theme_provider_ = provider.Pass(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 | 233 |
| 207 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { | 234 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { |
| 208 return browser_frame_view_->avatar_button(); | 235 return browser_frame_view_->avatar_button(); |
| 209 } | 236 } |
| 210 | 237 |
| 211 #if !defined(OS_WIN) || defined(USE_AURA) | 238 #if !defined(OS_WIN) || defined(USE_AURA) |
| 212 bool BrowserFrame::ShouldLeaveOffsetNearTopBorder() { | 239 bool BrowserFrame::ShouldLeaveOffsetNearTopBorder() { |
| 213 return !IsMaximized(); | 240 return !IsMaximized(); |
| 214 } | 241 } |
| 215 #endif // OS_WIN | 242 #endif // OS_WIN |
| OLD | NEW |