OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/apps/chrome_native_app_window_views_aura_ash.h
" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h
" |
6 | 6 |
7 #include "apps/ui/views/app_window_frame_view.h" | 7 #include "apps/ui/views/app_window_frame_view.h" |
8 #include "ash/ash_constants.h" | 8 #include "ash/ash_constants.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/frame/custom_frame_view_ash.h" | 10 #include "ash/frame/custom_frame_view_ash.h" |
11 #include "ash/public/cpp/shelf_item.h" | |
12 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
13 #include "ash/public/cpp/window_properties.h" | 12 #include "ash/public/cpp/window_properties.h" |
14 #include "ash/shared/app_types.h" | 13 #include "ash/shared/app_types.h" |
15 #include "ash/shared/immersive_fullscreen_controller.h" | 14 #include "ash/shared/immersive_fullscreen_controller.h" |
16 #include "ash/shell.h" | 15 #include "ash/shell.h" |
17 #include "ash/wm/panels/panel_frame_view.h" | 16 #include "ash/wm/panels/panel_frame_view.h" |
18 #include "ash/wm/window_properties.h" | 17 #include "ash/wm/window_properties.h" |
19 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
20 #include "ash/wm/window_state_delegate.h" | 19 #include "ash/wm/window_state_delegate.h" |
21 #include "ash/wm/window_state_observer.h" | 20 #include "ash/wm/window_state_observer.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 ChromeNativeAppWindowViewsAuraAsh::ChromeNativeAppWindowViewsAuraAsh() {} | 121 ChromeNativeAppWindowViewsAuraAsh::ChromeNativeAppWindowViewsAuraAsh() {} |
123 | 122 |
124 ChromeNativeAppWindowViewsAuraAsh::~ChromeNativeAppWindowViewsAuraAsh() {} | 123 ChromeNativeAppWindowViewsAuraAsh::~ChromeNativeAppWindowViewsAuraAsh() {} |
125 | 124 |
126 void ChromeNativeAppWindowViewsAuraAsh::InitializeWindow( | 125 void ChromeNativeAppWindowViewsAuraAsh::InitializeWindow( |
127 AppWindow* app_window, | 126 AppWindow* app_window, |
128 const AppWindow::CreateParams& create_params) { | 127 const AppWindow::CreateParams& create_params) { |
129 ChromeNativeAppWindowViewsAura::InitializeWindow(app_window, create_params); | 128 ChromeNativeAppWindowViewsAura::InitializeWindow(app_window, create_params); |
130 aura::Window* window = widget()->GetNativeWindow(); | 129 aura::Window* window = widget()->GetNativeWindow(); |
131 | 130 |
132 if (app_window->window_type_is_panel()) { | 131 if (!app_window->window_type_is_panel()) { |
133 // Ash's ShelfWindowWatcher handles app panel windows once this type is set. | |
134 // The type should have been initialized for mash below, via mus_properties. | |
135 if (!ash_util::IsRunningInMash()) | |
136 window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_APP_PANEL); | |
137 } else { | |
138 window->SetProperty(aura::client::kAppType, | 132 window->SetProperty(aura::client::kAppType, |
139 static_cast<int>(ash::AppType::CHROME_APP)); | 133 static_cast<int>(ash::AppType::CHROME_APP)); |
140 } | 134 } |
141 } | 135 } |
142 | 136 |
143 void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( | 137 void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( |
144 const AppWindow::CreateParams& create_params, | 138 const AppWindow::CreateParams& create_params, |
145 views::Widget::InitParams* init_params, | 139 views::Widget::InitParams* init_params, |
146 views::Widget* widget) { | 140 views::Widget* widget) { |
147 ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, | 141 ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, |
(...skipping 16 matching lines...) Expand all Loading... |
164 } | 158 } |
165 DCHECK_NE(AppWindow::WINDOW_TYPE_PANEL, create_params.window_type); | 159 DCHECK_NE(AppWindow::WINDOW_TYPE_PANEL, create_params.window_type); |
166 init_params->mus_properties | 160 init_params->mus_properties |
167 [ui::mojom::WindowManager::kRemoveStandardFrame_InitProperty] = | 161 [ui::mojom::WindowManager::kRemoveStandardFrame_InitProperty] = |
168 mojo::ConvertTo<std::vector<uint8_t>>(init_params->remove_standard_frame); | 162 mojo::ConvertTo<std::vector<uint8_t>>(init_params->remove_standard_frame); |
169 } | 163 } |
170 | 164 |
171 void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit( | 165 void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit( |
172 views::Widget::InitParams* init_params, | 166 views::Widget::InitParams* init_params, |
173 views::Widget* widget) { | 167 views::Widget* widget) { |
174 ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit(init_params, | 168 ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit(init_params, widget); |
175 widget); | |
176 | 169 |
177 if (ash_util::IsRunningInMash()) { | 170 if (!ash_util::IsRunningInMash() && ash::Shell::HasInstance()) { |
178 // Ash's ShelfWindowWatcher handles app panel windows once this type is set. | |
179 init_params | |
180 ->mus_properties[ui::mojom::WindowManager::kShelfItemType_Property] = | |
181 mojo::ConvertTo<std::vector<uint8_t>>( | |
182 static_cast<aura::PropertyConverter::PrimitiveType>( | |
183 ash::TYPE_APP_PANEL)); | |
184 } else if (ash::Shell::HasInstance()) { | |
185 // Open a new panel on the target root. | 171 // Open a new panel on the target root. |
186 init_params->context = ash::Shell::GetRootWindowForNewWindows(); | 172 init_params->context = ash::Shell::GetRootWindowForNewWindows(); |
187 init_params->bounds = gfx::Rect(GetPreferredSize()); | 173 init_params->bounds = gfx::Rect(GetPreferredSize()); |
188 wm::ConvertRectToScreen(ash::Shell::GetRootWindowForNewWindows(), | 174 wm::ConvertRectToScreen(ash::Shell::GetRootWindowForNewWindows(), |
189 &init_params->bounds); | 175 &init_params->bounds); |
190 } | 176 } |
191 } | 177 } |
192 | 178 |
193 views::NonClientFrameView* | 179 views::NonClientFrameView* |
194 ChromeNativeAppWindowViewsAuraAsh::CreateNonStandardAppFrame() { | 180 ChromeNativeAppWindowViewsAuraAsh::CreateNonStandardAppFrame() { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 bool activate_on_pointer) { | 359 bool activate_on_pointer) { |
374 widget()->GetNativeWindow()->SetProperty(aura::client::kActivateOnPointerKey, | 360 widget()->GetNativeWindow()->SetProperty(aura::client::kActivateOnPointerKey, |
375 activate_on_pointer); | 361 activate_on_pointer); |
376 } | 362 } |
377 | 363 |
378 void ChromeNativeAppWindowViewsAuraAsh::OnMenuClosed() { | 364 void ChromeNativeAppWindowViewsAuraAsh::OnMenuClosed() { |
379 menu_runner_.reset(); | 365 menu_runner_.reset(); |
380 menu_model_adapter_.reset(); | 366 menu_model_adapter_.reset(); |
381 menu_model_.reset(); | 367 menu_model_.reset(); |
382 } | 368 } |
OLD | NEW |