| 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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 // Inform RendererMediaPlayerManager to release all video player resources. | 1310 // Inform RendererMediaPlayerManager to release all video player resources. |
| 1311 // If something is in progress the resource will not be freed, it will | 1311 // If something is in progress the resource will not be freed, it will |
| 1312 // only be freed once the tab is destroyed or if the user navigates away | 1312 // only be freed once the tab is destroyed or if the user navigates away |
| 1313 // via WebMediaPlayerAndroid::Destroy. | 1313 // via WebMediaPlayerAndroid::Destroy. |
| 1314 media_player_manager_->ReleaseVideoResources(); | 1314 media_player_manager_->ReleaseVideoResources(); |
| 1315 } | 1315 } |
| 1316 #endif | 1316 #endif |
| 1317 | 1317 |
| 1318 /////////////////////////////////////////////////////////////////////////////// | 1318 /////////////////////////////////////////////////////////////////////////////// |
| 1319 | 1319 |
| 1320 // Tell the embedding application that the title of the active page has changed | |
| 1321 void RenderViewImpl::UpdateTitle(WebFrame* frame, | |
| 1322 const base::string16& title, | |
| 1323 WebTextDirection title_direction) { | |
| 1324 // Ignore all but top level navigations. | |
| 1325 if (frame->parent()) | |
| 1326 return; | |
| 1327 | |
| 1328 base::debug::TraceLog::GetInstance()->UpdateProcessLabel( | |
| 1329 routing_id_, base::UTF16ToUTF8(title)); | |
| 1330 | |
| 1331 base::string16 shortened_title = title.substr(0, kMaxTitleChars); | |
| 1332 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, | |
| 1333 title_direction)); | |
| 1334 } | |
| 1335 | |
| 1336 void RenderViewImpl::UpdateEncoding(WebFrame* frame, | |
| 1337 const std::string& encoding_name) { | |
| 1338 // Only update main frame's encoding_name. | |
| 1339 if (webview()->mainFrame() == frame && | |
| 1340 last_encoding_name_ != encoding_name) { | |
| 1341 // Save the encoding name for later comparing. | |
| 1342 last_encoding_name_ = encoding_name; | |
| 1343 | |
| 1344 Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_)); | |
| 1345 } | |
| 1346 } | |
| 1347 | |
| 1348 // Sends the last committed session history state to the browser so it will be | 1320 // Sends the last committed session history state to the browser so it will be |
| 1349 // saved before we navigate to a new page. This must be called *before* the | 1321 // saved before we navigate to a new page. This must be called *before* the |
| 1350 // page ID has been updated so we know what it was. | 1322 // page ID has been updated so we know what it was. |
| 1351 void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { | 1323 void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { |
| 1352 // If we have a valid page ID at this point, then it corresponds to the page | 1324 // If we have a valid page ID at this point, then it corresponds to the page |
| 1353 // we are navigating away from. Otherwise, this is the first navigation, so | 1325 // we are navigating away from. Otherwise, this is the first navigation, so |
| 1354 // there is no past session history to record. | 1326 // there is no past session history to record. |
| 1355 if (page_id_ == -1) | 1327 if (page_id_ == -1) |
| 1356 return; | 1328 return; |
| 1357 SendUpdateState(history_controller_->GetPreviousEntry()); | 1329 SendUpdateState(history_controller_->GetPreviousEntry()); |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 | 2207 |
| 2236 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 2208 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 2237 | 2209 |
| 2238 if (command_line.HasSwitch(switches::kEnableSkiaBenchmarking)) | 2210 if (command_line.HasSwitch(switches::kEnableSkiaBenchmarking)) |
| 2239 SkiaBenchmarking::Install(frame); | 2211 SkiaBenchmarking::Install(frame); |
| 2240 | 2212 |
| 2241 if (command_line.HasSwitch(switches::kEnableMemoryBenchmarking)) | 2213 if (command_line.HasSwitch(switches::kEnableMemoryBenchmarking)) |
| 2242 MemoryBenchmarkingExtension::Install(frame); | 2214 MemoryBenchmarkingExtension::Install(frame); |
| 2243 } | 2215 } |
| 2244 | 2216 |
| 2245 void RenderViewImpl::didReceiveTitle(WebLocalFrame* frame, | |
| 2246 const WebString& title, | |
| 2247 WebTextDirection direction) { | |
| 2248 UpdateTitle(frame, title, direction); | |
| 2249 | |
| 2250 // Also check whether we have new encoding name. | |
| 2251 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | |
| 2252 } | |
| 2253 | |
| 2254 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, | 2217 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, |
| 2255 WebIconURL::Type icon_type) { | 2218 WebIconURL::Type icon_type) { |
| 2256 if (frame->parent()) | 2219 if (frame->parent()) |
| 2257 return; | 2220 return; |
| 2258 | 2221 |
| 2259 if (!TouchEnabled() && icon_type != WebIconURL::TypeFavicon) | 2222 if (!TouchEnabled() && icon_type != WebIconURL::TypeFavicon) |
| 2260 return; | 2223 return; |
| 2261 | 2224 |
| 2262 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); | 2225 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); |
| 2263 std::vector<FaviconURL> urls; | 2226 std::vector<FaviconURL> urls; |
| (...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4097 std::vector<gfx::Size> sizes; | 4060 std::vector<gfx::Size> sizes; |
| 4098 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4061 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 4099 if (!url.isEmpty()) | 4062 if (!url.isEmpty()) |
| 4100 urls.push_back( | 4063 urls.push_back( |
| 4101 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4064 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 4102 } | 4065 } |
| 4103 SendUpdateFaviconURL(urls); | 4066 SendUpdateFaviconURL(urls); |
| 4104 } | 4067 } |
| 4105 | 4068 |
| 4106 } // namespace content | 4069 } // namespace content |
| OLD | NEW |