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