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/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
10 #include "ash/common/frame/custom_frame_view_ash.h" | 10 #include "ash/common/frame/custom_frame_view_ash.h" |
| 11 #include "ash/common/shelf/shelf_item_types.h" |
11 #include "ash/common/wm/panels/panel_frame_view.h" | 12 #include "ash/common/wm/panels/panel_frame_view.h" |
12 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
13 #include "ash/common/wm/window_state_delegate.h" | 14 #include "ash/common/wm/window_state_delegate.h" |
14 #include "ash/common/wm/window_state_observer.h" | 15 #include "ash/common/wm/window_state_observer.h" |
15 #include "ash/public/cpp/shell_window_ids.h" | 16 #include "ash/public/cpp/shell_window_ids.h" |
16 #include "ash/screen_util.h" | 17 #include "ash/screen_util.h" |
17 #include "ash/shared/app_types.h" | 18 #include "ash/shared/app_types.h" |
18 #include "ash/shared/immersive_fullscreen_controller.h" | 19 #include "ash/shared/immersive_fullscreen_controller.h" |
19 #include "ash/shell.h" | 20 #include "ash/shell.h" |
20 #include "ash/wm/window_properties.h" | 21 #include "ash/wm/window_properties.h" |
21 #include "ash/wm/window_state_aura.h" | 22 #include "ash/wm/window_state_aura.h" |
22 #include "chrome/browser/chromeos/note_taking_app_utils.h" | 23 #include "chrome/browser/chromeos/note_taking_app_utils.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/ash/ash_util.h" | 25 #include "chrome/browser/ui/ash/ash_util.h" |
25 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" | 26 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" |
| 27 #include "chrome/browser/ui/ash/property_util.h" |
26 #include "services/ui/public/cpp/property_type_converters.h" | 28 #include "services/ui/public/cpp/property_type_converters.h" |
27 #include "services/ui/public/cpp/window.h" | 29 #include "services/ui/public/cpp/window.h" |
28 #include "services/ui/public/interfaces/window_manager.mojom.h" | 30 #include "services/ui/public/interfaces/window_manager.mojom.h" |
29 #include "ui/aura/client/aura_constants.h" | 31 #include "ui/aura/client/aura_constants.h" |
30 #include "ui/aura/mus/mus_util.h" | 32 #include "ui/aura/mus/mus_util.h" |
31 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
32 #include "ui/aura/window_observer.h" | 34 #include "ui/aura/window_observer.h" |
33 #include "ui/base/hit_test.h" | 35 #include "ui/base/hit_test.h" |
34 #include "ui/base/models/simple_menu_model.h" | 36 #include "ui/base/models/simple_menu_model.h" |
35 #include "ui/gfx/skia_util.h" | 37 #include "ui/gfx/skia_util.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 115 |
114 // Not owned. | 116 // Not owned. |
115 AppWindow* app_window_; | 117 AppWindow* app_window_; |
116 ash::wm::WindowState* window_state_; | 118 ash::wm::WindowState* window_state_; |
117 | 119 |
118 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); | 120 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); |
119 }; | 121 }; |
120 | 122 |
121 } // namespace | 123 } // namespace |
122 | 124 |
123 ChromeNativeAppWindowViewsAuraAsh::ChromeNativeAppWindowViewsAuraAsh() { | 125 ChromeNativeAppWindowViewsAuraAsh::ChromeNativeAppWindowViewsAuraAsh() {} |
124 } | |
125 | 126 |
126 ChromeNativeAppWindowViewsAuraAsh::~ChromeNativeAppWindowViewsAuraAsh() { | 127 ChromeNativeAppWindowViewsAuraAsh::~ChromeNativeAppWindowViewsAuraAsh() {} |
127 } | |
128 | 128 |
129 void ChromeNativeAppWindowViewsAuraAsh::InitializeWindow( | 129 void ChromeNativeAppWindowViewsAuraAsh::InitializeWindow( |
130 AppWindow* app_window, | 130 AppWindow* app_window, |
131 const AppWindow::CreateParams& create_params) { | 131 const AppWindow::CreateParams& create_params) { |
132 ChromeNativeAppWindowViewsAura::InitializeWindow(app_window, create_params); | 132 ChromeNativeAppWindowViewsAura::InitializeWindow(app_window, create_params); |
| 133 aura::Window* window = widget()->GetNativeWindow(); |
133 // Restore docked state on ash desktop. | 134 // Restore docked state on ash desktop. |
134 if (create_params.state == ui::SHOW_STATE_DOCKED) { | 135 if (create_params.state == ui::SHOW_STATE_DOCKED) |
135 widget()->GetNativeWindow()->SetProperty(aura::client::kShowStateKey, | 136 window->SetProperty(aura::client::kShowStateKey, create_params.state); |
136 create_params.state); | 137 window->SetProperty(aura::client::kAppIdKey, |
137 } | 138 new std::string(app_window->extension_id())); |
138 | 139 |
139 if (!app_window->window_type_is_panel()) { | 140 if (app_window->window_type_is_panel()) { |
| 141 // Ash's ShelfWindowWatcher handles app panel windows once this type is set. |
| 142 property_util::SetIntProperty(window, ash::kShelfItemTypeKey, |
| 143 ash::TYPE_APP_PANEL); |
| 144 } else { |
140 ash::AppType app_type = ash::AppType::CHROME_APP; | 145 ash::AppType app_type = ash::AppType::CHROME_APP; |
141 Profile* profile = | 146 Profile* profile = |
142 Profile::FromBrowserContext(app_window->browser_context()); | 147 Profile::FromBrowserContext(app_window->browser_context()); |
143 if (profile && chromeos::IsNoteTakingAppWindow(app_window, profile)) | 148 if (profile && chromeos::IsNoteTakingAppWindow(app_window, profile)) |
144 app_type = ash::AppType::DEFAULT_NOTE_TAKING_APP; | 149 app_type = ash::AppType::DEFAULT_NOTE_TAKING_APP; |
145 widget()->GetNativeWindow()->SetProperty(aura::client::kAppType, | 150 window->SetProperty(aura::client::kAppType, static_cast<int>(app_type)); |
146 static_cast<int>(app_type)); | |
147 } | 151 } |
148 } | 152 } |
149 | 153 |
150 void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( | 154 void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( |
151 const AppWindow::CreateParams& create_params, | 155 const AppWindow::CreateParams& create_params, |
152 views::Widget::InitParams* init_params, | 156 views::Widget::InitParams* init_params, |
153 views::Widget* widget) { | 157 views::Widget* widget) { |
154 ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, | 158 ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, |
155 widget); | 159 widget); |
156 if (create_params.is_ime_window) { | 160 if (create_params.is_ime_window) { |
157 // Puts ime windows into ime window container. | 161 // Puts ime windows into the ime window container. |
158 init_params->parent = | 162 init_params->parent = |
159 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 163 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
160 ash::kShellWindowId_ImeWindowParentContainer); | 164 ash::kShellWindowId_ImeWindowParentContainer); |
161 } | 165 } |
162 init_params->mus_properties | 166 init_params->mus_properties |
163 [ui::mojom::WindowManager::kRemoveStandardFrame_Property] = | 167 [ui::mojom::WindowManager::kRemoveStandardFrame_Property] = |
164 mojo::ConvertTo<std::vector<uint8_t>>(init_params->remove_standard_frame); | 168 mojo::ConvertTo<std::vector<uint8_t>>(init_params->remove_standard_frame); |
165 } | 169 } |
166 | 170 |
167 void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit( | 171 void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit( |
168 bool use_default_bounds, | 172 bool use_default_bounds, |
169 views::Widget::InitParams* init_params, | 173 views::Widget::InitParams* init_params, |
170 views::Widget* widget) { | 174 views::Widget* widget) { |
171 ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit(use_default_bounds, | 175 ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit(use_default_bounds, |
172 init_params, | 176 init_params, |
173 widget); | 177 widget); |
174 | 178 |
175 if (ash::Shell::HasInstance() && use_default_bounds) { | 179 if (ash::Shell::HasInstance() && use_default_bounds) { |
176 // Open a new panel on the target root. | 180 // Open a new panel on the target root. |
| 181 init_params->context = ash::Shell::GetTargetRootWindow(); |
177 init_params->bounds = ash::ScreenUtil::ConvertRectToScreen( | 182 init_params->bounds = ash::ScreenUtil::ConvertRectToScreen( |
178 ash::Shell::GetTargetRootWindow(), gfx::Rect(GetPreferredSize())); | 183 ash::Shell::GetTargetRootWindow(), gfx::Rect(GetPreferredSize())); |
179 } | 184 } |
180 } | 185 } |
181 | 186 |
182 views::NonClientFrameView* | 187 views::NonClientFrameView* |
183 ChromeNativeAppWindowViewsAuraAsh::CreateNonStandardAppFrame() { | 188 ChromeNativeAppWindowViewsAuraAsh::CreateNonStandardAppFrame() { |
184 apps::AppWindowFrameView* frame = new apps::AppWindowFrameView(widget(), this, | 189 apps::AppWindowFrameView* frame = new apps::AppWindowFrameView(widget(), this, |
185 HasFrameColor(), ActiveFrameColor(), InactiveFrameColor()); | 190 HasFrameColor(), ActiveFrameColor(), InactiveFrameColor()); |
186 frame->Init(); | 191 frame->Init(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 GetMusWindow(widget()->GetNativeWindow()) | 365 GetMusWindow(widget()->GetNativeWindow()) |
361 ->SetClientArea(insets, std::move(additional_client_regions)); | 366 ->SetClientArea(insets, std::move(additional_client_regions)); |
362 } | 367 } |
363 } | 368 } |
364 | 369 |
365 void ChromeNativeAppWindowViewsAuraAsh::OnMenuClosed() { | 370 void ChromeNativeAppWindowViewsAuraAsh::OnMenuClosed() { |
366 menu_runner_.reset(); | 371 menu_runner_.reset(); |
367 menu_model_adapter_.reset(); | 372 menu_model_adapter_.reset(); |
368 menu_model_.reset(); | 373 menu_model_.reset(); |
369 } | 374 } |
OLD | NEW |