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/autofill/save_card_bubble_controller_impl.h" | 29 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
30 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 30 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
(...skipping 13 matching lines...) Expand all Loading... |
44 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 44 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
45 #include "chrome/browser/ui/location_bar/location_bar.h" | 45 #include "chrome/browser/ui/location_bar/location_bar.h" |
46 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 46 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
47 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 47 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
48 #include "chrome/browser/ui/search/search_tab_helper.h" | 48 #include "chrome/browser/ui/search/search_tab_helper.h" |
49 #include "chrome/browser/ui/status_bubble.h" | 49 #include "chrome/browser/ui/status_bubble.h" |
50 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 50 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
51 #include "chrome/browser/ui/tab_dialogs.h" | 51 #include "chrome/browser/ui/tab_dialogs.h" |
52 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 52 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
53 #include "chrome/browser/upgrade_detector.h" | 53 #include "chrome/browser/upgrade_detector.h" |
54 #include "chrome/common/chrome_switches.h" | |
55 #include "chrome/common/content_restriction.h" | 54 #include "chrome/common/content_restriction.h" |
56 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
57 #include "components/bookmarks/browser/bookmark_model.h" | 56 #include "components/bookmarks/browser/bookmark_model.h" |
58 #include "components/bookmarks/browser/bookmark_utils.h" | 57 #include "components/bookmarks/browser/bookmark_utils.h" |
59 #include "components/bookmarks/common/bookmark_pref_names.h" | 58 #include "components/bookmarks/common/bookmark_pref_names.h" |
60 #include "components/favicon/content/content_favicon_driver.h" | 59 #include "components/favicon/content/content_favicon_driver.h" |
61 #include "components/google/core/browser/google_util.h" | 60 #include "components/google/core/browser/google_util.h" |
62 #include "components/sessions/core/live_tab_context.h" | 61 #include "components/sessions/core/live_tab_context.h" |
63 #include "components/sessions/core/tab_restore_service.h" | 62 #include "components/sessions/core/tab_restore_service.h" |
64 #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... |
105 #include "chrome/browser/printing/print_view_manager_common.h" | 104 #include "chrome/browser/printing/print_view_manager_common.h" |
106 #if defined(ENABLE_PRINT_PREVIEW) | 105 #if defined(ENABLE_PRINT_PREVIEW) |
107 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 106 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
108 #endif // defined(ENABLE_PRINT_PREVIEW) | 107 #endif // defined(ENABLE_PRINT_PREVIEW) |
109 #endif // defined(ENABLE_PRINTING) | 108 #endif // defined(ENABLE_PRINTING) |
110 | 109 |
111 #if defined(ENABLE_RLZ) | 110 #if defined(ENABLE_RLZ) |
112 #include "components/rlz/rlz_tracker.h" | 111 #include "components/rlz/rlz_tracker.h" |
113 #endif | 112 #endif |
114 | 113 |
| 114 #if defined(ENABLE_MEDIA_ROUTER) |
| 115 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
| 116 #endif |
| 117 |
115 namespace { | 118 namespace { |
116 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; | 119 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; |
117 } | 120 } |
118 | 121 |
119 using base::UserMetricsAction; | 122 using base::UserMetricsAction; |
120 using bookmarks::BookmarkModel; | 123 using bookmarks::BookmarkModel; |
121 using content::NavigationController; | 124 using content::NavigationController; |
122 using content::NavigationEntry; | 125 using content::NavigationEntry; |
123 using content::OpenURLParams; | 126 using content::OpenURLParams; |
124 using content::Referrer; | 127 using content::Referrer; |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) | 925 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) |
923 return false; | 926 return false; |
924 #endif | 927 #endif |
925 | 928 |
926 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 929 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
927 (PrintPreviewShowing(browser) || CanPrint(browser)); | 930 (PrintPreviewShowing(browser) || CanPrint(browser)); |
928 } | 931 } |
929 #endif // ENABLE_BASIC_PRINTING | 932 #endif // ENABLE_BASIC_PRINTING |
930 | 933 |
931 bool CanRouteMedia(Browser* browser) { | 934 bool CanRouteMedia(Browser* browser) { |
932 if (!switches::MediaRouterEnabled() || browser->profile()->IsOffTheRecord()) | 935 if (!media_router::MediaRouterEnabled() || |
| 936 browser->profile()->IsOffTheRecord()) |
933 return false; | 937 return false; |
934 | 938 |
935 // Do not allow user to open Media Router dialog when there is already an | 939 // Do not allow user to open Media Router dialog when there is already an |
936 // active modal dialog. This avoids overlapping dialogs. | 940 // active modal dialog. This avoids overlapping dialogs. |
937 return !IsShowingWebContentsModalDialog(browser); | 941 return !IsShowingWebContentsModalDialog(browser); |
938 } | 942 } |
939 | 943 |
940 void RouteMedia(Browser* browser) { | 944 void RouteMedia(Browser* browser) { |
| 945 #if defined(ENABLE_MEDIA_ROUTER) |
941 DCHECK(CanRouteMedia(browser)); | 946 DCHECK(CanRouteMedia(browser)); |
942 | 947 |
943 media_router::MediaRouterDialogController* dialog_controller = | 948 media_router::MediaRouterDialogController* dialog_controller = |
944 media_router::MediaRouterDialogController::GetOrCreateForWebContents( | 949 media_router::MediaRouterDialogController::GetOrCreateForWebContents( |
945 browser->tab_strip_model()->GetActiveWebContents()); | 950 browser->tab_strip_model()->GetActiveWebContents()); |
946 if (!dialog_controller) | 951 if (!dialog_controller) |
947 return; | 952 return; |
948 | 953 |
949 dialog_controller->ShowMediaRouterDialog(); | 954 dialog_controller->ShowMediaRouterDialog(); |
| 955 #endif // defined(ENABLE_MEDIA_ROUTER) |
950 } | 956 } |
951 | 957 |
952 void EmailPageLocation(Browser* browser) { | 958 void EmailPageLocation(Browser* browser) { |
953 content::RecordAction(UserMetricsAction("EmailPageLocation")); | 959 content::RecordAction(UserMetricsAction("EmailPageLocation")); |
954 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); | 960 WebContents* wc = browser->tab_strip_model()->GetActiveWebContents(); |
955 DCHECK(wc); | 961 DCHECK(wc); |
956 | 962 |
957 std::string title = net::EscapeQueryParamValue( | 963 std::string title = net::EscapeQueryParamValue( |
958 base::UTF16ToUTF8(wc->GetTitle()), false); | 964 base::UTF16ToUTF8(wc->GetTitle()), false); |
959 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); | 965 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 browser->host_desktop_type())); | 1329 browser->host_desktop_type())); |
1324 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1330 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1325 | 1331 |
1326 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1332 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1327 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1333 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1328 app_browser->window()->Show(); | 1334 app_browser->window()->Show(); |
1329 } | 1335 } |
1330 #endif // defined(ENABLE_EXTENSIONS) | 1336 #endif // defined(ENABLE_EXTENSIONS) |
1331 | 1337 |
1332 } // namespace chrome | 1338 } // namespace chrome |
OLD | NEW |