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 20 matching lines...) Expand all Loading... | |
31 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
32 #include "chrome/browser/shell_integration_linux.h" | 32 #include "chrome/browser/shell_integration_linux.h" |
33 #endif | 33 #endif |
34 | 34 |
35 #if defined(USE_ASH) | 35 #if defined(USE_ASH) |
36 #include "ash/ash_constants.h" | 36 #include "ash/ash_constants.h" |
37 #include "ash/ash_switches.h" | 37 #include "ash/ash_switches.h" |
38 #include "ash/frame/custom_frame_view_ash.h" | 38 #include "ash/frame/custom_frame_view_ash.h" |
39 #include "ash/screen_util.h" | 39 #include "ash/screen_util.h" |
40 #include "ash/shell.h" | 40 #include "ash/shell.h" |
41 #include "ash/shell_window_ids.h" | |
41 #include "ash/wm/immersive_fullscreen_controller.h" | 42 #include "ash/wm/immersive_fullscreen_controller.h" |
42 #include "ash/wm/panels/panel_frame_view.h" | 43 #include "ash/wm/panels/panel_frame_view.h" |
43 #include "ash/wm/window_properties.h" | 44 #include "ash/wm/window_properties.h" |
44 #include "ash/wm/window_state.h" | 45 #include "ash/wm/window_state.h" |
45 #include "ash/wm/window_state_delegate.h" | 46 #include "ash/wm/window_state_delegate.h" |
46 #include "ash/wm/window_state_observer.h" | 47 #include "ash/wm/window_state_observer.h" |
47 #include "chrome/browser/ui/ash/ash_util.h" | 48 #include "chrome/browser/ui/ash/ash_util.h" |
48 #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" |
49 #include "ui/aura/client/aura_constants.h" | 50 #include "ui/aura/client/aura_constants.h" |
50 #include "ui/aura/client/window_tree_client.h" | 51 #include "ui/aura/client/window_tree_client.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 220 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
220 // Set up a custom WM_CLASS for app windows. This allows task switchers in | 221 // Set up a custom WM_CLASS for app windows. This allows task switchers in |
221 // X11 environments to distinguish them from main browser windows. | 222 // X11 environments to distinguish them from main browser windows. |
222 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); | 223 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); |
223 init_params.wm_class_class = shell_integration_linux::GetProgramClassName(); | 224 init_params.wm_class_class = shell_integration_linux::GetProgramClassName(); |
224 const char kX11WindowRoleApp[] = "app"; | 225 const char kX11WindowRoleApp[] = "app"; |
225 init_params.wm_role_name = std::string(kX11WindowRoleApp); | 226 init_params.wm_role_name = std::string(kX11WindowRoleApp); |
226 #endif | 227 #endif |
227 | 228 |
228 OnBeforeWidgetInit(&init_params, widget()); | 229 OnBeforeWidgetInit(&init_params, widget()); |
230 #if defined(USE_ASH) | |
benwells
2014/09/09 00:02:30
This will compile on most platforms. Is it a probl
bshe
2014/09/10 22:34:55
Restricted to chromeos only as IME is ChromeOS onl
| |
231 if (create_params.is_ime_window) { | |
232 // Puts ime windows to ime window container. | |
benwells
2014/09/09 00:02:30
Nit: s/to/into/ .... or something.
bshe
2014/09/10 22:34:55
Done.
| |
233 init_params.parent = ash::Shell::GetContainer( | |
234 ash::Shell::GetPrimaryRootWindow(), | |
235 ash::kShellWindowId_ImeWindowParentContainer); | |
236 } | |
237 #endif | |
229 widget()->Init(init_params); | 238 widget()->Init(init_params); |
230 | 239 |
231 // The frame insets are required to resolve the bounds specifications | 240 // The frame insets are required to resolve the bounds specifications |
232 // correctly. So we set the window bounds and constraints now. | 241 // correctly. So we set the window bounds and constraints now. |
233 gfx::Insets frame_insets = GetFrameInsets(); | 242 gfx::Insets frame_insets = GetFrameInsets(); |
234 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); | 243 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); |
235 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), | 244 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), |
236 create_params.GetContentMaximumSize(frame_insets)); | 245 create_params.GetContentMaximumSize(frame_insets)); |
237 if (!window_bounds.IsEmpty()) { | 246 if (!window_bounds.IsEmpty()) { |
238 typedef AppWindow::BoundsSpecification BoundsSpecification; | 247 typedef AppWindow::BoundsSpecification BoundsSpecification; |
239 bool position_specified = | 248 bool position_specified = |
240 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && | 249 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && |
241 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; | 250 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; |
242 if (!position_specified) | 251 if (!position_specified) |
243 widget()->CenterWindow(window_bounds.size()); | 252 widget()->CenterWindow(window_bounds.size()); |
244 else | 253 else |
245 widget()->SetBounds(window_bounds); | 254 widget()->SetBounds(window_bounds); |
246 } | 255 } |
247 | 256 |
248 if (IsFrameless() && | 257 if (IsFrameless() && |
249 init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW) { | 258 init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW) { |
250 // The given window is most likely not rectangular since it uses | 259 // The given window is most likely not rectangular since it uses |
251 // transparency and has no standard frame, don't show a shadow for it. | 260 // transparency and has no standard frame, don't show a shadow for it. |
252 // TODO(skuhne): If we run into an application which should have a shadow | 261 // TODO(skuhne): If we run into an application which should have a shadow |
253 // but does not have, a new attribute has to be added. | 262 // but does not have, a new attribute has to be added. |
254 wm::SetShadowType(widget()->GetNativeWindow(), wm::SHADOW_TYPE_NONE); | 263 wm::SetShadowType(widget()->GetNativeWindow(), wm::SHADOW_TYPE_NONE); |
255 } | 264 } |
256 | 265 |
266 #if defined(USE_ASH) | |
benwells
2014/09/09 00:02:30
I think this part should defitely restrict on the
bshe
2014/09/10 22:34:55
Done.
| |
267 if (create_params.is_ime_window) | |
268 return; | |
269 #endif | |
270 | |
257 // Register accelarators supported by app windows. | 271 // Register accelarators supported by app windows. |
258 // TODO(jeremya/stevenjb): should these be registered for panels too? | 272 // TODO(jeremya/stevenjb): should these be registered for panels too? |
259 views::FocusManager* focus_manager = GetFocusManager(); | 273 views::FocusManager* focus_manager = GetFocusManager(); |
260 const std::map<ui::Accelerator, int>& accelerator_table = | 274 const std::map<ui::Accelerator, int>& accelerator_table = |
261 GetAcceleratorTable(); | 275 GetAcceleratorTable(); |
262 const bool is_kiosk_app_mode = chrome::IsRunningInForcedAppMode(); | 276 const bool is_kiosk_app_mode = chrome::IsRunningInForcedAppMode(); |
263 | 277 |
264 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be | 278 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be |
265 // future proof). This is needed because GetAcceleratorTable() uses a static | 279 // future proof). This is needed because GetAcceleratorTable() uses a static |
266 // to store data and only checks kiosk mode once. If a platform app is | 280 // to store data and only checks kiosk mode once. If a platform app is |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 InitializePanelWindow(create_params); | 682 InitializePanelWindow(create_params); |
669 } else { | 683 } else { |
670 InitializeDefaultWindow(create_params); | 684 InitializeDefaultWindow(create_params); |
671 } | 685 } |
672 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 686 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
673 Profile::FromBrowserContext(app_window->browser_context()), | 687 Profile::FromBrowserContext(app_window->browser_context()), |
674 widget()->GetFocusManager(), | 688 widget()->GetFocusManager(), |
675 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 689 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
676 NULL)); | 690 NULL)); |
677 } | 691 } |
OLD | NEW |