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" | |
21 #include "chrome/browser/platform_util.h" | 20 #include "chrome/browser/platform_util.h" |
22 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 21 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
23 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/search/search.h" | 23 #include "chrome/browser/search/search.h" |
25 #include "chrome/browser/sessions/session_service_factory.h" | 24 #include "chrome/browser/sessions/session_service_factory.h" |
26 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 25 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
27 #include "chrome/browser/translate/chrome_translate_client.h" | 26 #include "chrome/browser/translate/chrome_translate_client.h" |
28 #include "chrome/browser/ui/accelerator_utils.h" | 27 #include "chrome/browser/ui/accelerator_utils.h" |
29 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 28 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
30 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" | 29 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 #include "chrome/browser/printing/print_view_manager_common.h" | 103 #include "chrome/browser/printing/print_view_manager_common.h" |
105 #if defined(ENABLE_PRINT_PREVIEW) | 104 #if defined(ENABLE_PRINT_PREVIEW) |
106 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 105 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
107 #endif // defined(ENABLE_PRINT_PREVIEW) | 106 #endif // defined(ENABLE_PRINT_PREVIEW) |
108 #endif // defined(ENABLE_PRINTING) | 107 #endif // defined(ENABLE_PRINTING) |
109 | 108 |
110 #if defined(ENABLE_RLZ) | 109 #if defined(ENABLE_RLZ) |
111 #include "components/rlz/rlz_tracker.h" | 110 #include "components/rlz/rlz_tracker.h" |
112 #endif | 111 #endif |
113 | 112 |
| 113 #if defined(ENABLE_MEDIA_ROUTER) |
| 114 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
| 115 #include "chrome/browser/media/router/media_router_feature.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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 #if defined(OS_WIN) | 913 #if defined(OS_WIN) |
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 |
| 923 #if defined(ENABLE_MEDIA_ROUTER) |
919 bool CanRouteMedia(Browser* browser) { | 924 bool CanRouteMedia(Browser* browser) { |
920 if (!switches::MediaRouterEnabled() || browser->profile()->IsOffTheRecord()) | 925 if (!media_router::MediaRouterEnabled() || |
| 926 browser->profile()->IsOffTheRecord()) { |
921 return false; | 927 return false; |
| 928 } |
922 | 929 |
923 // Do not allow user to open Media Router dialog when there is already an | 930 // Do not allow user to open Media Router dialog when there is already an |
924 // active modal dialog. This avoids overlapping dialogs. | 931 // active modal dialog. This avoids overlapping dialogs. |
925 return !IsShowingWebContentsModalDialog(browser); | 932 return !IsShowingWebContentsModalDialog(browser); |
926 } | 933 } |
927 | 934 |
928 void RouteMedia(Browser* browser) { | 935 void RouteMedia(Browser* browser) { |
929 DCHECK(CanRouteMedia(browser)); | 936 DCHECK(CanRouteMedia(browser)); |
930 | 937 |
931 media_router::MediaRouterDialogController* dialog_controller = | 938 media_router::MediaRouterDialogController* dialog_controller = |
932 media_router::MediaRouterDialogController::GetOrCreateForWebContents( | 939 media_router::MediaRouterDialogController::GetOrCreateForWebContents( |
933 browser->tab_strip_model()->GetActiveWebContents()); | 940 browser->tab_strip_model()->GetActiveWebContents()); |
934 if (!dialog_controller) | 941 if (!dialog_controller) |
935 return; | 942 return; |
936 | 943 |
937 dialog_controller->ShowMediaRouterDialog(); | 944 dialog_controller->ShowMediaRouterDialog(); |
938 } | 945 } |
| 946 #endif // defined(ENABLE_MEDIA_ROUTER) |
939 | 947 |
940 void EmailPageLocation(Browser* browser) { | 948 void EmailPageLocation(Browser* browser) { |
941 content::RecordAction(UserMetricsAction("EmailPageLocation")); | 949 content::RecordAction(UserMetricsAction("EmailPageLocation")); |
942 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); | 950 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); |
943 DCHECK(wc); | 951 DCHECK(wc); |
944 | 952 |
945 std::string title = net::EscapeQueryParamValue( | 953 std::string title = net::EscapeQueryParamValue( |
946 base::UTF16ToUTF8(wc->GetTitle()), false); | 954 base::UTF16ToUTF8(wc->GetTitle()), false); |
947 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); | 955 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); |
948 std::string mailto = std::string("mailto:?subject=Fwd:%20") + | 956 std::string mailto = std::string("mailto:?subject=Fwd:%20") + |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 browser->host_desktop_type())); | 1319 browser->host_desktop_type())); |
1312 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1320 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1313 | 1321 |
1314 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1322 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1315 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1323 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1316 app_browser->window()->Show(); | 1324 app_browser->window()->Show(); |
1317 } | 1325 } |
1318 #endif // defined(ENABLE_EXTENSIONS) | 1326 #endif // defined(ENABLE_EXTENSIONS) |
1319 | 1327 |
1320 } // namespace chrome | 1328 } // namespace chrome |
OLD | NEW |