| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 RoutingIDViewMap* views = g_routing_id_view_map.Pointer(); | 883 RoutingIDViewMap* views = g_routing_id_view_map.Pointer(); |
| 884 RoutingIDViewMap::iterator it = views->find(routing_id); | 884 RoutingIDViewMap::iterator it = views->find(routing_id); |
| 885 return it == views->end() ? NULL : it->second; | 885 return it == views->end() ? NULL : it->second; |
| 886 } | 886 } |
| 887 | 887 |
| 888 /*static*/ | 888 /*static*/ |
| 889 RenderView* RenderView::FromRoutingID(int routing_id) { | 889 RenderView* RenderView::FromRoutingID(int routing_id) { |
| 890 return RenderViewImpl::FromRoutingID(routing_id); | 890 return RenderViewImpl::FromRoutingID(routing_id); |
| 891 } | 891 } |
| 892 | 892 |
| 893 /* static */ |
| 894 size_t RenderViewImpl::GetRenderViewCount() { |
| 895 return g_view_map.Get().size(); |
| 896 } |
| 897 |
| 893 /*static*/ | 898 /*static*/ |
| 894 void RenderView::ForEach(RenderViewVisitor* visitor) { | 899 void RenderView::ForEach(RenderViewVisitor* visitor) { |
| 895 ViewMap* views = g_view_map.Pointer(); | 900 ViewMap* views = g_view_map.Pointer(); |
| 896 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { | 901 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 897 if (!visitor->Visit(it->second)) | 902 if (!visitor->Visit(it->second)) |
| 898 return; | 903 return; |
| 899 } | 904 } |
| 900 } | 905 } |
| 901 | 906 |
| 902 /*static*/ | 907 /*static*/ |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 return; | 2133 return; |
| 2129 | 2134 |
| 2130 // When navigating to a new page, reset the page scale factor to be 1.0. | 2135 // When navigating to a new page, reset the page scale factor to be 1.0. |
| 2131 webview()->setInitialPageScaleOverride(1.f); | 2136 webview()->setInitialPageScaleOverride(1.f); |
| 2132 | 2137 |
| 2133 float maxPageScaleFactor = | 2138 float maxPageScaleFactor = |
| 2134 command_line.HasSwitch(switches::kEnablePinch) ? 4.f : 1.f ; | 2139 command_line.HasSwitch(switches::kEnablePinch) ? 4.f : 1.f ; |
| 2135 webview()->setPageScaleFactorLimits(1, maxPageScaleFactor); | 2140 webview()->setPageScaleFactorLimits(1, maxPageScaleFactor); |
| 2136 } | 2141 } |
| 2137 | 2142 |
| 2138 void RenderViewImpl::FrameDidCommitProvisionalLoad(WebLocalFrame* frame, | |
| 2139 bool is_new_navigation) { | |
| 2140 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | |
| 2141 DidCommitProvisionalLoad(frame, is_new_navigation)); | |
| 2142 | |
| 2143 // TODO(nasko): Transition this code to RenderFrameImpl, since g_view_map is | |
| 2144 // not accessible from there. | |
| 2145 if (!frame->parent()) { // Only for top frames. | |
| 2146 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | |
| 2147 if (render_thread_impl) { // Can be NULL in tests. | |
| 2148 render_thread_impl->histogram_customizer()-> | |
| 2149 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), | |
| 2150 g_view_map.Get().size()); | |
| 2151 } | |
| 2152 } | |
| 2153 } | |
| 2154 | |
| 2155 void RenderViewImpl::didClearWindowObject(WebLocalFrame* frame) { | 2143 void RenderViewImpl::didClearWindowObject(WebLocalFrame* frame) { |
| 2156 FOR_EACH_OBSERVER( | 2144 FOR_EACH_OBSERVER( |
| 2157 RenderViewObserver, observers_, DidClearWindowObject(frame)); | 2145 RenderViewObserver, observers_, DidClearWindowObject(frame)); |
| 2158 | 2146 |
| 2159 if (enabled_bindings_& BINDINGS_POLICY_WEB_UI) | 2147 if (enabled_bindings_& BINDINGS_POLICY_WEB_UI) |
| 2160 WebUIExtension::Install(frame); | 2148 WebUIExtension::Install(frame); |
| 2161 | 2149 |
| 2162 if (enabled_bindings_ & BINDINGS_POLICY_STATS_COLLECTION) | 2150 if (enabled_bindings_ & BINDINGS_POLICY_STATS_COLLECTION) |
| 2163 StatsCollectionController::Install(frame); | 2151 StatsCollectionController::Install(frame); |
| 2164 | 2152 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 void RenderViewImpl::DidStopLoading() { | 2352 void RenderViewImpl::DidStopLoading() { |
| 2365 main_render_frame_->didStopLoading(); | 2353 main_render_frame_->didStopLoading(); |
| 2366 } | 2354 } |
| 2367 | 2355 |
| 2368 void RenderViewImpl::SyncNavigationState() { | 2356 void RenderViewImpl::SyncNavigationState() { |
| 2369 if (!webview()) | 2357 if (!webview()) |
| 2370 return; | 2358 return; |
| 2371 SendUpdateState(history_controller_->GetCurrentEntry()); | 2359 SendUpdateState(history_controller_->GetCurrentEntry()); |
| 2372 } | 2360 } |
| 2373 | 2361 |
| 2374 GURL RenderViewImpl::GetLoadingUrl(blink::WebFrame* frame) const { | |
| 2375 WebDataSource* ds = frame->dataSource(); | |
| 2376 if (ds->hasUnreachableURL()) | |
| 2377 return ds->unreachableURL(); | |
| 2378 | |
| 2379 const WebURLRequest& request = ds->request(); | |
| 2380 return request.url(); | |
| 2381 } | |
| 2382 | |
| 2383 blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { | 2362 blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { |
| 2384 if (!webview()) | 2363 if (!webview()) |
| 2385 return NULL; | 2364 return NULL; |
| 2386 | 2365 |
| 2387 WebFrame* main_frame = webview()->mainFrame(); | 2366 WebFrame* main_frame = webview()->mainFrame(); |
| 2388 if (main_frame->document().isPluginDocument()) | 2367 if (main_frame->document().isPluginDocument()) |
| 2389 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 2368 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
| 2390 | 2369 |
| 2391 #if defined(ENABLE_PLUGINS) | 2370 #if defined(ENABLE_PLUGINS) |
| 2392 if (plugin_find_handler_) | 2371 if (plugin_find_handler_) |
| (...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4038 std::vector<gfx::Size> sizes; | 4017 std::vector<gfx::Size> sizes; |
| 4039 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4018 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 4040 if (!url.isEmpty()) | 4019 if (!url.isEmpty()) |
| 4041 urls.push_back( | 4020 urls.push_back( |
| 4042 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4021 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 4043 } | 4022 } |
| 4044 SendUpdateFaviconURL(urls); | 4023 SendUpdateFaviconURL(urls); |
| 4045 } | 4024 } |
| 4046 | 4025 |
| 4047 } // namespace content | 4026 } // namespace content |
| OLD | NEW |