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/panels/panel_view.h" | 5 #include "chrome/browser/ui/views/panels/panel_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/app/chrome_command_ids.h" | 16 #include "chrome/app/chrome_command_ids.h" |
| 17 #include "chrome/browser/lifetime/keep_alive_options.h" |
| 18 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
17 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/host_desktop.h" | 20 #include "chrome/browser/ui/host_desktop.h" |
19 #include "chrome/browser/ui/panels/panel.h" | 21 #include "chrome/browser/ui/panels/panel.h" |
20 #include "chrome/browser/ui/panels/panel_bounds_animation.h" | 22 #include "chrome/browser/ui/panels/panel_bounds_animation.h" |
21 #include "chrome/browser/ui/panels/panel_manager.h" | 23 #include "chrome/browser/ui/panels/panel_manager.h" |
22 #include "chrome/browser/ui/panels/stacked_panel_collection.h" | 24 #include "chrome/browser/ui/panels/stacked_panel_collection.h" |
23 #include "chrome/browser/ui/views/auto_keep_alive.h" | |
24 #include "chrome/browser/ui/views/panels/panel_frame_view.h" | 25 #include "chrome/browser/ui/views/panels/panel_frame_view.h" |
25 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/render_widget_host_view.h" | 27 #include "content/public/browser/render_widget_host_view.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "ui/content_accelerators/accelerator_util.h" | 29 #include "ui/content_accelerators/accelerator_util.h" |
29 #include "ui/gfx/image/image.h" | 30 #include "ui/gfx/image/image.h" |
30 #include "ui/gfx/path.h" | 31 #include "ui/gfx/path.h" |
31 #include "ui/gfx/screen.h" | 32 #include "ui/gfx/screen.h" |
32 #include "ui/views/controls/button/image_button.h" | 33 #include "ui/views/controls/button/image_button.h" |
33 #include "ui/views/controls/webview/webview.h" | 34 #include "ui/views/controls/webview/webview.h" |
(...skipping 11 matching lines...) Expand all Loading... |
45 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 46 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
46 #include "chrome/browser/shell_integration_linux.h" | 47 #include "chrome/browser/shell_integration_linux.h" |
47 #include "chrome/browser/ui/views/panels/x11_panel_resizer.h" | 48 #include "chrome/browser/ui/views/panels/x11_panel_resizer.h" |
48 #include "chrome/browser/web_applications/web_app.h" | 49 #include "chrome/browser/web_applications/web_app.h" |
49 #include "ui/aura/window.h" | 50 #include "ui/aura/window.h" |
50 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 51 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
51 #endif | 52 #endif |
52 | 53 |
53 namespace { | 54 namespace { |
54 | 55 |
| 56 #if !defined(OS_CHROMEOS) |
| 57 static const KeepAliveOptions g_keep_alive_options = {"PanelView"}; |
| 58 #endif // !defined(OS_CHROMEOS) |
| 59 |
55 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
56 // If the height of a stacked panel shrinks below this threshold during the | 61 // If the height of a stacked panel shrinks below this threshold during the |
57 // user resizing, it will be treated as minimized. | 62 // user resizing, it will be treated as minimized. |
58 const int kStackedPanelHeightShrinkThresholdToBecomeMinimized = | 63 const int kStackedPanelHeightShrinkThresholdToBecomeMinimized = |
59 panel::kTitlebarHeight + 20; | 64 panel::kTitlebarHeight + 20; |
60 #endif | 65 #endif |
61 | 66 |
62 // Supported accelerators. | 67 // Supported accelerators. |
63 // Note: We can't use the accelerator table defined in chrome/browser/ui/views | 68 // Note: We can't use the accelerator table defined in chrome/browser/ui/views |
64 // due to checkdeps violation. | 69 // due to checkdeps violation. |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 298 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
294 params.wm_class_name = web_app::GetWMClassFromAppName(panel->app_name()); | 299 params.wm_class_name = web_app::GetWMClassFromAppName(panel->app_name()); |
295 params.wm_class_class = shell_integration_linux::GetProgramClassName(); | 300 params.wm_class_class = shell_integration_linux::GetProgramClassName(); |
296 #endif | 301 #endif |
297 | 302 |
298 window_->Init(params); | 303 window_->Init(params); |
299 window_->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); | 304 window_->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); |
300 window_->set_focus_on_creation(false); | 305 window_->set_focus_on_creation(false); |
301 window_->AddObserver(this); | 306 window_->AddObserver(this); |
302 | 307 |
| 308 #if !defined(OS_CHROMEOS) |
303 // Prevent the browser process from shutting down while this window is open. | 309 // Prevent the browser process from shutting down while this window is open. |
304 keep_alive_.reset(new AutoKeepAlive(GetNativePanelWindow())); | 310 // Chrome OS already has a mechanism to always stay alive and skips this. |
| 311 keep_alive_.reset(new ScopedKeepAlive(&g_keep_alive_options)); |
| 312 #endif // !defined(OS_CHROMEOS) |
305 | 313 |
306 web_view_ = new views::WebView(NULL); | 314 web_view_ = new views::WebView(NULL); |
307 AddChildView(web_view_); | 315 AddChildView(web_view_); |
308 | 316 |
309 // Register accelarators supported by panels. | 317 // Register accelarators supported by panels. |
310 views::FocusManager* focus_manager = GetFocusManager(); | 318 views::FocusManager* focus_manager = GetFocusManager(); |
311 const std::map<ui::Accelerator, int>& accelerator_table = | 319 const std::map<ui::Accelerator, int>& accelerator_table = |
312 GetAcceleratorTable(); | 320 GetAcceleratorTable(); |
313 for (std::map<ui::Accelerator, int>::const_iterator iter = | 321 for (std::map<ui::Accelerator, int>::const_iterator iter = |
314 accelerator_table.begin(); | 322 accelerator_table.begin(); |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 // SWP_FRAMECHANGED flag must be called in order for the cached window data | 1151 // SWP_FRAMECHANGED flag must be called in order for the cached window data |
1144 // to be updated properly. | 1152 // to be updated properly. |
1145 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).a
spx | 1153 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).a
spx |
1146 if (update_frame) { | 1154 if (update_frame) { |
1147 ::SetWindowPos(native_window, NULL, 0, 0, 0, 0, | 1155 ::SetWindowPos(native_window, NULL, 0, 0, 0, 0, |
1148 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | | 1156 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | |
1149 SWP_NOZORDER | SWP_NOACTIVATE); | 1157 SWP_NOZORDER | SWP_NOACTIVATE); |
1150 } | 1158 } |
1151 } | 1159 } |
1152 #endif | 1160 #endif |
OLD | NEW |