| 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 13 matching lines...) Expand all Loading... |
| 24 #include "base/time.h" | 24 #include "base/time.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 #include "chrome/common/appcache/appcache_dispatcher.h" | 26 #include "chrome/common/appcache/appcache_dispatcher.h" |
| 27 #include "chrome/common/bindings_policy.h" | 27 #include "chrome/common/bindings_policy.h" |
| 28 #include "chrome/common/child_process_logging.h" | 28 #include "chrome/common/child_process_logging.h" |
| 29 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
| 30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/extensions/extension.h" | 32 #include "chrome/common/extensions/extension.h" |
| 33 #include "chrome/common/jstemplate_builder.h" | 33 #include "chrome/common/jstemplate_builder.h" |
| 34 #include "chrome/common/notification_service.h" |
| 34 #include "chrome/common/page_zoom.h" | 35 #include "chrome/common/page_zoom.h" |
| 35 #include "chrome/common/pepper_plugin_registry.h" | 36 #include "chrome/common/pepper_plugin_registry.h" |
| 37 #include "chrome/common/plugin_group.h" |
| 36 #include "chrome/common/render_messages.h" | 38 #include "chrome/common/render_messages.h" |
| 37 #include "chrome/common/renderer_preferences.h" | 39 #include "chrome/common/renderer_preferences.h" |
| 38 #include "chrome/common/thumbnail_score.h" | 40 #include "chrome/common/thumbnail_score.h" |
| 39 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
| 40 #include "chrome/common/window_container_type.h" | 42 #include "chrome/common/window_container_type.h" |
| 41 #include "chrome/renderer/about_handler.h" | 43 #include "chrome/renderer/about_handler.h" |
| 42 #include "chrome/renderer/audio_message_filter.h" | 44 #include "chrome/renderer/audio_message_filter.h" |
| 43 #include "chrome/renderer/blocked_plugin.h" | 45 #include "chrome/renderer/blocked_plugin.h" |
| 44 #include "chrome/renderer/devtools_agent.h" | 46 #include "chrome/renderer/devtools_agent.h" |
| 45 #include "chrome/renderer/devtools_client.h" | 47 #include "chrome/renderer/devtools_client.h" |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 IPC_MESSAGE_HANDLER(ViewMsg_SetDOMUIProperty, OnSetDOMUIProperty) | 678 IPC_MESSAGE_HANDLER(ViewMsg_SetDOMUIProperty, OnSetDOMUIProperty) |
| 677 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceEndedOrMoved, | 679 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceEndedOrMoved, |
| 678 OnDragSourceEndedOrMoved) | 680 OnDragSourceEndedOrMoved) |
| 679 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceSystemDragEnded, | 681 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceSystemDragEnded, |
| 680 OnDragSourceSystemDragEnded) | 682 OnDragSourceSystemDragEnded) |
| 681 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 683 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
| 682 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 684 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 683 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 685 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 684 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 686 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
| 685 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) | 687 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) |
| 688 IPC_MESSAGE_HANDLER(ViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) |
| 686 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 689 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
| 687 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 690 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 688 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 691 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
| 689 OnGetAllSavableResourceLinksForCurrentPage) | 692 OnGetAllSavableResourceLinksForCurrentPage) |
| 690 IPC_MESSAGE_HANDLER( | 693 IPC_MESSAGE_HANDLER( |
| 691 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 694 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 692 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 695 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
| 693 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) | 696 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) |
| 694 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) | 697 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
| 695 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 698 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| (...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 if (RenderThread::current()) // Will be NULL during unit tests. | 2293 if (RenderThread::current()) // Will be NULL during unit tests. |
| 2291 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); | 2294 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); |
| 2292 | 2295 |
| 2293 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); | 2296 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
| 2294 } | 2297 } |
| 2295 | 2298 |
| 2296 // WebKit::WebFrameClient ----------------------------------------------------- | 2299 // WebKit::WebFrameClient ----------------------------------------------------- |
| 2297 | 2300 |
| 2298 WebPlugin* RenderView::createPlugin(WebFrame* frame, | 2301 WebPlugin* RenderView::createPlugin(WebFrame* frame, |
| 2299 const WebPluginParams& params) { | 2302 const WebPluginParams& params) { |
| 2300 if (AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS)) | 2303 bool found = false; |
| 2301 return CreatePluginInternal(frame, params); | 2304 WebPluginInfo info; |
| 2305 GURL url(params.url); |
| 2306 std::string mime_type(params.mimeType.utf8()); |
| 2307 std::string actual_mime_type; |
| 2308 Send(new ViewHostMsg_GetPluginInfo(url, |
| 2309 frame->top()->url(), |
| 2310 mime_type, |
| 2311 &found, |
| 2312 &info, |
| 2313 &actual_mime_type)); |
| 2302 | 2314 |
| 2303 didNotAllowPlugins(frame); | 2315 if (!found) |
| 2304 return CreatePluginPlaceholder(frame, params); | 2316 return NULL; |
| 2317 |
| 2318 scoped_ptr<PluginGroup> group(PluginGroup::FindHardcodedPluginGroup(info)); |
| 2319 group->AddPlugin(info, 0); |
| 2320 |
| 2321 if (!info.enabled) { |
| 2322 if (group->IsVulnerable() && CommandLine::ForCurrentProcess()->HasSwitch( |
| 2323 switches::kDisableOutdatedPlugins)) { |
| 2324 Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, |
| 2325 group->GetGroupName(), |
| 2326 GURL(group->GetUpdateURL()))); |
| 2327 return CreatePluginPlaceholder(frame, params, group.get()); |
| 2328 } |
| 2329 return NULL; |
| 2330 } |
| 2331 |
| 2332 if (info.path.value() != kDefaultPluginLibraryName) { |
| 2333 if (!AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS)) { |
| 2334 didNotAllowPlugins(frame); |
| 2335 return CreatePluginPlaceholder(frame, params, NULL); |
| 2336 } |
| 2337 scoped_refptr<pepper::PluginModule> pepper_module = |
| 2338 PepperPluginRegistry::GetInstance()->GetModule(info.path); |
| 2339 if (pepper_module) { |
| 2340 return CreatePepperPlugin(pepper_module.get(), params); |
| 2341 } |
| 2342 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2343 switches::kBlockNonSandboxedPlugins)) { |
| 2344 Send(new ViewHostMsg_NonSandboxedPluginBlocked(routing_id_, |
| 2345 group->GetGroupName())); |
| 2346 return CreatePluginPlaceholder(frame, params, NULL); |
| 2347 } |
| 2348 } |
| 2349 return CreateNPAPIPlugin(frame, params, &info, actual_mime_type); |
| 2305 } | 2350 } |
| 2306 | 2351 |
| 2307 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { | 2352 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { |
| 2308 WebApplicationCacheHostImpl* appcache_host = | 2353 WebApplicationCacheHostImpl* appcache_host = |
| 2309 WebApplicationCacheHostImpl::FromFrame(frame); | 2354 WebApplicationCacheHostImpl::FromFrame(frame); |
| 2310 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; | 2355 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; |
| 2311 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, | 2356 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, |
| 2312 appcache_host_id); | 2357 appcache_host_id); |
| 2313 } | 2358 } |
| 2314 | 2359 |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3720 content_blocked_[settings_type] = true; | 3765 content_blocked_[settings_type] = true; |
| 3721 Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type)); | 3766 Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type)); |
| 3722 } | 3767 } |
| 3723 } | 3768 } |
| 3724 | 3769 |
| 3725 void RenderView::ClearBlockedContentSettings() { | 3770 void RenderView::ClearBlockedContentSettings() { |
| 3726 for (size_t i = 0; i < arraysize(content_blocked_); ++i) | 3771 for (size_t i = 0; i < arraysize(content_blocked_); ++i) |
| 3727 content_blocked_[i] = false; | 3772 content_blocked_[i] = false; |
| 3728 } | 3773 } |
| 3729 | 3774 |
| 3730 WebPlugin* RenderView::CreatePluginInternal(WebFrame* frame, | 3775 WebPlugin* RenderView::CreatePepperPlugin(pepper::PluginModule* pepper_module, |
| 3731 const WebPluginParams& params) { | 3776 const WebPluginParams& params) { |
| 3732 FilePath path; | 3777 return new pepper::WebPluginImpl(pepper_module, params, |
| 3733 std::string actual_mime_type; | 3778 pepper_delegate_.AsWeakPtr()); |
| 3734 render_thread_->Send(new ViewHostMsg_GetPluginPath( | 3779 } |
| 3735 params.url, frame->top()->url(), params.mimeType.utf8(), &path, | 3780 |
| 3736 &actual_mime_type)); | 3781 |
| 3737 if (path.value().empty()) | 3782 WebPlugin* RenderView::CreateNPAPIPlugin(WebFrame* frame, |
| 3783 const WebPluginParams& params, |
| 3784 WebPluginInfo* plugin_info, |
| 3785 const std::string& mime_type) { |
| 3786 std::string actual_mime_type(mime_type); |
| 3787 WebPluginInfo plugin; |
| 3788 if (plugin_info != NULL) { |
| 3789 plugin = *plugin_info; |
| 3790 } else { |
| 3791 bool found; |
| 3792 std::string actual_mime_type(mime_type); |
| 3793 Send(new ViewHostMsg_GetPluginInfo( |
| 3794 params.url, frame->top()->url(), params.mimeType.utf8(), &found, |
| 3795 &plugin, &actual_mime_type)); |
| 3796 if (!found) |
| 3797 plugin.enabled = false; |
| 3798 } |
| 3799 if (!plugin.enabled) |
| 3738 return NULL; | 3800 return NULL; |
| 3739 | 3801 |
| 3740 if (actual_mime_type.empty()) | 3802 if (actual_mime_type.empty()) |
| 3741 actual_mime_type = params.mimeType.utf8(); | 3803 actual_mime_type = params.mimeType.utf8(); |
| 3742 | 3804 return new webkit_glue::WebPluginImpl(frame, params, plugin.path, |
| 3743 scoped_refptr<pepper::PluginModule> pepper_module = | 3805 actual_mime_type, AsWeakPtr()); |
| 3744 PepperPluginRegistry::GetInstance()->GetModule(path); | |
| 3745 if (pepper_module) { | |
| 3746 return new pepper::WebPluginImpl(pepper_module, params, | |
| 3747 pepper_delegate_.AsWeakPtr()); | |
| 3748 } | |
| 3749 | |
| 3750 return new webkit_glue::WebPluginImpl(frame, params, path, actual_mime_type, | |
| 3751 AsWeakPtr()); | |
| 3752 } | 3806 } |
| 3753 | 3807 |
| 3754 WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame, | 3808 WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame, |
| 3755 const WebPluginParams& params) { | 3809 const WebPluginParams& params, |
| 3810 PluginGroup* group) { |
| 3756 // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed. | 3811 // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed. |
| 3757 BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params); | 3812 BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params, group); |
| 3758 WebViewPlugin* plugin = blocked_plugin->plugin(); | 3813 WebViewPlugin* plugin = blocked_plugin->plugin(); |
| 3759 webkit_preferences_.Apply(plugin->web_view()); | 3814 WebView* web_view = plugin->web_view(); |
| 3815 webkit_preferences_.Apply(web_view); |
| 3760 return plugin; | 3816 return plugin; |
| 3761 } | 3817 } |
| 3762 | 3818 |
| 3763 void RenderView::OnZoom(PageZoom::Function function) { | 3819 void RenderView::OnZoom(PageZoom::Function function) { |
| 3764 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 3820 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 3765 return; | 3821 return; |
| 3766 | 3822 |
| 3767 webview()->hidePopups(); | 3823 webview()->hidePopups(); |
| 3768 | 3824 |
| 3769 int zoom_level = webview()->zoomLevel(); | 3825 int zoom_level = webview()->zoomLevel(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4004 void RenderView::OnRevertTranslation(int page_id) { | 4060 void RenderView::OnRevertTranslation(int page_id) { |
| 4005 translate_helper_.RevertTranslation(page_id); | 4061 translate_helper_.RevertTranslation(page_id); |
| 4006 } | 4062 } |
| 4007 | 4063 |
| 4008 void RenderView::OnInstallMissingPlugin() { | 4064 void RenderView::OnInstallMissingPlugin() { |
| 4009 // This could happen when the first default plugin is deleted. | 4065 // This could happen when the first default plugin is deleted. |
| 4010 if (first_default_plugin_) | 4066 if (first_default_plugin_) |
| 4011 first_default_plugin_->InstallMissingPlugin(); | 4067 first_default_plugin_->InstallMissingPlugin(); |
| 4012 } | 4068 } |
| 4013 | 4069 |
| 4070 void RenderView::OnLoadBlockedPlugins() { |
| 4071 NotificationService::current()->Notify(NotificationType::SHOULD_LOAD_PLUGINS, |
| 4072 Source<RenderView>(this), |
| 4073 NotificationService::NoDetails()); |
| 4074 } |
| 4075 |
| 4014 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { | 4076 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { |
| 4015 // This could happen if we navigated to a different page before the user | 4077 // This could happen if we navigated to a different page before the user |
| 4016 // closed the chooser. | 4078 // closed the chooser. |
| 4017 if (file_chooser_completions_.empty()) | 4079 if (file_chooser_completions_.empty()) |
| 4018 return; | 4080 return; |
| 4019 | 4081 |
| 4020 WebVector<WebString> ws_file_names(paths.size()); | 4082 WebVector<WebString> ws_file_names(paths.size()); |
| 4021 for (size_t i = 0; i < paths.size(); ++i) | 4083 for (size_t i = 0; i < paths.size(); ++i) |
| 4022 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); | 4084 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
| 4023 | 4085 |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5346 webkit_glue::FormData form; | 5408 webkit_glue::FormData form; |
| 5347 const WebInputElement element = node.toConst<WebInputElement>(); | 5409 const WebInputElement element = node.toConst<WebInputElement>(); |
| 5348 if (!form_manager_.FindFormWithFormControlElement( | 5410 if (!form_manager_.FindFormWithFormControlElement( |
| 5349 element, FormManager::REQUIRE_NONE, &form)) | 5411 element, FormManager::REQUIRE_NONE, &form)) |
| 5350 return; | 5412 return; |
| 5351 | 5413 |
| 5352 autofill_action_ = action; | 5414 autofill_action_ = action; |
| 5353 Send(new ViewHostMsg_FillAutoFillFormData( | 5415 Send(new ViewHostMsg_FillAutoFillFormData( |
| 5354 routing_id_, autofill_query_id_, form, value, label, unique_id)); | 5416 routing_id_, autofill_query_id_, form, value, label, unique_id)); |
| 5355 } | 5417 } |
| OLD | NEW |