| 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" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/devtools/devtools_window.h" | 18 #include "chrome/browser/devtools/devtools_window.h" |
| 19 #include "chrome/browser/dom_distiller/tab_utils.h" | 19 #include "chrome/browser/dom_distiller/tab_utils.h" |
| 20 #include "chrome/browser/lifetime/application_lifetime.h" | 20 #include "chrome/browser/lifetime/application_lifetime.h" |
| 21 #include "chrome/browser/media/router/media_router_feature.h" | 21 #include "chrome/browser/media/router/media_router_feature.h" |
| 22 #include "chrome/browser/platform_util.h" | 22 #include "chrome/browser/platform_util.h" |
| 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/search/search.h" | 25 #include "chrome/browser/search/search.h" |
| 26 #include "chrome/browser/sessions/session_service_factory.h" | 26 #include "chrome/browser/sessions/session_service_factory.h" |
| 27 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 27 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 28 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 28 #include "chrome/browser/translate/chrome_translate_client.h" | 29 #include "chrome/browser/translate/chrome_translate_client.h" |
| 29 #include "chrome/browser/ui/accelerator_utils.h" | 30 #include "chrome/browser/ui/accelerator_utils.h" |
| 30 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" | 31 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
| 31 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 32 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 32 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" | 33 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" |
| 33 #include "chrome/browser/ui/browser.h" | 34 #include "chrome/browser/ui/browser.h" |
| 34 #include "chrome/browser/ui/browser_command_controller.h" | 35 #include "chrome/browser/ui/browser_command_controller.h" |
| 35 #include "chrome/browser/ui/browser_dialogs.h" | 36 #include "chrome/browser/ui/browser_dialogs.h" |
| 36 #include "chrome/browser/ui/browser_instant_controller.h" | 37 #include "chrome/browser/ui/browser_instant_controller.h" |
| 37 #include "chrome/browser/ui/browser_live_tab_context.h" | 38 #include "chrome/browser/ui/browser_live_tab_context.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 #include "chrome/browser/upgrade_detector.h" | 56 #include "chrome/browser/upgrade_detector.h" |
| 56 #include "chrome/common/content_restriction.h" | 57 #include "chrome/common/content_restriction.h" |
| 57 #include "chrome/common/features.h" | 58 #include "chrome/common/features.h" |
| 58 #include "chrome/common/pref_names.h" | 59 #include "chrome/common/pref_names.h" |
| 59 #include "components/bookmarks/browser/bookmark_model.h" | 60 #include "components/bookmarks/browser/bookmark_model.h" |
| 60 #include "components/bookmarks/browser/bookmark_utils.h" | 61 #include "components/bookmarks/browser/bookmark_utils.h" |
| 61 #include "components/bookmarks/common/bookmark_pref_names.h" | 62 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 62 #include "components/favicon/content/content_favicon_driver.h" | 63 #include "components/favicon/content/content_favicon_driver.h" |
| 63 #include "components/google/core/browser/google_util.h" | 64 #include "components/google/core/browser/google_util.h" |
| 64 #include "components/prefs/pref_service.h" | 65 #include "components/prefs/pref_service.h" |
| 66 #include "components/security_state/core/security_state.h" |
| 65 #include "components/sessions/core/live_tab_context.h" | 67 #include "components/sessions/core/live_tab_context.h" |
| 66 #include "components/sessions/core/tab_restore_service.h" | 68 #include "components/sessions/core/tab_restore_service.h" |
| 67 #include "components/signin/core/browser/signin_header_helper.h" | 69 #include "components/signin/core/browser/signin_header_helper.h" |
| 68 #include "components/translate/core/browser/language_state.h" | 70 #include "components/translate/core/browser/language_state.h" |
| 69 #include "components/version_info/version_info.h" | 71 #include "components/version_info/version_info.h" |
| 70 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 72 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 71 #include "components/zoom/page_zoom.h" | 73 #include "components/zoom/page_zoom.h" |
| 72 #include "components/zoom/zoom_controller.h" | 74 #include "components/zoom/zoom_controller.h" |
| 73 #include "content/public/browser/devtools_agent_host.h" | 75 #include "content/public/browser/devtools_agent_host.h" |
| 74 #include "content/public/browser/navigation_controller.h" | 76 #include "content/public/browser/navigation_controller.h" |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 return false; | 891 return false; |
| 890 } | 892 } |
| 891 return !browser->is_devtools() && | 893 return !browser->is_devtools() && |
| 892 !(GetContentRestrictions(browser) & CONTENT_RESTRICTION_SAVE); | 894 !(GetContentRestrictions(browser) & CONTENT_RESTRICTION_SAVE); |
| 893 } | 895 } |
| 894 | 896 |
| 895 void ShowFindBar(Browser* browser) { | 897 void ShowFindBar(Browser* browser) { |
| 896 browser->GetFindBarController()->Show(); | 898 browser->GetFindBarController()->Show(); |
| 897 } | 899 } |
| 898 | 900 |
| 899 void ShowWebsiteSettings(Browser* browser, | 901 bool ShowWebsiteSettings(Browser* browser, content::WebContents* web_contents) { |
| 900 content::WebContents* web_contents, | 902 content::NavigationEntry* entry = |
| 901 const GURL& url, | 903 web_contents->GetController().GetVisibleEntry(); |
| 902 const security_state::SecurityInfo& security_info) { | 904 if (!entry) |
| 905 return false; |
| 906 |
| 907 SecurityStateTabHelper* helper = |
| 908 SecurityStateTabHelper::FromWebContents(web_contents); |
| 909 security_state::SecurityInfo security_info; |
| 910 helper->GetSecurityInfo(&security_info); |
| 911 |
| 903 browser->window()->ShowWebsiteSettings( | 912 browser->window()->ShowWebsiteSettings( |
| 904 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 913 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
| 905 web_contents, url, security_info); | 914 web_contents, entry->GetVirtualURL(), security_info); |
| 915 return true; |
| 906 } | 916 } |
| 907 | 917 |
| 908 void Print(Browser* browser) { | 918 void Print(Browser* browser) { |
| 909 #if BUILDFLAG(ENABLE_PRINTING) | 919 #if BUILDFLAG(ENABLE_PRINTING) |
| 910 auto* web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 920 auto* web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
| 911 printing::StartPrint(web_contents, browser->profile()->GetPrefs()->GetBoolean( | 921 printing::StartPrint(web_contents, browser->profile()->GetPrefs()->GetBoolean( |
| 912 prefs::kPrintPreviewDisabled), | 922 prefs::kPrintPreviewDisabled), |
| 913 false /* has_selection? */); | 923 false /* has_selection? */); |
| 914 #endif | 924 #endif |
| 915 } | 925 } |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); | 1341 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
| 1332 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1342 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1333 | 1343 |
| 1334 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1344 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1335 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1345 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1336 app_browser->window()->Show(); | 1346 app_browser->window()->Show(); |
| 1337 } | 1347 } |
| 1338 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 1348 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 1339 | 1349 |
| 1340 } // namespace chrome | 1350 } // namespace chrome |
| OLD | NEW |