| 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/common/ash_constants.h" | 8 #include "ash/common/ash_constants.h" |
| 9 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/frame/custom_frame_view_ash.h" | 10 #include "ash/common/frame/custom_frame_view_ash.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 ash::switches::DockedWindowsEnabled()) { | 138 ash::switches::DockedWindowsEnabled()) { |
| 139 window->SetProperty(aura::client::kShowStateKey, create_params.state); | 139 window->SetProperty(aura::client::kShowStateKey, create_params.state); |
| 140 } | 140 } |
| 141 | 141 |
| 142 window->SetProperty(aura::client::kAppIdKey, | 142 window->SetProperty(aura::client::kAppIdKey, |
| 143 new std::string(app_window->extension_id())); | 143 new std::string(app_window->extension_id())); |
| 144 | 144 |
| 145 if (app_window->window_type_is_panel()) { | 145 if (app_window->window_type_is_panel()) { |
| 146 // Ash's ShelfWindowWatcher handles app panel windows once this type is set. | 146 // Ash's ShelfWindowWatcher handles app panel windows once this type is set. |
| 147 // The type should have been initialized for mash below, via mus_properties. | 147 // The type should have been initialized for mash below, via mus_properties. |
| 148 if (!chrome::IsRunningInMash()) | 148 if (!ash_util::IsRunningInMash()) |
| 149 window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_APP_PANEL); | 149 window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_APP_PANEL); |
| 150 } else { | 150 } else { |
| 151 window->SetProperty(aura::client::kAppType, | 151 window->SetProperty(aura::client::kAppType, |
| 152 static_cast<int>(ash::AppType::CHROME_APP)); | 152 static_cast<int>(ash::AppType::CHROME_APP)); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( | 156 void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( |
| 157 const AppWindow::CreateParams& create_params, | 157 const AppWindow::CreateParams& create_params, |
| 158 views::Widget::InitParams* init_params, | 158 views::Widget::InitParams* init_params, |
| 159 views::Widget* widget) { | 159 views::Widget* widget) { |
| 160 ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, | 160 ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, |
| 161 widget); | 161 widget); |
| 162 if (create_params.is_ime_window) { | 162 if (create_params.is_ime_window) { |
| 163 // Put ime windows into the ime window container on the primary display. | 163 // Put ime windows into the ime window container on the primary display. |
| 164 int container_id = ash::kShellWindowId_ImeWindowParentContainer; | 164 int container_id = ash::kShellWindowId_ImeWindowParentContainer; |
| 165 if (chrome::IsRunningInMash()) { | 165 if (ash_util::IsRunningInMash()) { |
| 166 init_params->mus_properties | 166 init_params->mus_properties |
| 167 [ui::mojom::WindowManager::kContainerId_InitProperty] = | 167 [ui::mojom::WindowManager::kContainerId_InitProperty] = |
| 168 mojo::ConvertTo<std::vector<uint8_t>>(container_id); | 168 mojo::ConvertTo<std::vector<uint8_t>>(container_id); |
| 169 int display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 169 int display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 170 init_params | 170 init_params |
| 171 ->mus_properties[ui::mojom::WindowManager::kDisplayId_InitProperty] = | 171 ->mus_properties[ui::mojom::WindowManager::kDisplayId_InitProperty] = |
| 172 mojo::ConvertTo<std::vector<uint8_t>>(display_id); | 172 mojo::ConvertTo<std::vector<uint8_t>>(display_id); |
| 173 } else { | 173 } else { |
| 174 init_params->parent = ash::Shell::GetContainer( | 174 init_params->parent = ash::Shell::GetContainer( |
| 175 ash::Shell::GetPrimaryRootWindow(), container_id); | 175 ash::Shell::GetPrimaryRootWindow(), container_id); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 DCHECK_NE(AppWindow::WINDOW_TYPE_PANEL, create_params.window_type); | 178 DCHECK_NE(AppWindow::WINDOW_TYPE_PANEL, create_params.window_type); |
| 179 DCHECK_NE(AppWindow::WINDOW_TYPE_V1_PANEL, create_params.window_type); | 179 DCHECK_NE(AppWindow::WINDOW_TYPE_V1_PANEL, create_params.window_type); |
| 180 init_params->mus_properties | 180 init_params->mus_properties |
| 181 [ui::mojom::WindowManager::kRemoveStandardFrame_InitProperty] = | 181 [ui::mojom::WindowManager::kRemoveStandardFrame_InitProperty] = |
| 182 mojo::ConvertTo<std::vector<uint8_t>>(init_params->remove_standard_frame); | 182 mojo::ConvertTo<std::vector<uint8_t>>(init_params->remove_standard_frame); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit( | 185 void ChromeNativeAppWindowViewsAuraAsh::OnBeforePanelWidgetInit( |
| 186 bool use_default_bounds, | 186 bool use_default_bounds, |
| 187 views::Widget::InitParams* init_params, | 187 views::Widget::InitParams* init_params, |
| 188 views::Widget* widget) { | 188 views::Widget* widget) { |
| 189 ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit(use_default_bounds, | 189 ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit(use_default_bounds, |
| 190 init_params, | 190 init_params, |
| 191 widget); | 191 widget); |
| 192 | 192 |
| 193 if (chrome::IsRunningInMash()) { | 193 if (ash_util::IsRunningInMash()) { |
| 194 // Ash's ShelfWindowWatcher handles app panel windows once this type is set. | 194 // Ash's ShelfWindowWatcher handles app panel windows once this type is set. |
| 195 init_params | 195 init_params |
| 196 ->mus_properties[ui::mojom::WindowManager::kShelfItemType_Property] = | 196 ->mus_properties[ui::mojom::WindowManager::kShelfItemType_Property] = |
| 197 mojo::ConvertTo<std::vector<uint8_t>>( | 197 mojo::ConvertTo<std::vector<uint8_t>>( |
| 198 static_cast<aura::PropertyConverter::PrimitiveType>( | 198 static_cast<aura::PropertyConverter::PrimitiveType>( |
| 199 ash::TYPE_APP_PANEL)); | 199 ash::TYPE_APP_PANEL)); |
| 200 } else if (ash::Shell::HasInstance() && use_default_bounds) { | 200 } else if (ash::Shell::HasInstance() && use_default_bounds) { |
| 201 // Open a new panel on the target root. | 201 // Open a new panel on the target root. |
| 202 init_params->context = ash::Shell::GetTargetRootWindow(); | 202 init_params->context = ash::Shell::GetTargetRootWindow(); |
| 203 init_params->bounds = gfx::Rect(GetPreferredSize()); | 203 init_params->bounds = gfx::Rect(GetPreferredSize()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 views::Widget* widget) { | 311 views::Widget* widget) { |
| 312 // Set the delegate now because CustomFrameViewAsh sets the | 312 // Set the delegate now because CustomFrameViewAsh sets the |
| 313 // WindowStateDelegate if one is not already set. | 313 // WindowStateDelegate if one is not already set. |
| 314 ash::wm::GetWindowState(GetNativeWindow()) | 314 ash::wm::GetWindowState(GetNativeWindow()) |
| 315 ->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>( | 315 ->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>( |
| 316 new NativeAppWindowStateDelegate(app_window(), this))); | 316 new NativeAppWindowStateDelegate(app_window(), this))); |
| 317 | 317 |
| 318 if (IsFrameless()) | 318 if (IsFrameless()) |
| 319 return CreateNonStandardAppFrame(); | 319 return CreateNonStandardAppFrame(); |
| 320 | 320 |
| 321 if (chrome::IsRunningInMash()) | 321 if (ash_util::IsRunningInMash()) |
| 322 return ChromeNativeAppWindowViews::CreateNonClientFrameView(widget); | 322 return ChromeNativeAppWindowViews::CreateNonClientFrameView(widget); |
| 323 | 323 |
| 324 if (app_window()->window_type_is_panel()) { | 324 if (app_window()->window_type_is_panel()) { |
| 325 ash::PanelFrameView* frame_view = | 325 ash::PanelFrameView* frame_view = |
| 326 new ash::PanelFrameView(widget, ash::PanelFrameView::FRAME_ASH); | 326 new ash::PanelFrameView(widget, ash::PanelFrameView::FRAME_ASH); |
| 327 frame_view->set_context_menu_controller(this); | 327 frame_view->set_context_menu_controller(this); |
| 328 if (HasFrameColor()) | 328 if (HasFrameColor()) |
| 329 frame_view->SetFrameColors(ActiveFrameColor(), InactiveFrameColor()); | 329 frame_view->SetFrameColors(ActiveFrameColor(), InactiveFrameColor()); |
| 330 return frame_view; | 330 return frame_view; |
| 331 } | 331 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 355 // fullscreen is the fullscreen type used by the OS. | 355 // fullscreen is the fullscreen type used by the OS. |
| 356 immersive_fullscreen_controller_->SetEnabled( | 356 immersive_fullscreen_controller_->SetEnabled( |
| 357 ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP, | 357 ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP, |
| 358 (fullscreen_types & AppWindow::FULLSCREEN_TYPE_OS) != 0); | 358 (fullscreen_types & AppWindow::FULLSCREEN_TYPE_OS) != 0); |
| 359 // Autohide the shelf instead of hiding the shelf completely when only in | 359 // Autohide the shelf instead of hiding the shelf completely when only in |
| 360 // OS fullscreen. | 360 // OS fullscreen. |
| 361 ash::wm::WindowState* window_state = | 361 ash::wm::WindowState* window_state = |
| 362 ash::wm::GetWindowState(widget()->GetNativeWindow()); | 362 ash::wm::GetWindowState(widget()->GetNativeWindow()); |
| 363 window_state->set_hide_shelf_when_fullscreen(fullscreen_types != | 363 window_state->set_hide_shelf_when_fullscreen(fullscreen_types != |
| 364 AppWindow::FULLSCREEN_TYPE_OS); | 364 AppWindow::FULLSCREEN_TYPE_OS); |
| 365 if (!chrome::IsRunningInMash()) { | 365 if (!ash_util::IsRunningInMash()) { |
| 366 DCHECK(ash::Shell::HasInstance()); | 366 DCHECK(ash::Shell::HasInstance()); |
| 367 ash::Shell::GetInstance()->UpdateShelfVisibility(); | 367 ash::Shell::GetInstance()->UpdateShelfVisibility(); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 | 371 |
| 372 void ChromeNativeAppWindowViewsAuraAsh::UpdateDraggableRegions( | 372 void ChromeNativeAppWindowViewsAuraAsh::UpdateDraggableRegions( |
| 373 const std::vector<extensions::DraggableRegion>& regions) { | 373 const std::vector<extensions::DraggableRegion>& regions) { |
| 374 ChromeNativeAppWindowViewsAura::UpdateDraggableRegions(regions); | 374 ChromeNativeAppWindowViewsAura::UpdateDraggableRegions(regions); |
| 375 | 375 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 394 window_tree_host->SetClientArea(insets, | 394 window_tree_host->SetClientArea(insets, |
| 395 std::move(additional_client_regions)); | 395 std::move(additional_client_regions)); |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 void ChromeNativeAppWindowViewsAuraAsh::OnMenuClosed() { | 399 void ChromeNativeAppWindowViewsAuraAsh::OnMenuClosed() { |
| 400 menu_runner_.reset(); | 400 menu_runner_.reset(); |
| 401 menu_model_adapter_.reset(); | 401 menu_model_adapter_.reset(); |
| 402 menu_model_.reset(); | 402 menu_model_.reset(); |
| 403 } | 403 } |
| OLD | NEW |