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 "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 : RenderWidget(render_thread, WebKit::WebPopupTypeNone), | 550 : RenderWidget(render_thread, WebKit::WebPopupTypeNone), |
551 webkit_preferences_(webkit_prefs), | 551 webkit_preferences_(webkit_prefs), |
552 send_content_state_immediately_(false), | 552 send_content_state_immediately_(false), |
553 enabled_bindings_(0), | 553 enabled_bindings_(0), |
554 send_preferred_size_changes_(false), | 554 send_preferred_size_changes_(false), |
555 script_can_close_(true), | 555 script_can_close_(true), |
556 is_loading_(false), | 556 is_loading_(false), |
557 navigation_gesture_(NavigationGestureUnknown), | 557 navigation_gesture_(NavigationGestureUnknown), |
558 opened_by_user_gesture_(true), | 558 opened_by_user_gesture_(true), |
559 opener_suppressed_(false), | 559 opener_suppressed_(false), |
560 is_prerendering_(false), | |
560 page_id_(-1), | 561 page_id_(-1), |
561 last_page_id_sent_to_browser_(-1), | 562 last_page_id_sent_to_browser_(-1), |
562 last_indexed_page_id_(-1), | 563 last_indexed_page_id_(-1), |
563 history_list_offset_(-1), | 564 history_list_offset_(-1), |
564 history_list_length_(0), | 565 history_list_length_(0), |
565 has_unload_listener_(false), | 566 has_unload_listener_(false), |
566 #if defined(OS_MACOSX) | 567 #if defined(OS_MACOSX) |
567 has_document_tag_(false), | 568 has_document_tag_(false), |
568 #endif | 569 #endif |
569 document_tag_(0), | 570 document_tag_(0), |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1418 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 1419 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
1419 WebString::fromUTF8(i.values())); | 1420 WebString::fromUTF8(i.values())); |
1420 } | 1421 } |
1421 } | 1422 } |
1422 | 1423 |
1423 if (navigation_state) { | 1424 if (navigation_state) { |
1424 if (params.navigation_type != ViewMsg_Navigate_Params::PRERENDER) { | 1425 if (params.navigation_type != ViewMsg_Navigate_Params::PRERENDER) { |
1425 navigation_state->set_load_type(NavigationState::NORMAL_LOAD); | 1426 navigation_state->set_load_type(NavigationState::NORMAL_LOAD); |
1426 } else { | 1427 } else { |
1427 navigation_state->set_load_type(NavigationState::PRERENDER_LOAD); | 1428 navigation_state->set_load_type(NavigationState::PRERENDER_LOAD); |
1428 navigation_state->set_was_started_as_prerender(true); | 1429 is_prerendering_ = true; |
1429 navigation_state->set_is_prerendering(true); | |
1430 } | 1430 } |
1431 } | 1431 } |
1432 main_frame->loadRequest(request); | 1432 main_frame->loadRequest(request); |
1433 } | 1433 } |
1434 | 1434 |
1435 // In case LoadRequest failed before DidCreateDataSource was called. | 1435 // In case LoadRequest failed before DidCreateDataSource was called. |
1436 pending_navigation_state_.reset(); | 1436 pending_navigation_state_.reset(); |
1437 } | 1437 } |
1438 | 1438 |
1439 // Stop loading the current page | 1439 // Stop loading the current page |
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2713 params, | 2713 params, |
2714 *group, | 2714 *group, |
2715 IDR_BLOCKED_PLUGIN_HTML, | 2715 IDR_BLOCKED_PLUGIN_HTML, |
2716 IDS_PLUGIN_NOT_AUTHORIZED, | 2716 IDS_PLUGIN_NOT_AUTHORIZED, |
2717 false); | 2717 false); |
2718 } | 2718 } |
2719 | 2719 |
2720 if (info.path.value() == webkit::npapi::kDefaultPluginLibraryName || | 2720 if (info.path.value() == webkit::npapi::kDefaultPluginLibraryName || |
2721 plugin_setting == CONTENT_SETTING_ALLOW || | 2721 plugin_setting == CONTENT_SETTING_ALLOW || |
2722 host_setting == CONTENT_SETTING_ALLOW) { | 2722 host_setting == CONTENT_SETTING_ALLOW) { |
2723 // Delay loading plugins if prerendering main frame. | 2723 // Delay loading plugins if prerendering. |
2724 WebDataSource* main_frame_ds = webview()->mainFrame()->dataSource(); | 2724 if (is_prerendering_) { |
2725 NavigationState* navigation_state = | |
2726 NavigationState::FromDataSource(main_frame_ds); | |
2727 if (navigation_state->is_prerendering()) { | |
2728 return CreatePluginPlaceholder(frame, | 2725 return CreatePluginPlaceholder(frame, |
2729 params, | 2726 params, |
2730 *group, | 2727 *group, |
2731 IDR_CLICK_TO_PLAY_PLUGIN_HTML, | 2728 IDR_CLICK_TO_PLAY_PLUGIN_HTML, |
2732 IDS_PLUGIN_LOAD, | 2729 IDS_PLUGIN_LOAD, |
2733 true); | 2730 true); |
2734 } | 2731 } |
2735 | 2732 |
2736 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( | 2733 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
2737 pepper_delegate_.CreatePepperPlugin(info.path)); | 2734 pepper_delegate_.CreatePepperPlugin(info.path)); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3222 // This is for navigations within a page (didNavigateWithinPage). See | 3219 // This is for navigations within a page (didNavigateWithinPage). See |
3223 // http://code.google.com/p/chromium/issues/detail?id=64093 | 3220 // http://code.google.com/p/chromium/issues/detail?id=64093 |
3224 NavigationState* old_state = NavigationState::FromDataSource(ds); | 3221 NavigationState* old_state = NavigationState::FromDataSource(ds); |
3225 if (old_state && old_state->user_script_idle_scheduler()) { | 3222 if (old_state && old_state->user_script_idle_scheduler()) { |
3226 state->swap_user_script_idle_scheduler(old_state); | 3223 state->swap_user_script_idle_scheduler(old_state); |
3227 } else { | 3224 } else { |
3228 state->set_user_script_idle_scheduler( | 3225 state->set_user_script_idle_scheduler( |
3229 new UserScriptIdleScheduler(this, frame)); | 3226 new UserScriptIdleScheduler(this, frame)); |
3230 } | 3227 } |
3231 | 3228 |
3232 // If the RenderView was prerendering before, it is still prerendering. | 3229 state->set_was_started_as_prerender(is_prerendering_); |
3233 if (!frame->parent() && content_initiated) { | |
3234 WebDataSource* ds_old = webview()->mainFrame()->dataSource(); | |
3235 if (ds_old) { | |
3236 NavigationState* navigation_state = | |
3237 NavigationState::FromDataSource(ds_old); | |
3238 if (navigation_state) { | |
3239 state->set_is_prerendering(navigation_state->is_prerendering()); | |
3240 state->set_was_started_as_prerender( | |
3241 navigation_state->was_started_as_prerender()); | |
3242 } | |
3243 } | |
3244 } | |
3245 | 3230 |
3246 ds->setExtraData(state); | 3231 ds->setExtraData(state); |
3247 } | 3232 } |
3248 | 3233 |
3249 void RenderView::didStartProvisionalLoad(WebFrame* frame) { | 3234 void RenderView::didStartProvisionalLoad(WebFrame* frame) { |
3250 WebDataSource* ds = frame->provisionalDataSource(); | 3235 WebDataSource* ds = frame->provisionalDataSource(); |
3251 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 3236 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
3252 | 3237 |
3253 // Update the request time if WebKit has better knowledge of it. | 3238 // Update the request time if WebKit has better knowledge of it. |
3254 if (navigation_state->request_time().is_null()) { | 3239 if (navigation_state->request_time().is_null()) { |
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4711 webview()->performCustomContextMenuAction(action); | 4696 webview()->performCustomContextMenuAction(action); |
4712 } | 4697 } |
4713 | 4698 |
4714 void RenderView::OnInstallMissingPlugin() { | 4699 void RenderView::OnInstallMissingPlugin() { |
4715 // This could happen when the first default plugin is deleted. | 4700 // This could happen when the first default plugin is deleted. |
4716 if (first_default_plugin_) | 4701 if (first_default_plugin_) |
4717 first_default_plugin_->InstallMissingPlugin(); | 4702 first_default_plugin_->InstallMissingPlugin(); |
4718 } | 4703 } |
4719 | 4704 |
4720 void RenderView::OnDisplayPrerenderedPage() { | 4705 void RenderView::OnDisplayPrerenderedPage() { |
4721 NavigationState* navigation_state = pending_navigation_state_.get(); | 4706 DCHECK(is_prerendering_); |
4722 if (!navigation_state) { | 4707 is_prerendering_ = false; |
4723 WebDataSource* ds = webview()->mainFrame()->dataSource(); | 4708 |
4724 navigation_state = NavigationState::FromDataSource(ds); | 4709 // Update NavigationState for histograms. |
4710 WebDataSource* ds = webview()->mainFrame()->dataSource(); | |
4711 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | |
4712 navigation_state->set_prerendered_page_display_time(Time::Now()); | |
4713 | |
4714 // If there is a provisional data source, update its NavigationState, too. | |
4715 WebDataSource* povisional_ds = | |
cbentzel
2011/02/18 13:56:47
provisional_ds - although at least the misspelling
mmenke
2011/02/18 14:53:04
Fixed, though I prefer my more creative spelling.
| |
4716 webview()->mainFrame()->provisionalDataSource(); | |
4717 if (povisional_ds) { | |
4718 NavigationState* provisional_navigation_state = | |
4719 NavigationState::FromDataSource(povisional_ds); | |
4720 if (provisional_navigation_state) { | |
4721 provisional_navigation_state->set_prerendered_page_display_time( | |
4722 Time::Now()); | |
4723 } | |
4725 } | 4724 } |
4726 | |
4727 DCHECK(navigation_state->is_prerendering()); | |
4728 navigation_state->set_is_prerendering(false); | |
4729 navigation_state->set_prerendered_page_display_time(Time::Now()); | |
4730 } | 4725 } |
4731 | 4726 |
4732 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { | 4727 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { |
4733 // This could happen if we navigated to a different page before the user | 4728 // This could happen if we navigated to a different page before the user |
4734 // closed the chooser. | 4729 // closed the chooser. |
4735 if (file_chooser_completions_.empty()) | 4730 if (file_chooser_completions_.empty()) |
4736 return; | 4731 return; |
4737 | 4732 |
4738 WebVector<WebString> ws_file_names(paths.size()); | 4733 WebVector<WebString> ws_file_names(paths.size()); |
4739 for (size_t i = 0; i < paths.size(); ++i) | 4734 for (size_t i = 0; i < paths.size(); ++i) |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5677 } | 5672 } |
5678 } | 5673 } |
5679 | 5674 |
5680 void RenderView::OnContextMenuClosed( | 5675 void RenderView::OnContextMenuClosed( |
5681 const webkit_glue::CustomContextMenuContext& custom_context) { | 5676 const webkit_glue::CustomContextMenuContext& custom_context) { |
5682 if (custom_context.is_pepper_menu) | 5677 if (custom_context.is_pepper_menu) |
5683 pepper_delegate_.OnContextMenuClosed(custom_context); | 5678 pepper_delegate_.OnContextMenuClosed(custom_context); |
5684 else | 5679 else |
5685 context_menu_node_.reset(); | 5680 context_menu_node_.reset(); |
5686 } | 5681 } |
OLD | NEW |