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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 #include "content/public/browser/render_view_host.h" | 77 #include "content/public/browser/render_view_host.h" |
78 #include "content/public/browser/render_widget_host_view.h" | 78 #include "content/public/browser/render_widget_host_view.h" |
79 #include "content/public/browser/user_metrics.h" | 79 #include "content/public/browser/user_metrics.h" |
80 #include "content/public/browser/web_contents.h" | 80 #include "content/public/browser/web_contents.h" |
81 #include "content/public/common/page_state.h" | 81 #include "content/public/common/page_state.h" |
82 #include "content/public/common/renderer_preferences.h" | 82 #include "content/public/common/renderer_preferences.h" |
83 #include "content/public/common/url_constants.h" | 83 #include "content/public/common/url_constants.h" |
84 #include "content/public/common/url_utils.h" | 84 #include "content/public/common/url_utils.h" |
85 #include "content/public/common/user_agent.h" | 85 #include "content/public/common/user_agent.h" |
86 #include "net/base/escape.h" | 86 #include "net/base/escape.h" |
| 87 #include "printing/features/features.h" |
87 #include "ui/events/keycodes/keyboard_codes.h" | 88 #include "ui/events/keycodes/keyboard_codes.h" |
88 | 89 |
89 #if defined(ENABLE_EXTENSIONS) | 90 #if defined(ENABLE_EXTENSIONS) |
90 #include "chrome/browser/extensions/api/commands/command_service.h" | 91 #include "chrome/browser/extensions/api/commands/command_service.h" |
91 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 92 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
92 #include "chrome/browser/extensions/tab_helper.h" | 93 #include "chrome/browser/extensions/tab_helper.h" |
93 #include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h" | 94 #include "chrome/browser/ui/extensions/settings_api_bubble_helpers.h" |
94 #include "chrome/browser/web_applications/web_app.h" | 95 #include "chrome/browser/web_applications/web_app.h" |
95 #include "chrome/common/extensions/extension_metrics.h" | 96 #include "chrome/common/extensions/extension_metrics.h" |
96 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 97 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
97 #include "extensions/browser/extension_registry.h" | 98 #include "extensions/browser/extension_registry.h" |
98 #include "extensions/browser/extension_system.h" | 99 #include "extensions/browser/extension_system.h" |
99 #include "extensions/common/extension.h" | 100 #include "extensions/common/extension.h" |
100 #include "extensions/common/extension_set.h" | 101 #include "extensions/common/extension_set.h" |
101 #endif | 102 #endif |
102 | 103 |
103 #if defined(ENABLE_PRINTING) | 104 #if BUILDFLAG(ENABLE_PRINTING) |
104 #include "chrome/browser/printing/print_view_manager_common.h" | 105 #include "chrome/browser/printing/print_view_manager_common.h" |
105 #if defined(ENABLE_PRINT_PREVIEW) | 106 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
106 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 107 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
107 #endif // defined(ENABLE_PRINT_PREVIEW) | 108 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) |
108 #endif // defined(ENABLE_PRINTING) | 109 #endif // BUILDFLAG(ENABLE_PRINTING) |
109 | 110 |
110 #if defined(ENABLE_RLZ) | 111 #if defined(ENABLE_RLZ) |
111 #include "components/rlz/rlz_tracker.h" // nogncheck | 112 #include "components/rlz/rlz_tracker.h" // nogncheck |
112 #endif | 113 #endif |
113 | 114 |
114 #if defined(ENABLE_MEDIA_ROUTER) | 115 #if defined(ENABLE_MEDIA_ROUTER) |
115 #include "chrome/browser/media/router/media_router_dialog_controller.h" // nogn
check | 116 #include "chrome/browser/media/router/media_router_dialog_controller.h" // nogn
check |
116 #endif | 117 #endif |
117 | 118 |
118 namespace { | 119 namespace { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // method, and may be too restrictive if we allow print preview to overlap. | 249 // method, and may be too restrictive if we allow print preview to overlap. |
249 // Re-assess how to queue print preview after we know more about popup | 250 // Re-assess how to queue print preview after we know more about popup |
250 // management policy. | 251 // management policy. |
251 const web_modal::WebContentsModalDialogManager* manager = | 252 const web_modal::WebContentsModalDialogManager* manager = |
252 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); | 253 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
253 return manager && manager->IsDialogActive(); | 254 return manager && manager->IsDialogActive(); |
254 } | 255 } |
255 | 256 |
256 #if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) | 257 #if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
257 bool PrintPreviewShowing(const Browser* browser) { | 258 bool PrintPreviewShowing(const Browser* browser) { |
258 #if defined(ENABLE_PRINT_PREVIEW) | 259 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
259 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); | 260 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); |
260 printing::PrintPreviewDialogController* controller = | 261 printing::PrintPreviewDialogController* controller = |
261 printing::PrintPreviewDialogController::GetInstance(); | 262 printing::PrintPreviewDialogController::GetInstance(); |
262 return controller && (controller->GetPrintPreviewForContents(contents) || | 263 return controller && (controller->GetPrintPreviewForContents(contents) || |
263 controller->is_creating_print_preview_dialog()); | 264 controller->is_creating_print_preview_dialog()); |
264 #else | 265 #else |
265 return false; | 266 return false; |
266 #endif | 267 #endif |
267 } | 268 } |
268 #endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) | 269 #endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 Browser* browser, | 867 Browser* browser, |
867 content::WebContents* web_contents, | 868 content::WebContents* web_contents, |
868 const GURL& url, | 869 const GURL& url, |
869 const security_state::SecurityStateModel::SecurityInfo& security_info) { | 870 const security_state::SecurityStateModel::SecurityInfo& security_info) { |
870 browser->window()->ShowWebsiteSettings( | 871 browser->window()->ShowWebsiteSettings( |
871 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 872 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
872 web_contents, url, security_info); | 873 web_contents, url, security_info); |
873 } | 874 } |
874 | 875 |
875 void Print(Browser* browser) { | 876 void Print(Browser* browser) { |
876 #if defined(ENABLE_PRINTING) | 877 #if BUILDFLAG(ENABLE_PRINTING) |
877 printing::StartPrint( | 878 printing::StartPrint( |
878 browser->tab_strip_model()->GetActiveWebContents(), | 879 browser->tab_strip_model()->GetActiveWebContents(), |
879 browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled), | 880 browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled), |
880 false); | 881 false); |
881 #endif // defined(ENABLE_PRINTING) | 882 #endif // BUILDFLAG(ENABLE_PRINTING) |
882 } | 883 } |
883 | 884 |
884 bool CanPrint(Browser* browser) { | 885 bool CanPrint(Browser* browser) { |
885 // Do not print when printing is disabled via pref or policy. | 886 // Do not print when printing is disabled via pref or policy. |
886 // Do not print when a page has crashed. | 887 // Do not print when a page has crashed. |
887 // Do not print when a constrained window is showing. It's confusing. | 888 // Do not print when a constrained window is showing. It's confusing. |
888 // TODO(gbillock): Need to re-assess the call to | 889 // TODO(gbillock): Need to re-assess the call to |
889 // IsShowingWebContentsModalDialog after a popup management policy is | 890 // IsShowingWebContentsModalDialog after a popup management policy is |
890 // refined -- we will probably want to just queue the print request, not | 891 // refined -- we will probably want to just queue the print request, not |
891 // block it. | 892 // block it. |
892 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); | 893 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); |
893 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 894 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
894 (current_tab && !current_tab->IsCrashed()) && | 895 (current_tab && !current_tab->IsCrashed()) && |
895 !(IsShowingWebContentsModalDialog(browser) || | 896 !(IsShowingWebContentsModalDialog(browser) || |
896 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); | 897 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); |
897 } | 898 } |
898 | 899 |
899 #if defined(ENABLE_BASIC_PRINTING) | 900 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
900 void BasicPrint(Browser* browser) { | 901 void BasicPrint(Browser* browser) { |
901 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); | 902 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); |
902 } | 903 } |
903 | 904 |
904 bool CanBasicPrint(Browser* browser) { | 905 bool CanBasicPrint(Browser* browser) { |
905 #if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) | 906 #if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
906 // 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 |
907 // advanced print when the print preview is visible. | 908 // advanced print when the print preview is visible. |
908 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 909 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
909 (PrintPreviewShowing(browser) || CanPrint(browser)); | 910 (PrintPreviewShowing(browser) || CanPrint(browser)); |
910 #else | 911 #else |
911 return false; // The print dialog is disabled. | 912 return false; // The print dialog is disabled. |
912 #endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) | 913 #endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
913 } | 914 } |
914 #endif // defined(ENABLE_BASIC_PRINTING) | 915 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
915 | 916 |
916 bool CanRouteMedia(Browser* browser) { | 917 bool CanRouteMedia(Browser* browser) { |
917 // Do not allow user to open Media Router dialog when there is already an | 918 // Do not allow user to open Media Router dialog when there is already an |
918 // active modal dialog. This avoids overlapping dialogs. | 919 // active modal dialog. This avoids overlapping dialogs. |
919 return media_router::MediaRouterEnabled(browser->profile()) && | 920 return media_router::MediaRouterEnabled(browser->profile()) && |
920 !IsShowingWebContentsModalDialog(browser); | 921 !IsShowingWebContentsModalDialog(browser); |
921 } | 922 } |
922 | 923 |
923 void RouteMedia(Browser* browser) { | 924 void RouteMedia(Browser* browser) { |
924 #if defined(ENABLE_MEDIA_ROUTER) | 925 #if defined(ENABLE_MEDIA_ROUTER) |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); | 1298 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
1298 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1299 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1299 | 1300 |
1300 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1301 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1301 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1302 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1302 app_browser->window()->Show(); | 1303 app_browser->window()->Show(); |
1303 } | 1304 } |
1304 #endif // defined(ENABLE_EXTENSIONS) | 1305 #endif // defined(ENABLE_EXTENSIONS) |
1305 | 1306 |
1306 } // namespace chrome | 1307 } // namespace chrome |
OLD | NEW |