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" |
11 #include "chrome/browser/chrome_page_zoom.h" | 11 #include "chrome/browser/chrome_page_zoom.h" |
12 #include "chrome/browser/favicon/favicon_tab_helper.h" | 12 #include "chrome/browser/favicon/favicon_tab_helper.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/host_desktop.h" | 14 #include "chrome/browser/ui/host_desktop.h" |
15 #include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h" | 15 #include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h" |
16 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 16 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
17 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" | 17 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" |
| 18 #include "chrome/browser/ui/zoom/zoom_controller.h" |
18 #include "chrome/browser/web_applications/web_app.h" | 19 #include "chrome/browser/web_applications/web_app.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
22 #include "ui/base/hit_test.h" | 23 #include "ui/base/hit_test.h" |
23 #include "ui/base/models/simple_menu_model.h" | 24 #include "ui/base/models/simple_menu_model.h" |
24 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
25 #include "ui/views/controls/menu/menu_runner.h" | 26 #include "ui/views/controls/menu/menu_runner.h" |
26 #include "ui/views/controls/webview/webview.h" | 27 #include "ui/views/controls/webview/webview.h" |
27 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be | 267 // Ensures that kiosk mode accelerators are enabled when in kiosk mode (to be |
267 // future proof). This is needed because GetAcceleratorTable() uses a static | 268 // future proof). This is needed because GetAcceleratorTable() uses a static |
268 // to store data and only checks kiosk mode once. If a platform app is | 269 // to store data and only checks kiosk mode once. If a platform app is |
269 // launched before kiosk mode starts, the kiosk accelerators will not be | 270 // launched before kiosk mode starts, the kiosk accelerators will not be |
270 // registered. This DCHECK catches the case. | 271 // registered. This DCHECK catches the case. |
271 DCHECK(!is_kiosk_app_mode || | 272 DCHECK(!is_kiosk_app_mode || |
272 accelerator_table.size() == | 273 accelerator_table.size() == |
273 arraysize(kAppWindowAcceleratorMap) + | 274 arraysize(kAppWindowAcceleratorMap) + |
274 arraysize(kAppWindowKioskAppModeAcceleratorMap)); | 275 arraysize(kAppWindowKioskAppModeAcceleratorMap)); |
275 | 276 |
| 277 // Ensure there is a ZoomController in kiosk mode, otherwise the processing |
| 278 // of the accelerators will cause a crash. |
| 279 DCHECK(!is_kiosk_app_mode || |
| 280 ZoomController::FromWebContents(web_view()->GetWebContents())); |
| 281 |
276 for (std::map<ui::Accelerator, int>::const_iterator iter = | 282 for (std::map<ui::Accelerator, int>::const_iterator iter = |
277 accelerator_table.begin(); | 283 accelerator_table.begin(); |
278 iter != accelerator_table.end(); ++iter) { | 284 iter != accelerator_table.end(); ++iter) { |
279 if (is_kiosk_app_mode && !chrome::IsCommandAllowedInAppMode(iter->second)) | 285 if (is_kiosk_app_mode && !chrome::IsCommandAllowedInAppMode(iter->second)) |
280 continue; | 286 continue; |
281 | 287 |
282 focus_manager->RegisterAccelerator( | 288 focus_manager->RegisterAccelerator( |
283 iter->first, ui::AcceleratorManager::kNormalPriority, this); | 289 iter->first, ui::AcceleratorManager::kNormalPriority, this); |
284 } | 290 } |
285 } | 291 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 InitializePanelWindow(create_params); | 676 InitializePanelWindow(create_params); |
671 } else { | 677 } else { |
672 InitializeDefaultWindow(create_params); | 678 InitializeDefaultWindow(create_params); |
673 } | 679 } |
674 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 680 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
675 Profile::FromBrowserContext(app_window->browser_context()), | 681 Profile::FromBrowserContext(app_window->browser_context()), |
676 widget()->GetFocusManager(), | 682 widget()->GetFocusManager(), |
677 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 683 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
678 NULL)); | 684 NULL)); |
679 } | 685 } |
OLD | NEW |