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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "chrome/browser/ui/location_bar/location_bar.h" | 46 #include "chrome/browser/ui/location_bar/location_bar.h" |
47 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 47 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
48 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 48 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
49 #include "chrome/browser/ui/search/search_tab_helper.h" | 49 #include "chrome/browser/ui/search/search_tab_helper.h" |
50 #include "chrome/browser/ui/status_bubble.h" | 50 #include "chrome/browser/ui/status_bubble.h" |
51 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 51 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
52 #include "chrome/browser/ui/tab_dialogs.h" | 52 #include "chrome/browser/ui/tab_dialogs.h" |
53 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 53 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
54 #include "chrome/browser/upgrade_detector.h" | 54 #include "chrome/browser/upgrade_detector.h" |
55 #include "chrome/common/content_restriction.h" | 55 #include "chrome/common/content_restriction.h" |
| 56 #include "chrome/common/features.h" |
56 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
57 #include "components/bookmarks/browser/bookmark_model.h" | 58 #include "components/bookmarks/browser/bookmark_model.h" |
58 #include "components/bookmarks/browser/bookmark_utils.h" | 59 #include "components/bookmarks/browser/bookmark_utils.h" |
59 #include "components/bookmarks/common/bookmark_pref_names.h" | 60 #include "components/bookmarks/common/bookmark_pref_names.h" |
60 #include "components/favicon/content/content_favicon_driver.h" | 61 #include "components/favicon/content/content_favicon_driver.h" |
61 #include "components/google/core/browser/google_util.h" | 62 #include "components/google/core/browser/google_util.h" |
62 #include "components/prefs/pref_service.h" | 63 #include "components/prefs/pref_service.h" |
63 #include "components/sessions/core/live_tab_context.h" | 64 #include "components/sessions/core/live_tab_context.h" |
64 #include "components/sessions/core/tab_restore_service.h" | 65 #include "components/sessions/core/tab_restore_service.h" |
65 #include "components/signin/core/browser/signin_header_helper.h" | 66 #include "components/signin/core/browser/signin_header_helper.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 246 |
246 // TODO(gbillock): This is currently called in production by the CanPrint | 247 // 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. | 248 // 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 | 249 // Re-assess how to queue print preview after we know more about popup |
249 // management policy. | 250 // management policy. |
250 const web_modal::WebContentsModalDialogManager* manager = | 251 const web_modal::WebContentsModalDialogManager* manager = |
251 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); | 252 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
252 return manager && manager->IsDialogActive(); | 253 return manager && manager->IsDialogActive(); |
253 } | 254 } |
254 | 255 |
255 #if defined(ENABLE_BASIC_PRINTING) | 256 #if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
256 bool PrintPreviewShowing(const Browser* browser) { | 257 bool PrintPreviewShowing(const Browser* browser) { |
257 #if defined(ENABLE_PRINT_PREVIEW) | 258 #if defined(ENABLE_PRINT_PREVIEW) |
258 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); | 259 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); |
259 printing::PrintPreviewDialogController* controller = | 260 printing::PrintPreviewDialogController* controller = |
260 printing::PrintPreviewDialogController::GetInstance(); | 261 printing::PrintPreviewDialogController::GetInstance(); |
261 return controller && (controller->GetPrintPreviewForContents(contents) || | 262 return controller && (controller->GetPrintPreviewForContents(contents) || |
262 controller->is_creating_print_preview_dialog()); | 263 controller->is_creating_print_preview_dialog()); |
263 #else | 264 #else |
264 return false; | 265 return false; |
265 #endif | 266 #endif |
266 } | 267 } |
267 #endif // ENABLE_BASIC_PRINTING | 268 #endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
268 | 269 |
269 } // namespace | 270 } // namespace |
270 | 271 |
271 bool IsCommandEnabled(Browser* browser, int command) { | 272 bool IsCommandEnabled(Browser* browser, int command) { |
272 return browser->command_controller()->command_updater()->IsCommandEnabled( | 273 return browser->command_controller()->command_updater()->IsCommandEnabled( |
273 command); | 274 command); |
274 } | 275 } |
275 | 276 |
276 bool SupportsCommand(Browser* browser, int command) { | 277 bool SupportsCommand(Browser* browser, int command) { |
277 return browser->command_controller()->command_updater()->SupportsCommand( | 278 return browser->command_controller()->command_updater()->SupportsCommand( |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 !(IsShowingWebContentsModalDialog(browser) || | 895 !(IsShowingWebContentsModalDialog(browser) || |
895 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); | 896 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); |
896 } | 897 } |
897 | 898 |
898 #if defined(ENABLE_BASIC_PRINTING) | 899 #if defined(ENABLE_BASIC_PRINTING) |
899 void BasicPrint(Browser* browser) { | 900 void BasicPrint(Browser* browser) { |
900 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); | 901 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); |
901 } | 902 } |
902 | 903 |
903 bool CanBasicPrint(Browser* browser) { | 904 bool CanBasicPrint(Browser* browser) { |
| 905 #if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
904 // If printing is not disabled via pref or policy, it is always possible to | 906 // If printing is not disabled via pref or policy, it is always possible to |
905 // advanced print when the print preview is visible. | 907 // advanced print when the print preview is visible. |
906 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 908 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
907 (PrintPreviewShowing(browser) || CanPrint(browser)); | 909 (PrintPreviewShowing(browser) || CanPrint(browser)); |
| 910 #else |
| 911 return false; // The print dialog is disabled. |
| 912 #endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG) |
908 } | 913 } |
909 #endif // ENABLE_BASIC_PRINTING | 914 #endif // defined(ENABLE_BASIC_PRINTING) |
910 | 915 |
911 bool CanRouteMedia(Browser* browser) { | 916 bool CanRouteMedia(Browser* browser) { |
912 // Do not allow user to open Media Router dialog when there is already an | 917 // Do not allow user to open Media Router dialog when there is already an |
913 // active modal dialog. This avoids overlapping dialogs. | 918 // active modal dialog. This avoids overlapping dialogs. |
914 return media_router::MediaRouterEnabled(browser->profile()) && | 919 return media_router::MediaRouterEnabled(browser->profile()) && |
915 !IsShowingWebContentsModalDialog(browser); | 920 !IsShowingWebContentsModalDialog(browser); |
916 } | 921 } |
917 | 922 |
918 void RouteMedia(Browser* browser) { | 923 void RouteMedia(Browser* browser) { |
919 #if defined(ENABLE_MEDIA_ROUTER) | 924 #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())); | 1297 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
1293 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1298 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1294 | 1299 |
1295 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1300 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1296 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1301 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1297 app_browser->window()->Show(); | 1302 app_browser->window()->Show(); |
1298 } | 1303 } |
1299 #endif // defined(ENABLE_EXTENSIONS) | 1304 #endif // defined(ENABLE_EXTENSIONS) |
1300 | 1305 |
1301 } // namespace chrome | 1306 } // namespace chrome |
OLD | NEW |