OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "chrome/browser/google/google_url_tracker.h" | 58 #include "chrome/browser/google/google_url_tracker.h" |
59 #include "chrome/browser/google/google_util.h" | 59 #include "chrome/browser/google/google_util.h" |
60 #include "chrome/browser/infobars/infobar_tab_helper.h" | 60 #include "chrome/browser/infobars/infobar_tab_helper.h" |
61 #include "chrome/browser/instant/instant_controller.h" | 61 #include "chrome/browser/instant/instant_controller.h" |
62 #include "chrome/browser/instant/instant_unload_handler.h" | 62 #include "chrome/browser/instant/instant_unload_handler.h" |
63 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 63 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
64 #include "chrome/browser/intents/web_intents_registry_factory.h" | 64 #include "chrome/browser/intents/web_intents_registry_factory.h" |
65 #include "chrome/browser/net/browser_url_util.h" | 65 #include "chrome/browser/net/browser_url_util.h" |
66 #include "chrome/browser/net/url_fixer_upper.h" | 66 #include "chrome/browser/net/url_fixer_upper.h" |
67 #include "chrome/browser/notifications/notification_ui_manager.h" | 67 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 68 #include "chrome/browser/page_zoom.h" |
68 #include "chrome/browser/platform_util.h" | 69 #include "chrome/browser/platform_util.h" |
69 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 70 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
70 #include "chrome/browser/prefs/pref_service.h" | 71 #include "chrome/browser/prefs/pref_service.h" |
71 #include "chrome/browser/prerender/prerender_tab_helper.h" | 72 #include "chrome/browser/prerender/prerender_tab_helper.h" |
72 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 73 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
73 #include "chrome/browser/printing/print_preview_tab_controller.h" | 74 #include "chrome/browser/printing/print_preview_tab_controller.h" |
74 #include "chrome/browser/printing/print_view_manager.h" | 75 #include "chrome/browser/printing/print_view_manager.h" |
75 #include "chrome/browser/profiles/profile.h" | 76 #include "chrome/browser/profiles/profile.h" |
76 #include "chrome/browser/profiles/profile_manager.h" | 77 #include "chrome/browser/profiles/profile_manager.h" |
77 #include "chrome/browser/sessions/restore_tab_helper.h" | 78 #include "chrome/browser/sessions/restore_tab_helper.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 #include "content/browser/site_instance.h" | 146 #include "content/browser/site_instance.h" |
146 #include "content/browser/tab_contents/interstitial_page.h" | 147 #include "content/browser/tab_contents/interstitial_page.h" |
147 #include "content/browser/tab_contents/navigation_controller.h" | 148 #include "content/browser/tab_contents/navigation_controller.h" |
148 #include "content/browser/tab_contents/navigation_entry.h" | 149 #include "content/browser/tab_contents/navigation_entry.h" |
149 #include "content/browser/tab_contents/tab_contents_view.h" | 150 #include "content/browser/tab_contents/tab_contents_view.h" |
150 #include "content/browser/user_metrics.h" | 151 #include "content/browser/user_metrics.h" |
151 #include "content/public/browser/notification_service.h" | 152 #include "content/public/browser/notification_service.h" |
152 #include "content/public/browser/notification_details.h" | 153 #include "content/public/browser/notification_details.h" |
153 #include "content/public/common/content_restriction.h" | 154 #include "content/public/common/content_restriction.h" |
154 #include "content/public/common/content_switches.h" | 155 #include "content/public/common/content_switches.h" |
| 156 #include "content/public/common/page_zoom.h" |
155 #include "grit/chromium_strings.h" | 157 #include "grit/chromium_strings.h" |
156 #include "grit/generated_resources.h" | 158 #include "grit/generated_resources.h" |
157 #include "grit/locale_settings.h" | 159 #include "grit/locale_settings.h" |
158 #include "grit/theme_resources_standard.h" | 160 #include "grit/theme_resources_standard.h" |
159 #include "net/base/cookie_monster.h" | 161 #include "net/base/cookie_monster.h" |
160 #include "net/base/net_util.h" | 162 #include "net/base/net_util.h" |
161 #include "net/base/registry_controlled_domain.h" | 163 #include "net/base/registry_controlled_domain.h" |
162 #include "net/url_request/url_request_context.h" | 164 #include "net/url_request/url_request_context.h" |
163 #include "ui/base/animation/animation.h" | 165 #include "ui/base/animation/animation.h" |
164 #include "ui/base/l10n/l10n_util.h" | 166 #include "ui/base/l10n/l10n_util.h" |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 | 1895 |
1894 void Browser::FindPrevious() { | 1896 void Browser::FindPrevious() { |
1895 UserMetrics::RecordAction(UserMetricsAction("FindPrevious")); | 1897 UserMetrics::RecordAction(UserMetricsAction("FindPrevious")); |
1896 FindInPage(true, false); | 1898 FindInPage(true, false); |
1897 } | 1899 } |
1898 | 1900 |
1899 void Browser::Zoom(content::PageZoom zoom) { | 1901 void Browser::Zoom(content::PageZoom zoom) { |
1900 if (is_devtools()) | 1902 if (is_devtools()) |
1901 return; | 1903 return; |
1902 | 1904 |
1903 static const UserMetricsAction kActions[] = { | 1905 RenderViewHost* host = GetSelectedTabContentsWrapper()->render_view_host(); |
1904 UserMetricsAction("ZoomMinus"), | 1906 if (zoom == content::PAGE_ZOOM_RESET) { |
1905 UserMetricsAction("ZoomNormal"), | 1907 host->SetZoomLevel(0); |
1906 UserMetricsAction("ZoomPlus") | 1908 UserMetrics::RecordAction(UserMetricsAction("ZoomNormal")); |
1907 }; | 1909 return; |
| 1910 } |
1908 | 1911 |
1909 UserMetrics::RecordAction(kActions[zoom - content::PAGE_ZOOM_OUT]); | 1912 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel(); |
1910 TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper(); | 1913 double default_zoom_level = |
1911 RenderViewHost* host = tab_contents->render_view_host(); | 1914 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); |
1912 host->Zoom(zoom); | 1915 |
| 1916 // Generate a vector of zoom levels from an array of known presets along with |
| 1917 // the default level added if necessary. |
| 1918 std::vector<double> zoom_levels = |
| 1919 page_zoom::PresetZoomLevels(default_zoom_level); |
| 1920 |
| 1921 if (zoom == content::PAGE_ZOOM_OUT) { |
| 1922 // Iterate through the zoom levels in reverse order to find the next |
| 1923 // lower level based on the current zoom level for this page. |
| 1924 for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin(); |
| 1925 i != zoom_levels.rend(); ++i) { |
| 1926 double zoom_level = *i; |
| 1927 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) |
| 1928 continue; |
| 1929 if (zoom_level < current_zoom_level) { |
| 1930 host->SetZoomLevel(zoom_level); |
| 1931 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus")); |
| 1932 return; |
| 1933 } |
| 1934 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum")); |
| 1935 } |
| 1936 } else { |
| 1937 // Iterate through the zoom levels in normal order to find the next |
| 1938 // higher level based on the current zoom level for this page. |
| 1939 for (std::vector<double>::const_iterator i = zoom_levels.begin(); |
| 1940 i != zoom_levels.end(); ++i) { |
| 1941 double zoom_level = *i; |
| 1942 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) |
| 1943 continue; |
| 1944 if (zoom_level > current_zoom_level) { |
| 1945 host->SetZoomLevel(zoom_level); |
| 1946 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus")); |
| 1947 return; |
| 1948 } |
| 1949 } |
| 1950 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); |
| 1951 } |
1913 } | 1952 } |
1914 | 1953 |
1915 void Browser::FocusToolbar() { | 1954 void Browser::FocusToolbar() { |
1916 UserMetrics::RecordAction(UserMetricsAction("FocusToolbar")); | 1955 UserMetrics::RecordAction(UserMetricsAction("FocusToolbar")); |
1917 window_->FocusToolbar(); | 1956 window_->FocusToolbar(); |
1918 } | 1957 } |
1919 | 1958 |
1920 void Browser::FocusAppMenu() { | 1959 void Browser::FocusAppMenu() { |
1921 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu")); | 1960 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu")); |
1922 window_->FocusAppMenu(); | 1961 window_->FocusAppMenu(); |
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5272 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5311 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
5273 } else if (is_type_tabbed()) { | 5312 } else if (is_type_tabbed()) { |
5274 GlobalErrorService* service = | 5313 GlobalErrorService* service = |
5275 GlobalErrorServiceFactory::GetForProfile(profile()); | 5314 GlobalErrorServiceFactory::GetForProfile(profile()); |
5276 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5315 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
5277 if (error) { | 5316 if (error) { |
5278 error->ShowBubbleView(this); | 5317 error->ShowBubbleView(this); |
5279 } | 5318 } |
5280 } | 5319 } |
5281 } | 5320 } |
OLD | NEW |