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 BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
Lei Zhang
2016/10/04 22:10:54
include chrome/common/features.h
skau
2016/10/05 00:18:00
Done.
| |
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 // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
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 BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) | |
904 // If printing is not disabled via pref or policy, it is always possible to | 905 // If printing is not disabled via pref or policy, it is always possible to |
905 // advanced print when the print preview is visible. | 906 // advanced print when the print preview is visible. |
906 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 907 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
907 (PrintPreviewShowing(browser) || CanPrint(browser)); | 908 (PrintPreviewShowing(browser) || CanPrint(browser)); |
909 #else | |
910 return false; // The print dialog is disabled. | |
911 #endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) | |
908 } | 912 } |
909 #endif // ENABLE_BASIC_PRINTING | 913 #endif // defined(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 |
918 void RouteMedia(Browser* browser) { | 922 void RouteMedia(Browser* browser) { |
919 #if defined(ENABLE_MEDIA_ROUTER) | 923 #if defined(ENABLE_MEDIA_ROUTER) |
(...skipping 372 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 |