Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 | 245 |
| 246 // TODO(gbillock): This is currently called in production by the CanPrint | 246 // TODO(gbillock): This is currently called in production by the CanPrint |
| 247 // method, and may be too restrictive if we allow print preview to overlap. | 247 // method, and may be too restrictive if we allow print preview to overlap. |
| 248 // Re-assess how to queue print preview after we know more about popup | 248 // Re-assess how to queue print preview after we know more about popup |
| 249 // management policy. | 249 // management policy. |
| 250 const web_modal::WebContentsModalDialogManager* manager = | 250 const web_modal::WebContentsModalDialogManager* manager = |
| 251 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); | 251 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
| 252 return manager && manager->IsDialogActive(); | 252 return manager && manager->IsDialogActive(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 #if defined(ENABLE_BASIC_PRINTING) | 255 #if defined(ENABLE_BASIC_PRINTING) && !defined(OS_CHROMEOS) |
| 256 bool PrintPreviewShowing(const Browser* browser) { | 256 bool PrintPreviewShowing(const Browser* browser) { |
| 257 #if defined(ENABLE_PRINT_PREVIEW) | 257 #if defined(ENABLE_PRINT_PREVIEW) |
| 258 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); | 258 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); |
| 259 printing::PrintPreviewDialogController* controller = | 259 printing::PrintPreviewDialogController* controller = |
| 260 printing::PrintPreviewDialogController::GetInstance(); | 260 printing::PrintPreviewDialogController::GetInstance(); |
| 261 return controller && (controller->GetPrintPreviewForContents(contents) || | 261 return controller && (controller->GetPrintPreviewForContents(contents) || |
| 262 controller->is_creating_print_preview_dialog()); | 262 controller->is_creating_print_preview_dialog()); |
| 263 #else | 263 #else |
| 264 return false; | 264 return false; |
| 265 #endif | 265 #endif |
| 266 } | 266 } |
| 267 #endif // ENABLE_BASIC_PRINTING | 267 #endif // ENABLE_BASIC_PRINTING && !OS_CHROMEOS |
|
Lei Zhang
2016/10/03 23:03:58
While we are here, can you change this to:
#endif
skau
2016/10/03 23:32:13
Done.
| |
| 268 | 268 |
| 269 } // namespace | 269 } // namespace |
| 270 | 270 |
| 271 bool IsCommandEnabled(Browser* browser, int command) { | 271 bool IsCommandEnabled(Browser* browser, int command) { |
| 272 return browser->command_controller()->command_updater()->IsCommandEnabled( | 272 return browser->command_controller()->command_updater()->IsCommandEnabled( |
| 273 command); | 273 command); |
| 274 } | 274 } |
| 275 | 275 |
| 276 bool SupportsCommand(Browser* browser, int command) { | 276 bool SupportsCommand(Browser* browser, int command) { |
| 277 return browser->command_controller()->command_updater()->SupportsCommand( | 277 return browser->command_controller()->command_updater()->SupportsCommand( |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 !(IsShowingWebContentsModalDialog(browser) || | 894 !(IsShowingWebContentsModalDialog(browser) || |
| 895 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); | 895 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); |
| 896 } | 896 } |
| 897 | 897 |
| 898 #if defined(ENABLE_BASIC_PRINTING) | 898 #if defined(ENABLE_BASIC_PRINTING) |
| 899 void BasicPrint(Browser* browser) { | 899 void BasicPrint(Browser* browser) { |
| 900 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); | 900 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); |
| 901 } | 901 } |
| 902 | 902 |
| 903 bool CanBasicPrint(Browser* browser) { | 903 bool CanBasicPrint(Browser* browser) { |
| 904 #if defined(OS_CHROMEOS) | |
| 905 return false; // ChromeOS does not use the system print dialog. | |
| 906 #else | |
| 904 // If printing is not disabled via pref or policy, it is always possible to | 907 // If printing is not disabled via pref or policy, it is always possible to |
| 905 // advanced print when the print preview is visible. | 908 // advanced print when the print preview is visible. |
| 906 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 909 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
| 907 (PrintPreviewShowing(browser) || CanPrint(browser)); | 910 (PrintPreviewShowing(browser) || CanPrint(browser)); |
| 911 #endif // OS_CHROMEOS | |
|
Lei Zhang
2016/10/03 23:03:58
Ditto.
skau
2016/10/03 23:32:13
Done.
| |
| 908 } | 912 } |
| 909 #endif // ENABLE_BASIC_PRINTING | 913 #endif // ENABLE_BASIC_PRINTING |
| 910 | 914 |
| 911 bool CanRouteMedia(Browser* browser) { | 915 bool CanRouteMedia(Browser* browser) { |
| 912 // Do not allow user to open Media Router dialog when there is already an | 916 // Do not allow user to open Media Router dialog when there is already an |
| 913 // active modal dialog. This avoids overlapping dialogs. | 917 // active modal dialog. This avoids overlapping dialogs. |
| 914 return media_router::MediaRouterEnabled(browser->profile()) && | 918 return media_router::MediaRouterEnabled(browser->profile()) && |
| 915 !IsShowingWebContentsModalDialog(browser); | 919 !IsShowingWebContentsModalDialog(browser); |
| 916 } | 920 } |
| 917 | 921 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1292 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); | 1296 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
| 1293 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1297 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1294 | 1298 |
| 1295 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1299 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1296 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1300 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1297 app_browser->window()->Show(); | 1301 app_browser->window()->Show(); |
| 1298 } | 1302 } |
| 1299 #endif // defined(ENABLE_EXTENSIONS) | 1303 #endif // defined(ENABLE_EXTENSIONS) |
| 1300 | 1304 |
| 1301 } // namespace chrome | 1305 } // namespace chrome |
| OLD | NEW |