| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // reserve browser back/forward and refresh here. | 180 // reserve browser back/forward and refresh here. |
| 181 ui::KeyboardCode key_code = | 181 ui::KeyboardCode key_code = |
| 182 static_cast<ui::KeyboardCode>(event.windowsKeyCode); | 182 static_cast<ui::KeyboardCode>(event.windowsKeyCode); |
| 183 if ((key_code == ui::VKEY_BROWSER_BACK && command_id == IDC_BACK) || | 183 if ((key_code == ui::VKEY_BROWSER_BACK && command_id == IDC_BACK) || |
| 184 (key_code == ui::VKEY_BROWSER_FORWARD && command_id == IDC_FORWARD) || | 184 (key_code == ui::VKEY_BROWSER_FORWARD && command_id == IDC_FORWARD) || |
| 185 (key_code == ui::VKEY_BROWSER_REFRESH && command_id == IDC_RELOAD)) { | 185 (key_code == ui::VKEY_BROWSER_REFRESH && command_id == IDC_RELOAD)) { |
| 186 return true; | 186 return true; |
| 187 } | 187 } |
| 188 #endif | 188 #endif |
| 189 | 189 |
| 190 const bool is_tab_or_window_command = | |
| 191 command_id == IDC_CLOSE_TAB || | |
| 192 command_id == IDC_CLOSE_WINDOW || | |
| 193 command_id == IDC_NEW_INCOGNITO_WINDOW || | |
| 194 command_id == IDC_NEW_TAB || | |
| 195 command_id == IDC_NEW_WINDOW || | |
| 196 command_id == IDC_RESTORE_TAB || | |
| 197 command_id == IDC_SELECT_NEXT_TAB || | |
| 198 command_id == IDC_SELECT_PREVIOUS_TAB; | |
| 199 if (window()->IsFullscreen()) { | 190 if (window()->IsFullscreen()) { |
| 200 // In fullscreen, all commands except for IDC_FULLSCREEN and IDC_EXIT should | 191 // In fullscreen, all commands except for IDC_FULLSCREEN and IDC_EXIT should |
| 201 // be delivered to the web page. See https://goo.gl/4tJ32G. | 192 // be delivered to the web page. See, intent to implement, |
| 202 if (command_id == IDC_FULLSCREEN) | 193 // https://goo.gl/4tJ32G. |
| 203 return true; | 194 return command_id == IDC_EXIT || command_id == IDC_FULLSCREEN; |
| 204 if (is_tab_or_window_command) | |
| 205 return false; | |
| 206 } | 195 } |
| 207 | 196 |
| 208 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 197 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 209 // If this key was registered by the user as a content editing hotkey, then | 198 // If this key was registered by the user as a content editing hotkey, then |
| 210 // it is not reserved. | 199 // it is not reserved. |
| 211 ui::TextEditKeyBindingsDelegateAuraLinux* delegate = | 200 ui::TextEditKeyBindingsDelegateAuraLinux* delegate = |
| 212 ui::GetTextEditKeyBindingsDelegate(); | 201 ui::GetTextEditKeyBindingsDelegate(); |
| 213 if (delegate && event.os_event && delegate->MatchEvent(*event.os_event, NULL)) | 202 if (delegate && event.os_event && delegate->MatchEvent(*event.os_event, NULL)) |
| 214 return false; | 203 return false; |
| 215 #endif | 204 #endif |
| 216 | 205 |
| 217 return is_tab_or_window_command || command_id == IDC_EXIT; | 206 return command_id == IDC_CLOSE_TAB || |
| 207 command_id == IDC_CLOSE_WINDOW || |
| 208 command_id == IDC_NEW_INCOGNITO_WINDOW || |
| 209 command_id == IDC_NEW_TAB || |
| 210 command_id == IDC_NEW_WINDOW || |
| 211 command_id == IDC_RESTORE_TAB || |
| 212 command_id == IDC_SELECT_NEXT_TAB || |
| 213 command_id == IDC_SELECT_PREVIOUS_TAB || |
| 214 command_id == IDC_EXIT; |
| 218 } | 215 } |
| 219 | 216 |
| 220 void BrowserCommandController::SetBlockCommandExecution(bool block) { | 217 void BrowserCommandController::SetBlockCommandExecution(bool block) { |
| 221 block_command_execution_ = block; | 218 block_command_execution_ = block; |
| 222 if (block) { | 219 if (block) { |
| 223 last_blocked_command_id_ = -1; | 220 last_blocked_command_id_ = -1; |
| 224 last_blocked_command_disposition_ = WindowOpenDisposition::CURRENT_TAB; | 221 last_blocked_command_disposition_ = WindowOpenDisposition::CURRENT_TAB; |
| 225 } | 222 } |
| 226 } | 223 } |
| 227 | 224 |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 const bool fullscreen_enabled = is_fullscreen || | 1069 const bool fullscreen_enabled = is_fullscreen || |
| 1073 profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed); | 1070 profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed); |
| 1074 #else | 1071 #else |
| 1075 const bool fullscreen_enabled = true; | 1072 const bool fullscreen_enabled = true; |
| 1076 #endif | 1073 #endif |
| 1077 | 1074 |
| 1078 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled); | 1075 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled); |
| 1079 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_FULLSCREEN_TOOLBAR, | 1076 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_FULLSCREEN_TOOLBAR, |
| 1080 fullscreen_enabled); | 1077 fullscreen_enabled); |
| 1081 | 1078 |
| 1082 command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, !is_fullscreen); | |
| 1083 command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, !is_fullscreen); | |
| 1084 command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, | |
| 1085 !is_fullscreen); | |
| 1086 command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, !is_fullscreen); | |
| 1087 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, !is_fullscreen); | |
| 1088 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, !is_fullscreen); | |
| 1089 command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, !is_fullscreen); | |
| 1090 command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB, | |
| 1091 !is_fullscreen); | |
| 1092 | |
| 1093 UpdateCommandsForBookmarkBar(); | 1079 UpdateCommandsForBookmarkBar(); |
| 1094 } | 1080 } |
| 1095 | 1081 |
| 1096 void BrowserCommandController::UpdatePrintingState() { | 1082 void BrowserCommandController::UpdatePrintingState() { |
| 1097 bool print_enabled = CanPrint(browser_); | 1083 bool print_enabled = CanPrint(browser_); |
| 1098 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); | 1084 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
| 1099 #if BUILDFLAG(ENABLE_BASIC_PRINTING) | 1085 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 1100 command_updater_.UpdateCommandEnabled(IDC_BASIC_PRINT, | 1086 command_updater_.UpdateCommandEnabled(IDC_BASIC_PRINT, |
| 1101 CanBasicPrint(browser_)); | 1087 CanBasicPrint(browser_)); |
| 1102 #endif // ENABLE_BASIC_PRINTING | 1088 #endif // ENABLE_BASIC_PRINTING |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 | 1159 |
| 1174 BrowserWindow* BrowserCommandController::window() { | 1160 BrowserWindow* BrowserCommandController::window() { |
| 1175 return browser_->window(); | 1161 return browser_->window(); |
| 1176 } | 1162 } |
| 1177 | 1163 |
| 1178 Profile* BrowserCommandController::profile() { | 1164 Profile* BrowserCommandController::profile() { |
| 1179 return browser_->profile(); | 1165 return browser_->profile(); |
| 1180 } | 1166 } |
| 1181 | 1167 |
| 1182 } // namespace chrome | 1168 } // namespace chrome |
| OLD | NEW |