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/window.h" | 5 #include "chrome/browser/ui/views/window.h" |
6 | 6 |
7 #include "ui/views/bubble/bubble_delegate.h" | 7 #include "ui/views/bubble/bubble_delegate.h" |
8 #include "ui/views/widget/widget.h" | 8 #include "ui/views/widget/widget.h" |
9 | 9 |
10 #if defined(USE_AURA) | 10 #if defined(USE_AURA) |
| 11 #include "ash/ash_switches.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
| 14 #include "base/command_line.h" |
13 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
14 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
15 #endif | 17 #endif |
16 | 18 |
17 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
18 #include "chrome/browser/chromeos/frame/bubble_window.h" | 20 #include "chrome/browser/chromeos/frame/bubble_window.h" |
19 | 21 |
20 #if defined(TOOLKIT_USES_GTK) | 22 #if defined(TOOLKIT_USES_GTK) |
21 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" | 23 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" |
22 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 24 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
23 #endif // TOOLKIT_USES_GTK | 25 #endif // TOOLKIT_USES_GTK |
24 | 26 |
25 #endif // OS_CHROMEOS | 27 #endif // OS_CHROMEOS |
26 | 28 |
27 // Note: This file should be removed after the old ChromeOS frontend is removed. | 29 // Note: This file should be removed after the old ChromeOS frontend is removed. |
28 // It is not needed for Aura. | 30 // It is not needed for Aura. |
29 // The visual style implemented by BubbleFrameView/BubbleWindow for | 31 // The visual style implemented by BubbleFrameView/BubbleWindow for |
30 // ChromeOS should move to Ash. | 32 // ChromeOS should move to Ash. |
31 // Calling code should just call the standard views Widget creation | 33 // Calling code should just call the standard views Widget creation |
32 // methods and "the right thing" should just happen. | 34 // methods and "the right thing" should just happen. |
33 // The remainder of the code here is dealing with the legacy CrOS WM and | 35 // The remainder of the code here is dealing with the legacy CrOS WM and |
34 // can also be removed. | 36 // can also be removed. |
35 | 37 |
| 38 namespace { |
| 39 |
| 40 views::Widget* CreateViewsWindowWithParent(gfx::NativeWindow parent, |
| 41 views::WidgetDelegate* delegate) { |
| 42 views::Widget* widget = new views::Widget; |
| 43 views::Widget::InitParams params; |
| 44 params.delegate = delegate; |
| 45 #if defined(OS_WIN) || defined(USE_AURA) |
| 46 params.parent = parent; |
| 47 #endif |
| 48 #if defined(USE_AURA) |
| 49 // Outside of compact mode, dialog windows may have translucent frames. |
| 50 // TODO(jamescook): Find a better way to set this. |
| 51 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 52 bool compact_window_mode = |
| 53 cmd->HasSwitch(ash::switches::kAuraForceCompactWindowMode) || |
| 54 cmd->GetSwitchValueASCII(ash::switches::kAuraWindowMode) == |
| 55 ash::switches::kAuraWindowModeCompact; |
| 56 if (!compact_window_mode) |
| 57 params.transparent = true; |
| 58 #endif |
| 59 widget->Init(params); |
| 60 return widget; |
| 61 } |
| 62 |
| 63 } // namespace |
| 64 |
36 namespace browser { | 65 namespace browser { |
37 | 66 |
38 views::Widget* CreateViewsWindow(gfx::NativeWindow parent, | 67 views::Widget* CreateViewsWindow(gfx::NativeWindow parent, |
39 views::WidgetDelegate* delegate, | 68 views::WidgetDelegate* delegate, |
40 DialogStyle style) { | 69 DialogStyle style) { |
41 #if defined(OS_CHROMEOS) && !defined(USE_AURA) | 70 #if defined(OS_CHROMEOS) && !defined(USE_AURA) |
42 return chromeos::BubbleWindow::Create(parent, style, delegate); | 71 return chromeos::BubbleWindow::Create(parent, style, delegate); |
43 #else | 72 #else |
44 return views::Widget::CreateWindowWithParent(delegate, parent); | 73 return CreateViewsWindowWithParent(parent, delegate); |
45 #endif | 74 #endif |
46 } | 75 } |
47 | 76 |
48 views::Widget* CreateFramelessViewsWindow(gfx::NativeWindow parent, | 77 views::Widget* CreateFramelessViewsWindow(gfx::NativeWindow parent, |
49 views::WidgetDelegate* delegate) { | 78 views::WidgetDelegate* delegate) { |
50 #if defined(OS_CHROMEOS) && !defined(USE_AURA) | 79 #if defined(OS_CHROMEOS) && !defined(USE_AURA) |
51 return chromeos::BubbleWindow::Create(parent, STYLE_FLUSH, delegate); | 80 return chromeos::BubbleWindow::Create(parent, STYLE_FLUSH, delegate); |
52 #else | 81 #else |
53 return CreateFramelessWindowWithParentAndBounds(delegate, | 82 return CreateFramelessWindowWithParentAndBounds(delegate, |
54 parent, gfx::Rect()); | 83 parent, gfx::Rect()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 params.push_back(1); // Show while screen is locked. | 131 params.push_back(1); // Show while screen is locked. |
103 chromeos::WmIpc::instance()->SetWindowType( | 132 chromeos::WmIpc::instance()->SetWindowType( |
104 bubble_widget->GetNativeView(), | 133 bubble_widget->GetNativeView(), |
105 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, | 134 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, |
106 ¶ms); | 135 ¶ms); |
107 #endif | 136 #endif |
108 return bubble_widget; | 137 return bubble_widget; |
109 } | 138 } |
110 | 139 |
111 } // namespace browser | 140 } // namespace browser |
OLD | NEW |