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.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.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/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/devtools/devtools_window.h" | 17 #include "chrome/browser/devtools/devtools_window.h" |
18 #include "chrome/browser/dom_distiller/tab_utils.h" | 18 #include "chrome/browser/dom_distiller/tab_utils.h" |
19 #include "chrome/browser/lifetime/application_lifetime.h" | 19 #include "chrome/browser/lifetime/application_lifetime.h" |
20 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 20 #include "chrome/browser/media/router/media_router_feature.h" |
21 #include "chrome/browser/platform_util.h" | 21 #include "chrome/browser/platform_util.h" |
22 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 22 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/search/search.h" | 24 #include "chrome/browser/search/search.h" |
25 #include "chrome/browser/sessions/session_service_factory.h" | 25 #include "chrome/browser/sessions/session_service_factory.h" |
26 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 26 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
27 #include "chrome/browser/translate/chrome_translate_client.h" | 27 #include "chrome/browser/translate/chrome_translate_client.h" |
28 #include "chrome/browser/ui/accelerator_utils.h" | 28 #include "chrome/browser/ui/accelerator_utils.h" |
29 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 29 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
30 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" | 30 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
43 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 43 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
44 #include "chrome/browser/ui/location_bar/location_bar.h" | 44 #include "chrome/browser/ui/location_bar/location_bar.h" |
45 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 45 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
46 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 46 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
47 #include "chrome/browser/ui/search/search_tab_helper.h" | 47 #include "chrome/browser/ui/search/search_tab_helper.h" |
48 #include "chrome/browser/ui/status_bubble.h" | 48 #include "chrome/browser/ui/status_bubble.h" |
49 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 49 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
50 #include "chrome/browser/ui/tab_dialogs.h" | 50 #include "chrome/browser/ui/tab_dialogs.h" |
51 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 51 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
52 #include "chrome/browser/upgrade_detector.h" | 52 #include "chrome/browser/upgrade_detector.h" |
53 #include "chrome/common/chrome_switches.h" | 53 #include "chrome/common/chrome_switches.h" |
msw
2015/10/29 18:41:13
nit: remove?
imcheng
2015/10/29 21:44:56
Done.
| |
54 #include "chrome/common/content_restriction.h" | 54 #include "chrome/common/content_restriction.h" |
55 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
56 #include "components/bookmarks/browser/bookmark_model.h" | 56 #include "components/bookmarks/browser/bookmark_model.h" |
57 #include "components/bookmarks/browser/bookmark_utils.h" | 57 #include "components/bookmarks/browser/bookmark_utils.h" |
58 #include "components/bookmarks/common/bookmark_pref_names.h" | 58 #include "components/bookmarks/common/bookmark_pref_names.h" |
59 #include "components/favicon/content/content_favicon_driver.h" | 59 #include "components/favicon/content/content_favicon_driver.h" |
60 #include "components/google/core/browser/google_util.h" | 60 #include "components/google/core/browser/google_util.h" |
61 #include "components/sessions/core/live_tab_context.h" | 61 #include "components/sessions/core/live_tab_context.h" |
62 #include "components/sessions/core/tab_restore_service.h" | 62 #include "components/sessions/core/tab_restore_service.h" |
63 #include "components/signin/core/browser/signin_header_helper.h" | 63 #include "components/signin/core/browser/signin_header_helper.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 #include "chrome/browser/printing/print_view_manager_common.h" | 104 #include "chrome/browser/printing/print_view_manager_common.h" |
105 #if defined(ENABLE_PRINT_PREVIEW) | 105 #if defined(ENABLE_PRINT_PREVIEW) |
106 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 106 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
107 #endif // defined(ENABLE_PRINT_PREVIEW) | 107 #endif // defined(ENABLE_PRINT_PREVIEW) |
108 #endif // defined(ENABLE_PRINTING) | 108 #endif // defined(ENABLE_PRINTING) |
109 | 109 |
110 #if defined(ENABLE_RLZ) | 110 #if defined(ENABLE_RLZ) |
111 #include "components/rlz/rlz_tracker.h" | 111 #include "components/rlz/rlz_tracker.h" |
112 #endif | 112 #endif |
113 | 113 |
114 #if defined(ENABLE_MEDIA_ROUTER) | |
115 #include "chrome/browser/media/router/media_router_dialog_controller.h" | |
116 #endif | |
117 | |
114 namespace { | 118 namespace { |
115 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; | 119 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; |
116 } | 120 } |
117 | 121 |
118 using base::UserMetricsAction; | 122 using base::UserMetricsAction; |
119 using bookmarks::BookmarkModel; | 123 using bookmarks::BookmarkModel; |
120 using content::NavigationController; | 124 using content::NavigationController; |
121 using content::NavigationEntry; | 125 using content::NavigationEntry; |
122 using content::OpenURLParams; | 126 using content::OpenURLParams; |
123 using content::Referrer; | 127 using content::Referrer; |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
910 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) | 914 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) |
911 return false; | 915 return false; |
912 #endif | 916 #endif |
913 | 917 |
914 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 918 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
915 (PrintPreviewShowing(browser) || CanPrint(browser)); | 919 (PrintPreviewShowing(browser) || CanPrint(browser)); |
916 } | 920 } |
917 #endif // ENABLE_BASIC_PRINTING | 921 #endif // ENABLE_BASIC_PRINTING |
918 | 922 |
919 bool CanRouteMedia(Browser* browser) { | 923 bool CanRouteMedia(Browser* browser) { |
920 if (!switches::MediaRouterEnabled() || browser->profile()->IsOffTheRecord()) | 924 if (!media_router::MediaRouterEnabled() || |
925 browser->profile()->IsOffTheRecord()) | |
921 return false; | 926 return false; |
922 | 927 |
923 // Do not allow user to open Media Router dialog when there is already an | 928 // Do not allow user to open Media Router dialog when there is already an |
924 // active modal dialog. This avoids overlapping dialogs. | 929 // active modal dialog. This avoids overlapping dialogs. |
925 return !IsShowingWebContentsModalDialog(browser); | 930 return !IsShowingWebContentsModalDialog(browser); |
926 } | 931 } |
927 | 932 |
928 void RouteMedia(Browser* browser) { | 933 void RouteMedia(Browser* browser) { |
934 #if defined(ENABLE_MEDIA_ROUTER) | |
929 DCHECK(CanRouteMedia(browser)); | 935 DCHECK(CanRouteMedia(browser)); |
930 | 936 |
931 media_router::MediaRouterDialogController* dialog_controller = | 937 media_router::MediaRouterDialogController* dialog_controller = |
932 media_router::MediaRouterDialogController::GetOrCreateForWebContents( | 938 media_router::MediaRouterDialogController::GetOrCreateForWebContents( |
933 browser->tab_strip_model()->GetActiveWebContents()); | 939 browser->tab_strip_model()->GetActiveWebContents()); |
934 if (!dialog_controller) | 940 if (!dialog_controller) |
935 return; | 941 return; |
936 | 942 |
937 dialog_controller->ShowMediaRouterDialog(); | 943 dialog_controller->ShowMediaRouterDialog(); |
944 #endif // defined(ENABLE_MEDIA_ROUTER) | |
938 } | 945 } |
939 | 946 |
940 void EmailPageLocation(Browser* browser) { | 947 void EmailPageLocation(Browser* browser) { |
941 content::RecordAction(UserMetricsAction("EmailPageLocation")); | 948 content::RecordAction(UserMetricsAction("EmailPageLocation")); |
942 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); | 949 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); |
943 DCHECK(wc); | 950 DCHECK(wc); |
944 | 951 |
945 std::string title = net::EscapeQueryParamValue( | 952 std::string title = net::EscapeQueryParamValue( |
946 base::UTF16ToUTF8(wc->GetTitle()), false); | 953 base::UTF16ToUTF8(wc->GetTitle()), false); |
947 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); | 954 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1311 browser->host_desktop_type())); | 1318 browser->host_desktop_type())); |
1312 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1319 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1313 | 1320 |
1314 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1321 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1315 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1322 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1316 app_browser->window()->Show(); | 1323 app_browser->window()->Show(); |
1317 } | 1324 } |
1318 #endif // defined(ENABLE_EXTENSIONS) | 1325 #endif // defined(ENABLE_EXTENSIONS) |
1319 | 1326 |
1320 } // namespace chrome | 1327 } // namespace chrome |
OLD | NEW |