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 #include "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/gfx/native_widget_types.h" | 12 #include "base/gfx/native_widget_types.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/waitable_event.h" | 15 #include "base/waitable_event.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/child_process_security_policy.h" |
17 #include "chrome/browser/cross_site_request_manager.h" | 18 #include "chrome/browser/cross_site_request_manager.h" |
18 #include "chrome/browser/debugger/debugger_wrapper.h" | 19 #include "chrome/browser/debugger/debugger_wrapper.h" |
19 #include "chrome/browser/debugger/devtools_manager.h" | 20 #include "chrome/browser/debugger/devtools_manager.h" |
20 #include "chrome/browser/extensions/extension_message_service.h" | 21 #include "chrome/browser/extensions/extension_message_service.h" |
21 #include "chrome/browser/metrics/user_metrics.h" | 22 #include "chrome/browser/metrics/user_metrics.h" |
22 #include "chrome/browser/profile.h" | 23 #include "chrome/browser/profile.h" |
23 #include "chrome/browser/renderer_host/renderer_security_policy.h" | |
24 #include "chrome/browser/renderer_host/render_process_host.h" | 24 #include "chrome/browser/renderer_host/render_process_host.h" |
25 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 25 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
26 #include "chrome/browser/renderer_host/render_widget_host.h" | 26 #include "chrome/browser/renderer_host/render_widget_host.h" |
27 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 27 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
28 #include "chrome/browser/tab_contents/navigation_entry.h" | 28 #include "chrome/browser/tab_contents/navigation_entry.h" |
29 #include "chrome/browser/tab_contents/site_instance.h" | 29 #include "chrome/browser/tab_contents/site_instance.h" |
30 #include "chrome/browser/tab_contents/tab_contents.h" | 30 #include "chrome/browser/tab_contents/tab_contents.h" |
31 #include "chrome/common/bindings_policy.h" | 31 #include "chrome/common/bindings_policy.h" |
32 #include "chrome/common/notification_service.h" | 32 #include "chrome/common/notification_service.h" |
33 #include "chrome/common/notification_type.h" | 33 #include "chrome/common/notification_type.h" |
34 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
35 #include "chrome/common/result_codes.h" | 35 #include "chrome/common/result_codes.h" |
36 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
37 #include "chrome/common/thumbnail_score.h" | 37 #include "chrome/common/thumbnail_score.h" |
38 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
39 #include "net/base/net_util.h" | 39 #include "net/base/net_util.h" |
40 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
41 #include "webkit/api/public/WebFindOptions.h" | 41 #include "webkit/api/public/WebFindOptions.h" |
42 #include "webkit/glue/autofill_form.h" | 42 #include "webkit/glue/autofill_form.h" |
43 | 43 |
44 using base::TimeDelta; | 44 using base::TimeDelta; |
45 using WebKit::WebConsoleMessage; | 45 using WebKit::WebConsoleMessage; |
46 using WebKit::WebFindOptions; | 46 using WebKit::WebFindOptions; |
47 using WebKit::WebInputEvent; | 47 using WebKit::WebInputEvent; |
48 | 48 |
49 namespace { | 49 namespace { |
50 | 50 |
51 void FilterURL(RendererSecurityPolicy* policy, int renderer_id, GURL* url) { | 51 void FilterURL(ChildProcessSecurityPolicy* policy, int renderer_id, GURL* url) { |
52 if (!url->is_valid()) | 52 if (!url->is_valid()) |
53 return; // We don't need to block invalid URLs. | 53 return; // We don't need to block invalid URLs. |
54 | 54 |
55 if (url->SchemeIs(chrome::kAboutScheme)) { | 55 if (url->SchemeIs(chrome::kAboutScheme)) { |
56 // The renderer treats all URLs in the about: scheme as being about:blank. | 56 // The renderer treats all URLs in the about: scheme as being about:blank. |
57 // Canonicalize about: URLs to about:blank. | 57 // Canonicalize about: URLs to about:blank. |
58 *url = GURL(chrome::kAboutBlankURL); | 58 *url = GURL(chrome::kAboutBlankURL); |
59 } | 59 } |
60 | 60 |
61 if (!policy->CanRequestURL(renderer_id, *url)) { | 61 if (!policy->CanRequestURL(renderer_id, *url)) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // The process may (if we're sharing a process with another host that already | 133 // The process may (if we're sharing a process with another host that already |
134 // initialized it) or may not (we have our own process or the old process | 134 // initialized it) or may not (we have our own process or the old process |
135 // crashed) have been initialized. Calling Init multiple times will be | 135 // crashed) have been initialized. Calling Init multiple times will be |
136 // ignored, so this is safe. | 136 // ignored, so this is safe. |
137 if (!process()->Init()) | 137 if (!process()->Init()) |
138 return false; | 138 return false; |
139 DCHECK(process()->channel()); | 139 DCHECK(process()->channel()); |
140 DCHECK(process()->profile()); | 140 DCHECK(process()->profile()); |
141 | 141 |
142 if (enabled_bindings_ & BindingsPolicy::DOM_UI) { | 142 if (enabled_bindings_ & BindingsPolicy::DOM_UI) { |
143 RendererSecurityPolicy::GetInstance()->GrantDOMUIBindings( | 143 ChildProcessSecurityPolicy::GetInstance()->GrantDOMUIBindings( |
144 process()->pid()); | 144 process()->pid()); |
145 } | 145 } |
146 | 146 |
147 renderer_initialized_ = true; | 147 renderer_initialized_ = true; |
148 | 148 |
149 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
150 HANDLE modal_dialog_event_handle; | 150 HANDLE modal_dialog_event_handle; |
151 HANDLE renderer_process_handle = process()->process().handle(); | 151 HANDLE renderer_process_handle = process()->process().handle(); |
152 if (renderer_process_handle == NULL) | 152 if (renderer_process_handle == NULL) |
153 renderer_process_handle = GetCurrentProcess(); | 153 renderer_process_handle = GetCurrentProcess(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 bool RenderViewHost::IsRenderViewLive() const { | 190 bool RenderViewHost::IsRenderViewLive() const { |
191 return process()->channel() && renderer_initialized_; | 191 return process()->channel() && renderer_initialized_; |
192 } | 192 } |
193 | 193 |
194 void RenderViewHost::NavigateToEntry(const NavigationEntry& entry, | 194 void RenderViewHost::NavigateToEntry(const NavigationEntry& entry, |
195 bool is_reload) { | 195 bool is_reload) { |
196 ViewMsg_Navigate_Params params; | 196 ViewMsg_Navigate_Params params; |
197 MakeNavigateParams(entry, is_reload, ¶ms); | 197 MakeNavigateParams(entry, is_reload, ¶ms); |
198 | 198 |
199 RendererSecurityPolicy::GetInstance()->GrantRequestURL( | 199 ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( |
200 process()->pid(), params.url); | 200 process()->pid(), params.url); |
201 | 201 |
202 DoNavigate(entry.url(), new ViewMsg_Navigate(routing_id(), params)); | 202 DoNavigate(entry.url(), new ViewMsg_Navigate(routing_id(), params)); |
203 } | 203 } |
204 | 204 |
205 void RenderViewHost::NavigateToURL(const GURL& url) { | 205 void RenderViewHost::NavigateToURL(const GURL& url) { |
206 ViewMsg_Navigate_Params params; | 206 ViewMsg_Navigate_Params params; |
207 params.page_id = -1; | 207 params.page_id = -1; |
208 params.url = url; | 208 params.url = url; |
209 params.transition = PageTransition::LINK; | 209 params.transition = PageTransition::LINK; |
210 params.reload = false; | 210 params.reload = false; |
211 | 211 |
212 RendererSecurityPolicy::GetInstance()->GrantRequestURL( | 212 ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( |
213 process()->pid(), params.url); | 213 process()->pid(), params.url); |
214 | 214 |
215 DoNavigate(url, new ViewMsg_Navigate(routing_id(), params)); | 215 DoNavigate(url, new ViewMsg_Navigate(routing_id(), params)); |
216 } | 216 } |
217 | 217 |
218 void RenderViewHost::DoNavigate(const GURL& url, | 218 void RenderViewHost::DoNavigate(const GURL& url, |
219 ViewMsg_Navigate* nav_message) { | 219 ViewMsg_Navigate* nav_message) { |
220 // Only send the message if we aren't suspended at the start of a cross-site | 220 // Only send the message if we aren't suspended at the start of a cross-site |
221 // request. | 221 // request. |
222 if (navigations_suspended_) { | 222 if (navigations_suspended_) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 void RenderViewHost::FillPasswordForm( | 389 void RenderViewHost::FillPasswordForm( |
390 const PasswordFormDomManager::FillData& form_data) { | 390 const PasswordFormDomManager::FillData& form_data) { |
391 Send(new ViewMsg_FillPasswordForm(routing_id(), form_data)); | 391 Send(new ViewMsg_FillPasswordForm(routing_id(), form_data)); |
392 } | 392 } |
393 | 393 |
394 void RenderViewHost::DragTargetDragEnter( | 394 void RenderViewHost::DragTargetDragEnter( |
395 const WebDropData& drop_data, | 395 const WebDropData& drop_data, |
396 const gfx::Point& client_pt, | 396 const gfx::Point& client_pt, |
397 const gfx::Point& screen_pt) { | 397 const gfx::Point& screen_pt) { |
398 // Grant the renderer the ability to load the drop_data. | 398 // Grant the renderer the ability to load the drop_data. |
399 RendererSecurityPolicy* policy = RendererSecurityPolicy::GetInstance(); | 399 ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance()
; |
400 policy->GrantRequestURL(process()->pid(), drop_data.url); | 400 policy->GrantRequestURL(process()->pid(), drop_data.url); |
401 for (std::vector<string16>::const_iterator iter(drop_data.filenames.begin()); | 401 for (std::vector<string16>::const_iterator iter(drop_data.filenames.begin()); |
402 iter != drop_data.filenames.end(); ++iter) { | 402 iter != drop_data.filenames.end(); ++iter) { |
403 FilePath path = FilePath::FromWStringHack(UTF16ToWideHack(*iter)); | 403 FilePath path = FilePath::FromWStringHack(UTF16ToWideHack(*iter)); |
404 policy->GrantRequestURL(process()->pid(), net::FilePathToFileURL(path)); | 404 policy->GrantRequestURL(process()->pid(), net::FilePathToFileURL(path)); |
405 policy->GrantUploadFile(process()->pid(), path); | 405 policy->GrantUploadFile(process()->pid(), path); |
406 } | 406 } |
407 Send(new ViewMsg_DragTargetDragEnter(routing_id(), drop_data, client_pt, | 407 Send(new ViewMsg_DragTargetDragEnter(routing_id(), drop_data, client_pt, |
408 screen_pt)); | 408 screen_pt)); |
409 } | 409 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 void RenderViewHost::CopyImageAt(int x, int y) { | 561 void RenderViewHost::CopyImageAt(int x, int y) { |
562 Send(new ViewMsg_CopyImageAt(routing_id(), x, y)); | 562 Send(new ViewMsg_CopyImageAt(routing_id(), x, y)); |
563 } | 563 } |
564 | 564 |
565 void RenderViewHost::InspectElementAt(int x, int y) { | 565 void RenderViewHost::InspectElementAt(int x, int y) { |
566 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 566 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
567 switches::kDisableOutOfProcessDevTools)) { | 567 switches::kDisableOutOfProcessDevTools)) { |
568 DevToolsManager* manager = g_browser_process->devtools_manager(); | 568 DevToolsManager* manager = g_browser_process->devtools_manager(); |
569 manager->InspectElement(this, x, y); | 569 manager->InspectElement(this, x, y); |
570 } else { | 570 } else { |
571 RendererSecurityPolicy::GetInstance()-> | 571 ChildProcessSecurityPolicy::GetInstance()-> |
572 GrantInspectElement(process()->pid()); | 572 GrantInspectElement(process()->pid()); |
573 Send(new ViewMsg_InspectElement(routing_id(), x, y)); | 573 Send(new ViewMsg_InspectElement(routing_id(), x, y)); |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 void RenderViewHost::ShowJavaScriptConsole() { | 577 void RenderViewHost::ShowJavaScriptConsole() { |
578 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 578 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
579 switches::kDisableOutOfProcessDevTools)) { | 579 switches::kDisableOutOfProcessDevTools)) { |
580 DevToolsManager* manager = g_browser_process->devtools_manager(); | 580 DevToolsManager* manager = g_browser_process->devtools_manager(); |
581 manager->OpenDevToolsWindow(this); | 581 manager->OpenDevToolsWindow(this); |
582 } else { | 582 } else { |
583 RendererSecurityPolicy::GetInstance()-> | 583 ChildProcessSecurityPolicy::GetInstance()-> |
584 GrantInspectElement(process()->pid()); | 584 GrantInspectElement(process()->pid()); |
585 Send(new ViewMsg_ShowJavaScriptConsole(routing_id())); | 585 Send(new ViewMsg_ShowJavaScriptConsole(routing_id())); |
586 } | 586 } |
587 } | 587 } |
588 | 588 |
589 void RenderViewHost::DragSourceEndedAt( | 589 void RenderViewHost::DragSourceEndedAt( |
590 int client_x, int client_y, int screen_x, int screen_y) { | 590 int client_x, int client_y, int screen_x, int screen_y) { |
591 Send(new ViewMsg_DragSourceEndedOrMoved( | 591 Send(new ViewMsg_DragSourceEndedOrMoved( |
592 routing_id(), | 592 routing_id(), |
593 gfx::Point(client_x, client_y), | 593 gfx::Point(client_x, client_y), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 | 661 |
662 void RenderViewHost::UpdateWebPreferences(const WebPreferences& prefs) { | 662 void RenderViewHost::UpdateWebPreferences(const WebPreferences& prefs) { |
663 Send(new ViewMsg_UpdateWebPreferences(routing_id(), prefs)); | 663 Send(new ViewMsg_UpdateWebPreferences(routing_id(), prefs)); |
664 } | 664 } |
665 | 665 |
666 void RenderViewHost::InstallMissingPlugin() { | 666 void RenderViewHost::InstallMissingPlugin() { |
667 Send(new ViewMsg_InstallMissingPlugin(routing_id())); | 667 Send(new ViewMsg_InstallMissingPlugin(routing_id())); |
668 } | 668 } |
669 | 669 |
670 void RenderViewHost::FileSelected(const FilePath& path) { | 670 void RenderViewHost::FileSelected(const FilePath& path) { |
671 RendererSecurityPolicy::GetInstance()->GrantUploadFile(process()->pid(), | 671 ChildProcessSecurityPolicy::GetInstance()->GrantUploadFile(process()->pid(), |
672 path); | 672 path); |
673 std::vector<FilePath> files; | 673 std::vector<FilePath> files; |
674 files.push_back(path); | 674 files.push_back(path); |
675 Send(new ViewMsg_RunFileChooserResponse(routing_id(), files)); | 675 Send(new ViewMsg_RunFileChooserResponse(routing_id(), files)); |
676 } | 676 } |
677 | 677 |
678 void RenderViewHost::MultiFilesSelected( | 678 void RenderViewHost::MultiFilesSelected( |
679 const std::vector<FilePath>& files) { | 679 const std::vector<FilePath>& files) { |
680 for (std::vector<FilePath>::const_iterator file = files.begin(); | 680 for (std::vector<FilePath>::const_iterator file = files.begin(); |
681 file != files.end(); ++file) { | 681 file != files.end(); ++file) { |
682 RendererSecurityPolicy::GetInstance()->GrantUploadFile( | 682 ChildProcessSecurityPolicy::GetInstance()->GrantUploadFile( |
683 process()->pid(), *file); | 683 process()->pid(), *file); |
684 } | 684 } |
685 Send(new ViewMsg_RunFileChooserResponse(routing_id(), files)); | 685 Send(new ViewMsg_RunFileChooserResponse(routing_id(), files)); |
686 } | 686 } |
687 | 687 |
688 void RenderViewHost::LoadStateChanged(const GURL& url, | 688 void RenderViewHost::LoadStateChanged(const GURL& url, |
689 net::LoadState load_state) { | 689 net::LoadState load_state) { |
690 delegate_->LoadStateChanged(url, load_state); | 690 delegate_->LoadStateChanged(url, load_state); |
691 } | 691 } |
692 | 692 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) { | 899 void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) { |
900 // Read the parameters out of the IPC message directly to avoid making another | 900 // Read the parameters out of the IPC message directly to avoid making another |
901 // copy when we filter the URLs. | 901 // copy when we filter the URLs. |
902 void* iter = NULL; | 902 void* iter = NULL; |
903 ViewHostMsg_FrameNavigate_Params validated_params; | 903 ViewHostMsg_FrameNavigate_Params validated_params; |
904 if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>:: | 904 if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>:: |
905 Read(&msg, &iter, &validated_params)) | 905 Read(&msg, &iter, &validated_params)) |
906 return; | 906 return; |
907 | 907 |
908 const int renderer_id = process()->pid(); | 908 const int renderer_id = process()->pid(); |
909 RendererSecurityPolicy* policy = RendererSecurityPolicy::GetInstance(); | 909 ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance()
; |
910 // Without this check, an evil renderer can trick the browser into creating | 910 // Without this check, an evil renderer can trick the browser into creating |
911 // a navigation entry for a banned URL. If the user clicks the back button | 911 // a navigation entry for a banned URL. If the user clicks the back button |
912 // followed by the forward button (or clicks reload, or round-trips through | 912 // followed by the forward button (or clicks reload, or round-trips through |
913 // session restore, etc), we'll think that the browser commanded the | 913 // session restore, etc), we'll think that the browser commanded the |
914 // renderer to load the URL and grant the renderer the privileges to request | 914 // renderer to load the URL and grant the renderer the privileges to request |
915 // the URL. To prevent this attack, we block the renderer from inserting | 915 // the URL. To prevent this attack, we block the renderer from inserting |
916 // banned URLs into the navigation controller in the first place. | 916 // banned URLs into the navigation controller in the first place. |
917 FilterURL(policy, renderer_id, &validated_params.url); | 917 FilterURL(policy, renderer_id, &validated_params.url); |
918 FilterURL(policy, renderer_id, &validated_params.referrer); | 918 FilterURL(policy, renderer_id, &validated_params.referrer); |
919 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); | 919 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 const std::string& frame_origin, | 995 const std::string& frame_origin, |
996 const std::string& main_frame_origin, | 996 const std::string& main_frame_origin, |
997 const std::string& security_info) { | 997 const std::string& security_info) { |
998 delegate_->DidLoadResourceFromMemoryCache( | 998 delegate_->DidLoadResourceFromMemoryCache( |
999 url, frame_origin, main_frame_origin, security_info); | 999 url, frame_origin, main_frame_origin, security_info); |
1000 } | 1000 } |
1001 | 1001 |
1002 void RenderViewHost::OnMsgDidStartProvisionalLoadForFrame(bool is_main_frame, | 1002 void RenderViewHost::OnMsgDidStartProvisionalLoadForFrame(bool is_main_frame, |
1003 const GURL& url) { | 1003 const GURL& url) { |
1004 GURL validated_url(url); | 1004 GURL validated_url(url); |
1005 FilterURL(RendererSecurityPolicy::GetInstance(), | 1005 FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
1006 process()->pid(), &validated_url); | 1006 process()->pid(), &validated_url); |
1007 | 1007 |
1008 delegate_->DidStartProvisionalLoadForFrame(this, is_main_frame, | 1008 delegate_->DidStartProvisionalLoadForFrame(this, is_main_frame, |
1009 validated_url); | 1009 validated_url); |
1010 } | 1010 } |
1011 | 1011 |
1012 void RenderViewHost::OnMsgDidFailProvisionalLoadWithError( | 1012 void RenderViewHost::OnMsgDidFailProvisionalLoadWithError( |
1013 bool is_main_frame, | 1013 bool is_main_frame, |
1014 int error_code, | 1014 int error_code, |
1015 const GURL& url, | 1015 const GURL& url, |
1016 bool showing_repost_interstitial) { | 1016 bool showing_repost_interstitial) { |
1017 GURL validated_url(url); | 1017 GURL validated_url(url); |
1018 FilterURL(RendererSecurityPolicy::GetInstance(), | 1018 FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
1019 process()->pid(), &validated_url); | 1019 process()->pid(), &validated_url); |
1020 | 1020 |
1021 delegate_->DidFailProvisionalLoadWithError(this, is_main_frame, | 1021 delegate_->DidFailProvisionalLoadWithError(this, is_main_frame, |
1022 error_code, validated_url, | 1022 error_code, validated_url, |
1023 showing_repost_interstitial); | 1023 showing_repost_interstitial); |
1024 } | 1024 } |
1025 | 1025 |
1026 void RenderViewHost::OnMsgFindReply(int request_id, | 1026 void RenderViewHost::OnMsgFindReply(int request_id, |
1027 int number_of_matches, | 1027 int number_of_matches, |
1028 const gfx::Rect& selection_rect, | 1028 const gfx::Rect& selection_rect, |
(...skipping 26 matching lines...) Expand all Loading... |
1055 | 1055 |
1056 void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { | 1056 void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { |
1057 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1057 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
1058 if (!view) | 1058 if (!view) |
1059 return; | 1059 return; |
1060 | 1060 |
1061 // Validate the URLs in |params|. If the renderer can't request the URLs | 1061 // Validate the URLs in |params|. If the renderer can't request the URLs |
1062 // directly, don't show them in the context menu. | 1062 // directly, don't show them in the context menu. |
1063 ContextMenuParams validated_params(params); | 1063 ContextMenuParams validated_params(params); |
1064 const int renderer_id = process()->pid(); | 1064 const int renderer_id = process()->pid(); |
1065 RendererSecurityPolicy* policy = RendererSecurityPolicy::GetInstance(); | 1065 ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance()
; |
1066 | 1066 |
1067 // We don't validate |unfiltered_link_url| so that this field can be used | 1067 // We don't validate |unfiltered_link_url| so that this field can be used |
1068 // when users want to copy the original link URL. | 1068 // when users want to copy the original link URL. |
1069 FilterURL(policy, renderer_id, &validated_params.link_url); | 1069 FilterURL(policy, renderer_id, &validated_params.link_url); |
1070 FilterURL(policy, renderer_id, &validated_params.image_url); | 1070 FilterURL(policy, renderer_id, &validated_params.image_url); |
1071 FilterURL(policy, renderer_id, &validated_params.page_url); | 1071 FilterURL(policy, renderer_id, &validated_params.page_url); |
1072 FilterURL(policy, renderer_id, &validated_params.frame_url); | 1072 FilterURL(policy, renderer_id, &validated_params.frame_url); |
1073 | 1073 |
1074 view->ShowContextMenu(validated_params); | 1074 view->ShowContextMenu(validated_params); |
1075 } | 1075 } |
1076 | 1076 |
1077 void RenderViewHost::OnMsgOpenURL(const GURL& url, | 1077 void RenderViewHost::OnMsgOpenURL(const GURL& url, |
1078 const GURL& referrer, | 1078 const GURL& referrer, |
1079 WindowOpenDisposition disposition) { | 1079 WindowOpenDisposition disposition) { |
1080 GURL validated_url(url); | 1080 GURL validated_url(url); |
1081 FilterURL(RendererSecurityPolicy::GetInstance(), | 1081 FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
1082 process()->pid(), &validated_url); | 1082 process()->pid(), &validated_url); |
1083 | 1083 |
1084 delegate_->RequestOpenURL(validated_url, referrer, disposition); | 1084 delegate_->RequestOpenURL(validated_url, referrer, disposition); |
1085 } | 1085 } |
1086 | 1086 |
1087 void RenderViewHost::OnMsgDidContentsPreferredWidthChange(int pref_width) { | 1087 void RenderViewHost::OnMsgDidContentsPreferredWidthChange(int pref_width) { |
1088 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1088 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
1089 if (!view) | 1089 if (!view) |
1090 return; | 1090 return; |
1091 view->UpdatePreferredWidth(pref_width); | 1091 view->UpdatePreferredWidth(pref_width); |
1092 } | 1092 } |
1093 | 1093 |
1094 void RenderViewHost::OnMsgDomOperationResponse( | 1094 void RenderViewHost::OnMsgDomOperationResponse( |
1095 const std::string& json_string, int automation_id) { | 1095 const std::string& json_string, int automation_id) { |
1096 delegate_->DomOperationResponse(json_string, automation_id); | 1096 delegate_->DomOperationResponse(json_string, automation_id); |
1097 } | 1097 } |
1098 | 1098 |
1099 void RenderViewHost::OnMsgDOMUISend( | 1099 void RenderViewHost::OnMsgDOMUISend( |
1100 const std::string& message, const std::string& content) { | 1100 const std::string& message, const std::string& content) { |
1101 if (!RendererSecurityPolicy::GetInstance()-> | 1101 if (!ChildProcessSecurityPolicy::GetInstance()-> |
1102 HasDOMUIBindings(process()->pid())) { | 1102 HasDOMUIBindings(process()->pid())) { |
1103 NOTREACHED() << "Blocked unauthorized use of DOMUIBindings."; | 1103 NOTREACHED() << "Blocked unauthorized use of DOMUIBindings."; |
1104 return; | 1104 return; |
1105 } | 1105 } |
1106 delegate_->ProcessDOMUIMessage(message, content); | 1106 delegate_->ProcessDOMUIMessage(message, content); |
1107 } | 1107 } |
1108 | 1108 |
1109 void RenderViewHost::OnMsgForwardMessageToExternalHost( | 1109 void RenderViewHost::OnMsgForwardMessageToExternalHost( |
1110 const std::string& message, const std::string& origin, | 1110 const std::string& message, const std::string& origin, |
1111 const std::string& target) { | 1111 const std::string& target) { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success, | 1405 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success, |
1406 response, error)); | 1406 response, error)); |
1407 } | 1407 } |
1408 | 1408 |
1409 void RenderViewHost::OnExtensionPostMessage( | 1409 void RenderViewHost::OnExtensionPostMessage( |
1410 int port_id, const std::string& message) { | 1410 int port_id, const std::string& message) { |
1411 URLRequestContext* context = process()->profile()->GetRequestContext(); | 1411 URLRequestContext* context = process()->profile()->GetRequestContext(); |
1412 ExtensionMessageService::GetInstance(context)-> | 1412 ExtensionMessageService::GetInstance(context)-> |
1413 PostMessageFromRenderer(port_id, message); | 1413 PostMessageFromRenderer(port_id, message); |
1414 } | 1414 } |
OLD | NEW |