| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #if defined(ENABLE_PEPPER) | 5 #if defined(ENABLE_PEPPER) |
| 6 #define PEPPER_APIS_ENABLED | 6 #define PEPPER_APIS_ENABLED |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "chrome/renderer/render_view.h" | 9 #include "chrome/renderer/render_view.h" |
| 10 | 10 |
| (...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 RenderThread::current()->user_script_slave()->InjectScripts( | 2344 RenderThread::current()->user_script_slave()->InjectScripts( |
| 2345 frame, UserScript::DOCUMENT_IDLE); | 2345 frame, UserScript::DOCUMENT_IDLE); |
| 2346 } | 2346 } |
| 2347 | 2347 |
| 2348 WebFrame* main_frame = webview()->mainFrame(); | 2348 WebFrame* main_frame = webview()->mainFrame(); |
| 2349 if (frame == main_frame) { | 2349 if (frame == main_frame) { |
| 2350 while (!pending_code_execution_queue_.empty()) { | 2350 while (!pending_code_execution_queue_.empty()) { |
| 2351 scoped_refptr<CodeExecutionInfo> info = | 2351 scoped_refptr<CodeExecutionInfo> info = |
| 2352 pending_code_execution_queue_.front(); | 2352 pending_code_execution_queue_.front(); |
| 2353 ExecuteCodeImpl(main_frame, info->request_id, info->extension_id, | 2353 ExecuteCodeImpl(main_frame, info->request_id, info->extension_id, |
| 2354 info->is_js_code, info->code_string); | 2354 info->is_js_code, info->code_string, info->all_frames); |
| 2355 pending_code_execution_queue_.pop(); | 2355 pending_code_execution_queue_.pop(); |
| 2356 } | 2356 } |
| 2357 } | 2357 } |
| 2358 } | 2358 } |
| 2359 | 2359 |
| 2360 void RenderView::didHandleOnloadEvents(WebFrame* frame) { | 2360 void RenderView::didHandleOnloadEvents(WebFrame* frame) { |
| 2361 // Ignore | 2361 // Ignore |
| 2362 } | 2362 } |
| 2363 | 2363 |
| 2364 void RenderView::didFailLoad(WebFrame* frame, const WebURLError& error) { | 2364 void RenderView::didFailLoad(WebFrame* frame, const WebURLError& error) { |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2982 | 2982 |
| 2983 void RenderView::OnSetPageEncoding(const std::string& encoding_name) { | 2983 void RenderView::OnSetPageEncoding(const std::string& encoding_name) { |
| 2984 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); | 2984 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
| 2985 } | 2985 } |
| 2986 | 2986 |
| 2987 void RenderView::OnResetPageEncodingToDefault() { | 2987 void RenderView::OnResetPageEncodingToDefault() { |
| 2988 WebString no_encoding; | 2988 WebString no_encoding; |
| 2989 webview()->setPageEncoding(no_encoding); | 2989 webview()->setPageEncoding(no_encoding); |
| 2990 } | 2990 } |
| 2991 | 2991 |
| 2992 bool RenderView::GetAllChildFrames( |
| 2993 WebFrame* parent_frame, |
| 2994 std::vector<WebFrame*>* frames_vector) const { |
| 2995 if (!parent_frame) |
| 2996 return false; |
| 2997 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
| 2998 child_frame = child_frame->nextSibling()) { |
| 2999 frames_vector->push_back(child_frame); |
| 3000 GetAllChildFrames(child_frame, frames_vector); |
| 3001 } |
| 3002 return true; |
| 3003 } |
| 3004 |
| 2992 WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const { | 3005 WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const { |
| 2993 if (xpath.empty()) | 3006 if (xpath.empty()) |
| 2994 return webview()->mainFrame(); | 3007 return webview()->mainFrame(); |
| 2995 | 3008 |
| 2996 // xpath string can represent a frame deep down the tree (across multiple | 3009 // xpath string can represent a frame deep down the tree (across multiple |
| 2997 // frame DOMs). | 3010 // frame DOMs). |
| 2998 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] | 3011 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] |
| 2999 // should break into 2 xpaths | 3012 // should break into 2 xpaths |
| 3000 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] | 3013 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] |
| 3001 | 3014 |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3763 print_helper_->Print(frame, script_initiated); | 3776 print_helper_->Print(frame, script_initiated); |
| 3764 } | 3777 } |
| 3765 | 3778 |
| 3766 void RenderView::OnSetEditCommandsForNextKeyEvent( | 3779 void RenderView::OnSetEditCommandsForNextKeyEvent( |
| 3767 const EditCommands& edit_commands) { | 3780 const EditCommands& edit_commands) { |
| 3768 edit_commands_ = edit_commands; | 3781 edit_commands_ = edit_commands; |
| 3769 } | 3782 } |
| 3770 | 3783 |
| 3771 void RenderView::OnExecuteCode(int request_id, const std::string& extension_id, | 3784 void RenderView::OnExecuteCode(int request_id, const std::string& extension_id, |
| 3772 bool is_js_code, | 3785 bool is_js_code, |
| 3773 const std::string& code_string) { | 3786 const std::string& code_string, |
| 3787 bool all_frames) { |
| 3774 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 3788 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 3775 if (!main_frame) { | 3789 if (!main_frame) { |
| 3776 Send(new ViewMsg_ExecuteCodeFinished(routing_id_, request_id, false)); | 3790 Send(new ViewMsg_ExecuteCodeFinished(routing_id_, request_id, false)); |
| 3777 return; | 3791 return; |
| 3778 } | 3792 } |
| 3779 | 3793 |
| 3780 WebDataSource* ds = main_frame->dataSource(); | 3794 WebDataSource* ds = main_frame->dataSource(); |
| 3781 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 3795 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 3782 if (!navigation_state->user_script_idle_scheduler()->has_run()) { | 3796 if (!navigation_state->user_script_idle_scheduler()->has_run()) { |
| 3783 scoped_refptr<CodeExecutionInfo> info = new CodeExecutionInfo( | 3797 scoped_refptr<CodeExecutionInfo> info = new CodeExecutionInfo( |
| 3784 request_id, extension_id, is_js_code, code_string); | 3798 request_id, extension_id, is_js_code, code_string, all_frames); |
| 3785 pending_code_execution_queue_.push(info); | 3799 pending_code_execution_queue_.push(info); |
| 3786 return; | 3800 return; |
| 3787 } | 3801 } |
| 3788 | 3802 |
| 3789 ExecuteCodeImpl(main_frame, request_id, extension_id, is_js_code, | 3803 ExecuteCodeImpl(main_frame, request_id, extension_id, is_js_code, |
| 3790 code_string); | 3804 code_string, all_frames); |
| 3791 } | 3805 } |
| 3792 | 3806 |
| 3793 void RenderView::ExecuteCodeImpl(WebFrame* frame, | 3807 void RenderView::ExecuteCodeImpl(WebFrame* frame, |
| 3794 int request_id, | 3808 int request_id, |
| 3795 const std::string& extension_id, | 3809 const std::string& extension_id, |
| 3796 bool is_js_code, | 3810 bool is_js_code, |
| 3797 const std::string& code_string) { | 3811 const std::string& code_string, |
| 3798 if (is_js_code) { | 3812 bool all_frames) { |
| 3799 std::vector<WebScriptSource> sources; | 3813 std::vector<WebFrame*> frame_vector; |
| 3800 sources.push_back( | 3814 frame_vector.push_back(frame); |
| 3801 WebScriptSource(WebString::fromUTF8(code_string))); | 3815 if (all_frames) |
| 3802 UserScriptSlave::InsertInitExtensionCode(&sources, extension_id); | 3816 GetAllChildFrames(frame, &frame_vector); |
| 3803 frame->executeScriptInIsolatedWorld( | 3817 |
| 3804 UserScriptSlave::GetIsolatedWorldId(extension_id), | 3818 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin(); |
| 3805 &sources.front(), sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS); | 3819 frame_it != frame_vector.end(); ++frame_it) { |
| 3806 } else { | 3820 WebFrame* frame = *frame_it; |
| 3807 frame->insertStyleText(WebString::fromUTF8(code_string), WebString()); | 3821 if (is_js_code) { |
| 3822 std::vector<WebScriptSource> sources; |
| 3823 sources.push_back( |
| 3824 WebScriptSource(WebString::fromUTF8(code_string))); |
| 3825 UserScriptSlave::InsertInitExtensionCode(&sources, extension_id); |
| 3826 frame->executeScriptInIsolatedWorld( |
| 3827 UserScriptSlave::GetIsolatedWorldId(extension_id), |
| 3828 &sources.front(), sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS); |
| 3829 } else { |
| 3830 frame->insertStyleText(WebString::fromUTF8(code_string), WebString()); |
| 3831 } |
| 3808 } | 3832 } |
| 3809 | 3833 |
| 3810 Send(new ViewMsg_ExecuteCodeFinished(routing_id_, request_id, true)); | 3834 Send(new ViewMsg_ExecuteCodeFinished(routing_id_, request_id, true)); |
| 3811 } | 3835 } |
| 3812 | 3836 |
| 3813 void RenderView::Close() { | 3837 void RenderView::Close() { |
| 3814 // We need to grab a pointer to the doomed WebView before we destroy it. | 3838 // We need to grab a pointer to the doomed WebView before we destroy it. |
| 3815 WebView* doomed = webview(); | 3839 WebView* doomed = webview(); |
| 3816 RenderWidget::Close(); | 3840 RenderWidget::Close(); |
| 3817 Singleton<ViewMap>::get()->erase(doomed); | 3841 Singleton<ViewMap>::get()->erase(doomed); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3838 new PluginMsg_SignalModalDialogEvent(host_window_)); | 3862 new PluginMsg_SignalModalDialogEvent(host_window_)); |
| 3839 | 3863 |
| 3840 message->EnableMessagePumping(); // Runs a nested message loop. | 3864 message->EnableMessagePumping(); // Runs a nested message loop. |
| 3841 bool rv = Send(message); | 3865 bool rv = Send(message); |
| 3842 | 3866 |
| 3843 PluginChannelHost::Broadcast( | 3867 PluginChannelHost::Broadcast( |
| 3844 new PluginMsg_ResetModalDialogEvent(host_window_)); | 3868 new PluginMsg_ResetModalDialogEvent(host_window_)); |
| 3845 | 3869 |
| 3846 return rv; | 3870 return rv; |
| 3847 } | 3871 } |
| OLD | NEW |