OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_command_controller.h" | 5 #include "chrome/browser/ui/browser_command_controller.h" |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/defaults.h" | 9 #include "chrome/browser/defaults.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/printing/print_preview_tab_controller.h" | 13 #include "chrome/browser/printing/print_preview_tab_controller.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/sessions/tab_restore_service.h" | 16 #include "chrome/browser/sessions/tab_restore_service.h" |
17 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
18 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
19 #include "chrome/browser/sync/profile_sync_service_factory.h" | 19 #include "chrome/browser/sync/profile_sync_service_factory.h" |
20 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 20 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_commands.h" | 22 #include "chrome/browser/ui/browser_commands.h" |
23 #include "chrome/browser/ui/browser_tabstrip.h" | 23 #include "chrome/browser/ui/browser_tabstrip.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/browser/ui/chrome_pages.h" | 25 #include "chrome/browser/ui/chrome_pages.h" |
26 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | |
26 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 27 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
28 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 29 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
29 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
31 #include "chrome/common/profiling.h" | 32 #include "chrome/common/profiling.h" |
32 #include "content/public/browser/native_web_keyboard_event.h" | 33 #include "content/public/browser/native_web_keyboard_event.h" |
33 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
34 #include "content/public/browser/navigation_entry.h" | 35 #include "content/public/browser/navigation_entry.h" |
35 #include "content/public/browser/notification_details.h" | 36 #include "content/public/browser/notification_details.h" |
36 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
37 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
38 #include "content/public/common/content_restriction.h" | 39 #include "content/public/common/content_restriction.h" |
39 #include "content/public/common/url_constants.h" | 40 #include "content/public/common/url_constants.h" |
40 #include "ui/base/keycodes/keyboard_codes.h" | 41 #include "ui/base/keycodes/keyboard_codes.h" |
41 | 42 |
42 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
43 #include "base/win/metro.h" | 44 #include "base/win/metro.h" |
44 #endif | 45 #endif |
45 | 46 |
47 #if defined(USE_ASH) | |
48 #include "ash/wm/window_util.h" | |
49 #endif | |
50 | |
46 using content::WebContents; | 51 using content::WebContents; |
47 using content::NavigationEntry; | 52 using content::NavigationEntry; |
48 using content::NavigationController; | 53 using content::NavigationController; |
49 using content::WebContents; | 54 using content::WebContents; |
50 | 55 |
51 namespace { | 56 namespace { |
52 | 57 |
53 // Returns |true| if entry has an internal chrome:// URL, |false| otherwise. | 58 // Returns |true| if entry has an internal chrome:// URL, |false| otherwise. |
54 bool HasInternalURL(const NavigationEntry* entry) { | 59 bool HasInternalURL(const NavigationEntry* entry) { |
55 if (!entry) | 60 if (!entry) |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 break; | 280 break; |
276 | 281 |
277 // Window management commands | 282 // Window management commands |
278 case IDC_NEW_WINDOW: | 283 case IDC_NEW_WINDOW: |
279 NewWindow(browser_); | 284 NewWindow(browser_); |
280 break; | 285 break; |
281 case IDC_NEW_INCOGNITO_WINDOW: | 286 case IDC_NEW_INCOGNITO_WINDOW: |
282 NewIncognitoWindow(browser_); | 287 NewIncognitoWindow(browser_); |
283 break; | 288 break; |
284 case IDC_CLOSE_WINDOW: | 289 case IDC_CLOSE_WINDOW: |
285 CloseWindow(browser_); | 290 // Destroying a tab / browser window while it has opened a full screen |
Ben Goodger (Google)
2012/08/10 15:00:12
Hrm. This works on Windows today (STR: open a new
| |
291 // window will destroy it's content class - which will destroy the | |
292 // delegate - which is also used by the opened full screen window's | |
293 // event handler. That will cause then a crash. To avoid that we supress | |
294 // closing of windows via key stroke while a full screen window is open. | |
295 // http://crbug.com/134465, http://crbug.com/131436 | |
296 if (!IsFullScreenWindowOpen()) | |
297 CloseWindow(browser_); | |
286 break; | 298 break; |
287 case IDC_NEW_TAB: | 299 case IDC_NEW_TAB: |
288 NewTab(browser_); | 300 NewTab(browser_); |
289 break; | 301 break; |
290 case IDC_CLOSE_TAB: | 302 case IDC_CLOSE_TAB: |
291 CloseTab(browser_); | 303 // Destroying a tab / browser window while it has opened a full screen |
304 // window will destroy it's content class - which will destroy the | |
305 // delegate - which is also used by the opened full screen window's | |
306 // event handler. That will cause then a crash. To avoid that we supress | |
307 // closing of windows via key stroke while a full screen window is open. | |
308 // http://crbug.com/134465, http://crbug.com/131436 | |
309 if (!IsFullScreenWindowOpen()) | |
310 CloseTab(browser_); | |
292 break; | 311 break; |
293 case IDC_SELECT_NEXT_TAB: | 312 case IDC_SELECT_NEXT_TAB: |
294 SelectNextTab(browser_); | 313 SelectNextTab(browser_); |
295 break; | 314 break; |
296 case IDC_SELECT_PREVIOUS_TAB: | 315 case IDC_SELECT_PREVIOUS_TAB: |
297 SelectPreviousTab(browser_); | 316 SelectPreviousTab(browser_); |
298 break; | 317 break; |
299 case IDC_TABPOSE: | 318 case IDC_TABPOSE: |
300 OpenTabpose(browser_); | 319 OpenTabpose(browser_); |
301 break; | 320 break; |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 } | 1090 } |
1072 | 1091 |
1073 BrowserWindow* BrowserCommandController::window() { | 1092 BrowserWindow* BrowserCommandController::window() { |
1074 return browser_->window(); | 1093 return browser_->window(); |
1075 } | 1094 } |
1076 | 1095 |
1077 Profile* BrowserCommandController::profile() { | 1096 Profile* BrowserCommandController::profile() { |
1078 return browser_->profile(); | 1097 return browser_->profile(); |
1079 } | 1098 } |
1080 | 1099 |
1100 bool BrowserCommandController::IsFullScreenWindowOpen() { | |
1101 #if defined(USE_ASH) | |
1102 aura::Window* window = ash::wm::GetActiveWindow(); | |
1103 return (window && ash::wm::IsWindowFullscreen(window)); | |
1104 #else | |
1105 return false; | |
1106 #endif | |
1107 } | |
1108 | |
1081 } // namespace chrome | 1109 } // namespace chrome |
OLD | NEW |