| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 HostZoomLevels::iterator host_zoom = | 1177 HostZoomLevels::iterator host_zoom = |
| 1178 host_zoom_levels_.find(GURL(request.url()).host()); | 1178 host_zoom_levels_.find(GURL(request.url()).host()); |
| 1179 if (host_zoom != host_zoom_levels_.end()) { | 1179 if (host_zoom != host_zoom_levels_.end()) { |
| 1180 webview()->setZoomLevel(false, host_zoom->second); | 1180 webview()->setZoomLevel(false, host_zoom->second); |
| 1181 // This zoom level was merely recorded transiently for this load. We can | 1181 // This zoom level was merely recorded transiently for this load. We can |
| 1182 // erase it now. If at some point we reload this page, the browser will | 1182 // erase it now. If at some point we reload this page, the browser will |
| 1183 // send us a new, up-to-date zoom level. | 1183 // send us a new, up-to-date zoom level. |
| 1184 host_zoom_levels_.erase(host_zoom); | 1184 host_zoom_levels_.erase(host_zoom); |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 // Drop the translated nodes. | |
| 1188 page_translator_->NavigatedToNewPage(); | |
| 1189 | |
| 1190 // Update contents MIME type for main frame. | 1187 // Update contents MIME type for main frame. |
| 1191 params.contents_mime_type = ds->response().mimeType().utf8(); | 1188 params.contents_mime_type = ds->response().mimeType().utf8(); |
| 1192 | 1189 |
| 1193 params.transition = navigation_state->transition_type(); | 1190 params.transition = navigation_state->transition_type(); |
| 1194 if (!PageTransition::IsMainFrame(params.transition)) { | 1191 if (!PageTransition::IsMainFrame(params.transition)) { |
| 1195 // If the main frame does a load, it should not be reported as a subframe | 1192 // If the main frame does a load, it should not be reported as a subframe |
| 1196 // navigation. This can occur in the following case: | 1193 // navigation. This can occur in the following case: |
| 1197 // 1. You're on a site with frames. | 1194 // 1. You're on a site with frames. |
| 1198 // 2. You do a subframe navigation. This is stored with transition type | 1195 // 2. You do a subframe navigation. This is stored with transition type |
| 1199 // MANUAL_SUBFRAME. | 1196 // MANUAL_SUBFRAME. |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 navigation_state->postponed_data().size()); | 2399 navigation_state->postponed_data().size()); |
| 2403 navigation_state->clear_postponed_data(); | 2400 navigation_state->clear_postponed_data(); |
| 2404 } | 2401 } |
| 2405 } | 2402 } |
| 2406 | 2403 |
| 2407 void RenderView::didCommitProvisionalLoad(WebFrame* frame, | 2404 void RenderView::didCommitProvisionalLoad(WebFrame* frame, |
| 2408 bool is_new_navigation) { | 2405 bool is_new_navigation) { |
| 2409 NavigationState* navigation_state = | 2406 NavigationState* navigation_state = |
| 2410 NavigationState::FromDataSource(frame->dataSource()); | 2407 NavigationState::FromDataSource(frame->dataSource()); |
| 2411 | 2408 |
| 2409 if (!frame->parent()) { // Main frame case. |
| 2410 // Let the page translator know that the page has changed so it can clear |
| 2411 // its states. |
| 2412 page_translator_->MainFrameNavigated(); |
| 2413 } |
| 2414 |
| 2412 navigation_state->set_commit_load_time(Time::Now()); | 2415 navigation_state->set_commit_load_time(Time::Now()); |
| 2413 if (is_new_navigation) { | 2416 if (is_new_navigation) { |
| 2414 // When we perform a new navigation, we need to update the previous session | 2417 // When we perform a new navigation, we need to update the previous session |
| 2415 // history entry with state for the page we are leaving. | 2418 // history entry with state for the page we are leaving. |
| 2416 UpdateSessionHistory(frame); | 2419 UpdateSessionHistory(frame); |
| 2417 | 2420 |
| 2418 // We bump our Page ID to correspond with the new session history entry. | 2421 // We bump our Page ID to correspond with the new session history entry. |
| 2419 page_id_ = next_page_id_++; | 2422 page_id_ = next_page_id_++; |
| 2420 | 2423 |
| 2421 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 2424 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 | 2517 |
| 2515 // Check whether we have new encoding name. | 2518 // Check whether we have new encoding name. |
| 2516 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2519 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 2517 | 2520 |
| 2518 if (RenderThread::current()) { // Will be NULL during unit tests. | 2521 if (RenderThread::current()) { // Will be NULL during unit tests. |
| 2519 RenderThread::current()->user_script_slave()->InjectScripts( | 2522 RenderThread::current()->user_script_slave()->InjectScripts( |
| 2520 frame, UserScript::DOCUMENT_END); | 2523 frame, UserScript::DOCUMENT_END); |
| 2521 } | 2524 } |
| 2522 | 2525 |
| 2523 navigation_state->user_script_idle_scheduler()->DidFinishDocumentLoad(); | 2526 navigation_state->user_script_idle_scheduler()->DidFinishDocumentLoad(); |
| 2527 |
| 2528 if (page_translator_->IsPageTranslated()) |
| 2529 page_translator_->TranslateFrame(frame); |
| 2524 } | 2530 } |
| 2525 | 2531 |
| 2526 void RenderView::OnUserScriptIdleTriggered(WebFrame* frame) { | 2532 void RenderView::OnUserScriptIdleTriggered(WebFrame* frame) { |
| 2527 if (RenderThread::current()) { // Will be NULL during unit tests. | 2533 if (RenderThread::current()) { // Will be NULL during unit tests. |
| 2528 RenderThread::current()->user_script_slave()->InjectScripts( | 2534 RenderThread::current()->user_script_slave()->InjectScripts( |
| 2529 frame, UserScript::DOCUMENT_IDLE); | 2535 frame, UserScript::DOCUMENT_IDLE); |
| 2530 } | 2536 } |
| 2531 | 2537 |
| 2532 WebFrame* main_frame = webview()->mainFrame(); | 2538 WebFrame* main_frame = webview()->mainFrame(); |
| 2533 if (frame == main_frame) { | 2539 if (frame == main_frame) { |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3428 | 3434 |
| 3429 void RenderView::OnTranslatePage(int page_id, | 3435 void RenderView::OnTranslatePage(int page_id, |
| 3430 const std::string& source_lang, | 3436 const std::string& source_lang, |
| 3431 const std::string& target_lang) { | 3437 const std::string& target_lang) { |
| 3432 if (page_id != page_id_) | 3438 if (page_id != page_id_) |
| 3433 return; // Not the page we expected, nothing to do. | 3439 return; // Not the page we expected, nothing to do. |
| 3434 | 3440 |
| 3435 WebFrame* main_frame = webview()->mainFrame(); | 3441 WebFrame* main_frame = webview()->mainFrame(); |
| 3436 if (!main_frame) | 3442 if (!main_frame) |
| 3437 return; | 3443 return; |
| 3438 page_translator_->Translate(page_id, main_frame, source_lang, target_lang); | 3444 |
| 3445 page_translator_->TranslatePage(page_id, main_frame, |
| 3446 source_lang, target_lang); |
| 3439 } | 3447 } |
| 3440 | 3448 |
| 3441 void RenderView::OnTranslateTextResponse( | 3449 void RenderView::OnTranslateTextResponse( |
| 3442 int work_id, int error_id, const std::vector<string16>& text_chunks) { | 3450 int work_id, int error_id, const std::vector<string16>& text_chunks) { |
| 3443 text_translator_.OnTranslationResponse(work_id, error_id, text_chunks); | 3451 text_translator_.OnTranslationResponse(work_id, error_id, text_chunks); |
| 3444 } | 3452 } |
| 3445 | 3453 |
| 3446 void RenderView::OnInstallMissingPlugin() { | 3454 void RenderView::OnInstallMissingPlugin() { |
| 3447 // This could happen when the first default plugin is deleted. | 3455 // This could happen when the first default plugin is deleted. |
| 3448 if (first_default_plugin_) | 3456 if (first_default_plugin_) |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4409 int32 height, | 4417 int32 height, |
| 4410 uint64 io_surface_identifier) { | 4418 uint64 io_surface_identifier) { |
| 4411 Send(new ViewHostMsg_GPUPluginSetIOSurface( | 4419 Send(new ViewHostMsg_GPUPluginSetIOSurface( |
| 4412 routing_id(), window, width, height, io_surface_identifier)); | 4420 routing_id(), window, width, height, io_surface_identifier)); |
| 4413 } | 4421 } |
| 4414 | 4422 |
| 4415 void RenderView::GPUPluginBuffersSwapped(gfx::PluginWindowHandle window) { | 4423 void RenderView::GPUPluginBuffersSwapped(gfx::PluginWindowHandle window) { |
| 4416 Send(new ViewHostMsg_GPUPluginBuffersSwapped(routing_id(), window)); | 4424 Send(new ViewHostMsg_GPUPluginBuffersSwapped(routing_id(), window)); |
| 4417 } | 4425 } |
| 4418 #endif | 4426 #endif |
| OLD | NEW |