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 "content/browser/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 is_being_destroyed_(false), | 190 is_being_destroyed_(false), |
191 notify_disconnection_(false), | 191 notify_disconnection_(false), |
192 dialog_creator_(NULL), | 192 dialog_creator_(NULL), |
193 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
194 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 194 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
195 #endif | 195 #endif |
196 is_showing_before_unload_dialog_(false), | 196 is_showing_before_unload_dialog_(false), |
197 opener_web_ui_type_(WebUI::kNoWebUI), | 197 opener_web_ui_type_(WebUI::kNoWebUI), |
198 closed_by_user_gesture_(false), | 198 closed_by_user_gesture_(false), |
199 minimum_zoom_percent_( | 199 minimum_zoom_percent_( |
200 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), | 200 static_cast<int>(content::kMinimumZoomFactor * 100)), |
201 maximum_zoom_percent_( | 201 maximum_zoom_percent_( |
202 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), | 202 static_cast<int>(content::kMaximumZoomFactor * 100)), |
203 temporary_zoom_settings_(false), | 203 temporary_zoom_settings_(false), |
204 content_restrictions_(0), | 204 content_restrictions_(0), |
205 view_type_(content::VIEW_TYPE_TAB_CONTENTS) { | 205 view_type_(content::VIEW_TYPE_TAB_CONTENTS) { |
206 render_manager_.Init(browser_context, site_instance, routing_id); | 206 render_manager_.Init(browser_context, site_instance, routing_id); |
207 | 207 |
208 // We have the initial size of the view be based on the size of the passed in | 208 // We have the initial size of the view be based on the size of the passed in |
209 // tab contents (normally a tab from the same window). | 209 // tab contents (normally a tab from the same window). |
210 view_->CreateView(base_tab_contents ? | 210 view_->CreateView(base_tab_contents ? |
211 base_tab_contents->view()->GetContainerSize() : gfx::Size()); | 211 base_tab_contents->view()->GetContainerSize() : gfx::Size()); |
212 | 212 |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 // to get the zoom level. | 854 // to get the zoom level. |
855 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); | 855 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); |
856 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); | 856 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); |
857 } | 857 } |
858 return zoom_level; | 858 return zoom_level; |
859 } | 859 } |
860 | 860 |
861 int TabContents::GetZoomPercent(bool* enable_increment, | 861 int TabContents::GetZoomPercent(bool* enable_increment, |
862 bool* enable_decrement) { | 862 bool* enable_decrement) { |
863 *enable_decrement = *enable_increment = false; | 863 *enable_decrement = *enable_increment = false; |
| 864 // Calculate the zoom percent from the factor. Round up to the nearest whole |
| 865 // number. |
864 int percent = static_cast<int>( | 866 int percent = static_cast<int>( |
865 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100); | 867 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100 + 0.5); |
866 *enable_decrement = percent > minimum_zoom_percent_; | 868 *enable_decrement = percent > minimum_zoom_percent_; |
867 *enable_increment = percent < maximum_zoom_percent_; | 869 *enable_increment = percent < maximum_zoom_percent_; |
868 return percent; | 870 return percent; |
869 } | 871 } |
870 | 872 |
871 void TabContents::ViewSource() { | 873 void TabContents::ViewSource() { |
872 if (!delegate_) | 874 if (!delegate_) |
873 return; | 875 return; |
874 | 876 |
875 NavigationEntry* active_entry = controller().GetActiveEntry(); | 877 NavigationEntry* active_entry = controller().GetActiveEntry(); |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 | 2029 |
2028 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2030 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2029 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2031 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2030 rwh_view->SetSize(view()->GetContainerSize()); | 2032 rwh_view->SetSize(view()->GetContainerSize()); |
2031 } | 2033 } |
2032 | 2034 |
2033 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2035 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
2034 return render_view_host() ? | 2036 return render_view_host() ? |
2035 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2037 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
2036 } | 2038 } |
OLD | NEW |