| 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 // to get the zoom level. | 855 // to get the zoom level. |
| 856 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); | 856 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); |
| 857 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); | 857 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); |
| 858 } | 858 } |
| 859 return zoom_level; | 859 return zoom_level; |
| 860 } | 860 } |
| 861 | 861 |
| 862 int TabContents::GetZoomPercent(bool* enable_increment, | 862 int TabContents::GetZoomPercent(bool* enable_increment, |
| 863 bool* enable_decrement) { | 863 bool* enable_decrement) { |
| 864 *enable_decrement = *enable_increment = false; | 864 *enable_decrement = *enable_increment = false; |
| 865 // Calculate the zoom percent from the factor. Round up to the nearest whole |
| 866 // number. |
| 865 int percent = static_cast<int>( | 867 int percent = static_cast<int>( |
| 866 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100); | 868 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100 + 0.5); |
| 867 *enable_decrement = percent > minimum_zoom_percent_; | 869 *enable_decrement = percent > minimum_zoom_percent_; |
| 868 *enable_increment = percent < maximum_zoom_percent_; | 870 *enable_increment = percent < maximum_zoom_percent_; |
| 869 return percent; | 871 return percent; |
| 870 } | 872 } |
| 871 | 873 |
| 872 void TabContents::ViewSource() { | 874 void TabContents::ViewSource() { |
| 873 if (!delegate_) | 875 if (!delegate_) |
| 874 return; | 876 return; |
| 875 | 877 |
| 876 NavigationEntry* active_entry = controller().GetActiveEntry(); | 878 NavigationEntry* active_entry = controller().GetActiveEntry(); |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 | 2032 |
| 2031 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2033 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2032 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2034 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2033 rwh_view->SetSize(view()->GetContainerSize()); | 2035 rwh_view->SetSize(view()->GetContainerSize()); |
| 2034 } | 2036 } |
| 2035 | 2037 |
| 2036 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2038 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
| 2037 return render_view_host() ? | 2039 return render_view_host() ? |
| 2038 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2040 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
| 2039 } | 2041 } |
| OLD | NEW |