| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.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 "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/app_mode/app_mode_utils.h" | 10 #include "chrome/browser/app_mode/app_mode_utils.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "ash/wm/window_state.h" | 45 #include "ash/wm/window_state.h" |
| 46 #include "ash/wm/window_state_delegate.h" | 46 #include "ash/wm/window_state_delegate.h" |
| 47 #include "ash/wm/window_state_observer.h" | 47 #include "ash/wm/window_state_observer.h" |
| 48 #include "chrome/browser/ui/ash/ash_util.h" | 48 #include "chrome/browser/ui/ash/ash_util.h" |
| 49 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" | 49 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" |
| 50 #include "ui/aura/client/aura_constants.h" | 50 #include "ui/aura/client/aura_constants.h" |
| 51 #include "ui/aura/client/window_tree_client.h" | 51 #include "ui/aura/client/window_tree_client.h" |
| 52 #include "ui/aura/window_observer.h" | 52 #include "ui/aura/window_observer.h" |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 #if defined(OS_CHROMEOS) |
| 56 #include "ash/shell_window_ids.h" |
| 57 #endif |
| 58 |
| 55 using extensions::AppWindow; | 59 using extensions::AppWindow; |
| 56 | 60 |
| 57 namespace { | 61 namespace { |
| 58 | 62 |
| 59 const int kMinPanelWidth = 100; | 63 const int kMinPanelWidth = 100; |
| 60 const int kMinPanelHeight = 100; | 64 const int kMinPanelHeight = 100; |
| 61 const int kDefaultPanelWidth = 200; | 65 const int kDefaultPanelWidth = 200; |
| 62 const int kDefaultPanelHeight = 300; | 66 const int kDefaultPanelHeight = 300; |
| 63 | 67 |
| 64 struct AcceleratorMapping { | 68 struct AcceleratorMapping { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 226 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 223 // Set up a custom WM_CLASS for app windows. This allows task switchers in | 227 // Set up a custom WM_CLASS for app windows. This allows task switchers in |
| 224 // X11 environments to distinguish them from main browser windows. | 228 // X11 environments to distinguish them from main browser windows. |
| 225 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); | 229 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); |
| 226 init_params.wm_class_class = shell_integration_linux::GetProgramClassName(); | 230 init_params.wm_class_class = shell_integration_linux::GetProgramClassName(); |
| 227 const char kX11WindowRoleApp[] = "app"; | 231 const char kX11WindowRoleApp[] = "app"; |
| 228 init_params.wm_role_name = std::string(kX11WindowRoleApp); | 232 init_params.wm_role_name = std::string(kX11WindowRoleApp); |
| 229 #endif | 233 #endif |
| 230 | 234 |
| 231 OnBeforeWidgetInit(&init_params, widget()); | 235 OnBeforeWidgetInit(&init_params, widget()); |
| 236 #if defined(OS_CHROMEOS) |
| 237 if (create_params.is_ime_window) { |
| 238 // Puts ime windows into ime window container. |
| 239 init_params.parent = |
| 240 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
| 241 ash::kShellWindowId_ImeWindowParentContainer); |
| 242 } |
| 243 #endif |
| 232 widget()->Init(init_params); | 244 widget()->Init(init_params); |
| 233 | 245 |
| 234 // The frame insets are required to resolve the bounds specifications | 246 // The frame insets are required to resolve the bounds specifications |
| 235 // correctly. So we set the window bounds and constraints now. | 247 // correctly. So we set the window bounds and constraints now. |
| 236 gfx::Insets frame_insets = GetFrameInsets(); | 248 gfx::Insets frame_insets = GetFrameInsets(); |
| 237 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); | 249 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); |
| 238 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), | 250 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), |
| 239 create_params.GetContentMaximumSize(frame_insets)); | 251 create_params.GetContentMaximumSize(frame_insets)); |
| 240 if (!window_bounds.IsEmpty()) { | 252 if (!window_bounds.IsEmpty()) { |
| 241 typedef AppWindow::BoundsSpecification BoundsSpecification; | 253 typedef AppWindow::BoundsSpecification BoundsSpecification; |
| 242 bool position_specified = | 254 bool position_specified = |
| 243 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && | 255 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && |
| 244 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; | 256 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; |
| 245 if (!position_specified) | 257 if (!position_specified) |
| 246 widget()->CenterWindow(window_bounds.size()); | 258 widget()->CenterWindow(window_bounds.size()); |
| 247 else | 259 else |
| 248 widget()->SetBounds(window_bounds); | 260 widget()->SetBounds(window_bounds); |
| 249 } | 261 } |
| 250 | 262 |
| 251 if (IsFrameless() && | 263 if (IsFrameless() && |
| 252 init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW) { | 264 init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW) { |
| 253 // The given window is most likely not rectangular since it uses | 265 // The given window is most likely not rectangular since it uses |
| 254 // transparency and has no standard frame, don't show a shadow for it. | 266 // transparency and has no standard frame, don't show a shadow for it. |
| 255 // TODO(skuhne): If we run into an application which should have a shadow | 267 // TODO(skuhne): If we run into an application which should have a shadow |
| 256 // but does not have, a new attribute has to be added. | 268 // but does not have, a new attribute has to be added. |
| 257 wm::SetShadowType(widget()->GetNativeWindow(), wm::SHADOW_TYPE_NONE); | 269 wm::SetShadowType(widget()->GetNativeWindow(), wm::SHADOW_TYPE_NONE); |
| 258 } | 270 } |
| 259 | 271 |
| 272 #if defined(OS_CHROMEOS) |
| 273 if (create_params.is_ime_window) |
| 274 return; |
| 275 #endif |
| 276 |
| 260 // Register accelarators supported by app windows. | 277 // Register accelarators supported by app windows. |
| 261 // TODO(jeremya/stevenjb): should these be registered for panels too? | 278 // TODO(jeremya/stevenjb): should these be registered for panels too? |
| 262 views::FocusManager* focus_manager = GetFocusManager(); | 279 views::FocusManager* focus_manager = GetFocusManager(); |
| 263 const std::map<ui::Accelerator, int>& accelerator_table = | 280 const std::map<ui::Accelerator, int>& accelerator_table = |
| 264 GetAcceleratorTable(); | 281 GetAcceleratorTable(); |
| 265 const bool is_kiosk_app_mode = chrome::IsRunningInForcedAppMode(); | 282 const bool is_kiosk_app_mode = chrome::IsRunningInForcedAppMode(); |
| 266 | 283 |
| 267 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be | 284 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be |
| 268 // future proof). This is needed because GetAcceleratorTable() uses a static | 285 // future proof). This is needed because GetAcceleratorTable() uses a static |
| 269 // to store data and only checks kiosk mode once. If a platform app is | 286 // to store data and only checks kiosk mode once. If a platform app is |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 InitializePanelWindow(create_params); | 695 InitializePanelWindow(create_params); |
| 679 } else { | 696 } else { |
| 680 InitializeDefaultWindow(create_params); | 697 InitializeDefaultWindow(create_params); |
| 681 } | 698 } |
| 682 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 699 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
| 683 Profile::FromBrowserContext(app_window->browser_context()), | 700 Profile::FromBrowserContext(app_window->browser_context()), |
| 684 widget()->GetFocusManager(), | 701 widget()->GetFocusManager(), |
| 685 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 702 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 686 NULL)); | 703 NULL)); |
| 687 } | 704 } |
| OLD | NEW |