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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "ash/wm/window_state.h" | 44 #include "ash/wm/window_state.h" |
45 #include "ash/wm/window_state_delegate.h" | 45 #include "ash/wm/window_state_delegate.h" |
46 #include "ash/wm/window_state_observer.h" | 46 #include "ash/wm/window_state_observer.h" |
47 #include "chrome/browser/ui/ash/ash_util.h" | 47 #include "chrome/browser/ui/ash/ash_util.h" |
48 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" | 48 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" |
49 #include "ui/aura/client/aura_constants.h" | 49 #include "ui/aura/client/aura_constants.h" |
50 #include "ui/aura/client/window_tree_client.h" | 50 #include "ui/aura/client/window_tree_client.h" |
51 #include "ui/aura/window_observer.h" | 51 #include "ui/aura/window_observer.h" |
52 #endif | 52 #endif |
53 | 53 |
54 #if defined(OS_CHROMEOS) | |
benwells
2014/09/11 19:35:10
what about ash on windows etc.? It doesn't seem li
bshe
2014/09/11 22:35:59
IME api and the component extensions are not avail
| |
55 #include "ash/shell_window_ids.h" | |
56 #endif | |
57 | |
54 using extensions::AppWindow; | 58 using extensions::AppWindow; |
55 | 59 |
56 namespace { | 60 namespace { |
57 | 61 |
58 const int kMinPanelWidth = 100; | 62 const int kMinPanelWidth = 100; |
59 const int kMinPanelHeight = 100; | 63 const int kMinPanelHeight = 100; |
60 const int kDefaultPanelWidth = 200; | 64 const int kDefaultPanelWidth = 200; |
61 const int kDefaultPanelHeight = 300; | 65 const int kDefaultPanelHeight = 300; |
62 | 66 |
63 struct AcceleratorMapping { | 67 struct AcceleratorMapping { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 223 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
220 // Set up a custom WM_CLASS for app windows. This allows task switchers in | 224 // Set up a custom WM_CLASS for app windows. This allows task switchers in |
221 // X11 environments to distinguish them from main browser windows. | 225 // X11 environments to distinguish them from main browser windows. |
222 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); | 226 init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name); |
223 init_params.wm_class_class = shell_integration_linux::GetProgramClassName(); | 227 init_params.wm_class_class = shell_integration_linux::GetProgramClassName(); |
224 const char kX11WindowRoleApp[] = "app"; | 228 const char kX11WindowRoleApp[] = "app"; |
225 init_params.wm_role_name = std::string(kX11WindowRoleApp); | 229 init_params.wm_role_name = std::string(kX11WindowRoleApp); |
226 #endif | 230 #endif |
227 | 231 |
228 OnBeforeWidgetInit(&init_params, widget()); | 232 OnBeforeWidgetInit(&init_params, widget()); |
233 #if defined(OS_CHROMEOS) | |
234 if (create_params.is_ime_window) { | |
235 // Puts ime windows into ime window container. | |
236 init_params.parent = ash::Shell::GetContainer( | |
237 ash::Shell::GetPrimaryRootWindow(), | |
238 ash::kShellWindowId_ImeWindowParentContainer); | |
239 } | |
240 #endif | |
229 widget()->Init(init_params); | 241 widget()->Init(init_params); |
230 | 242 |
231 // The frame insets are required to resolve the bounds specifications | 243 // The frame insets are required to resolve the bounds specifications |
232 // correctly. So we set the window bounds and constraints now. | 244 // correctly. So we set the window bounds and constraints now. |
233 gfx::Insets frame_insets = GetFrameInsets(); | 245 gfx::Insets frame_insets = GetFrameInsets(); |
234 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); | 246 gfx::Rect window_bounds = create_params.GetInitialWindowBounds(frame_insets); |
235 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), | 247 SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets), |
236 create_params.GetContentMaximumSize(frame_insets)); | 248 create_params.GetContentMaximumSize(frame_insets)); |
237 if (!window_bounds.IsEmpty()) { | 249 if (!window_bounds.IsEmpty()) { |
238 typedef AppWindow::BoundsSpecification BoundsSpecification; | 250 typedef AppWindow::BoundsSpecification BoundsSpecification; |
239 bool position_specified = | 251 bool position_specified = |
240 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && | 252 window_bounds.x() != BoundsSpecification::kUnspecifiedPosition && |
241 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; | 253 window_bounds.y() != BoundsSpecification::kUnspecifiedPosition; |
242 if (!position_specified) | 254 if (!position_specified) |
243 widget()->CenterWindow(window_bounds.size()); | 255 widget()->CenterWindow(window_bounds.size()); |
244 else | 256 else |
245 widget()->SetBounds(window_bounds); | 257 widget()->SetBounds(window_bounds); |
246 } | 258 } |
247 | 259 |
248 if (IsFrameless() && | 260 if (IsFrameless() && |
249 init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW) { | 261 init_params.opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW) { |
250 // The given window is most likely not rectangular since it uses | 262 // 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. | 263 // 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 | 264 // 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. | 265 // but does not have, a new attribute has to be added. |
254 wm::SetShadowType(widget()->GetNativeWindow(), wm::SHADOW_TYPE_NONE); | 266 wm::SetShadowType(widget()->GetNativeWindow(), wm::SHADOW_TYPE_NONE); |
255 } | 267 } |
256 | 268 |
269 #if defined(OS_CHROMEOS) | |
270 if (create_params.is_ime_window) | |
271 return; | |
272 #endif | |
273 | |
257 // Register accelarators supported by app windows. | 274 // Register accelarators supported by app windows. |
258 // TODO(jeremya/stevenjb): should these be registered for panels too? | 275 // TODO(jeremya/stevenjb): should these be registered for panels too? |
259 views::FocusManager* focus_manager = GetFocusManager(); | 276 views::FocusManager* focus_manager = GetFocusManager(); |
260 const std::map<ui::Accelerator, int>& accelerator_table = | 277 const std::map<ui::Accelerator, int>& accelerator_table = |
261 GetAcceleratorTable(); | 278 GetAcceleratorTable(); |
262 const bool is_kiosk_app_mode = chrome::IsRunningInForcedAppMode(); | 279 const bool is_kiosk_app_mode = chrome::IsRunningInForcedAppMode(); |
263 | 280 |
264 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be | 281 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be |
265 // future proof). This is needed because GetAcceleratorTable() uses a static | 282 // 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 | 283 // 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); | 685 InitializePanelWindow(create_params); |
669 } else { | 686 } else { |
670 InitializeDefaultWindow(create_params); | 687 InitializeDefaultWindow(create_params); |
671 } | 688 } |
672 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 689 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
673 Profile::FromBrowserContext(app_window->browser_context()), | 690 Profile::FromBrowserContext(app_window->browser_context()), |
674 widget()->GetFocusManager(), | 691 widget()->GetFocusManager(), |
675 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 692 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
676 NULL)); | 693 NULL)); |
677 } | 694 } |
OLD | NEW |