OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/intents/intent_injector.h" | 5 #include "content/browser/intents/intent_injector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "content/browser/child_process_security_policy_impl.h" | |
11 #include "content/browser/renderer_host/render_view_host_impl.h" | 13 #include "content/browser/renderer_host/render_view_host_impl.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 14 #include "content/browser/tab_contents/tab_contents.h" |
13 #include "content/common/intents_messages.h" | 15 #include "content/common/intents_messages.h" |
14 #include "content/public/browser/web_intents_dispatcher.h" | 16 #include "content/public/browser/web_intents_dispatcher.h" |
15 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
16 #include "webkit/glue/web_intent_data.h" | 18 #include "webkit/glue/web_intent_data.h" |
17 #include "webkit/glue/web_intent_reply_data.h" | 19 #include "webkit/glue/web_intent_reply_data.h" |
18 | 20 |
19 using content::RenderViewHost; | 21 using content::RenderViewHost; |
20 using content::WebContents; | 22 using content::WebContents; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 } | 58 } |
57 | 59 |
58 void IntentInjector::RenderViewCreated(RenderViewHost* render_view_host) { | 60 void IntentInjector::RenderViewCreated(RenderViewHost* render_view_host) { |
59 if (source_intent_.get() == NULL || | 61 if (source_intent_.get() == NULL || |
60 CommandLine::ForCurrentProcess()->HasSwitch( | 62 CommandLine::ForCurrentProcess()->HasSwitch( |
61 switches::kDisableWebIntents) || | 63 switches::kDisableWebIntents) || |
62 web_contents()->GetRenderViewHost() == NULL) { | 64 web_contents()->GetRenderViewHost() == NULL) { |
63 return; | 65 return; |
64 } | 66 } |
65 | 67 |
68 if (source_intent_->data_type == webkit_glue::WebIntentData::BLOB) { | |
69 // Grant read permission on the blob file to the delivered context. | |
70 ChildProcessSecurityPolicyImpl* policy = | |
71 ChildProcessSecurityPolicyImpl::GetInstance(); | |
72 int child_id = render_view_host->GetProcess()->GetID(); | |
73 policy->GrantReadFile(child_id, | |
michaeln
2012/03/29 20:51:57
are read rights ever revoked, should they be at so
Greg Billock
2012/03/29 21:04:45
I should do that when the injector is destroyed? I
| |
74 FilePath::FromUTF8Unsafe(source_intent_->blob_file)); | |
75 } | |
76 | |
66 render_view_host->Send(new IntentsMsg_SetWebIntentData( | 77 render_view_host->Send(new IntentsMsg_SetWebIntentData( |
67 render_view_host->GetRoutingID(), *(source_intent_.get()))); | 78 render_view_host->GetRoutingID(), *(source_intent_.get()))); |
68 } | 79 } |
69 | 80 |
70 bool IntentInjector::OnMessageReceived(const IPC::Message& message) { | 81 bool IntentInjector::OnMessageReceived(const IPC::Message& message) { |
71 bool handled = true; | 82 bool handled = true; |
72 IPC_BEGIN_MESSAGE_MAP(IntentInjector, message) | 83 IPC_BEGIN_MESSAGE_MAP(IntentInjector, message) |
73 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply); | 84 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply); |
74 IPC_MESSAGE_UNHANDLED(handled = false) | 85 IPC_MESSAGE_UNHANDLED(handled = false) |
75 IPC_END_MESSAGE_MAP() | 86 IPC_END_MESSAGE_MAP() |
76 return handled; | 87 return handled; |
77 } | 88 } |
78 | 89 |
79 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, | 90 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, |
80 const string16& data) { | 91 const string16& data) { |
81 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWebIntents)) | 92 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWebIntents)) |
82 NOTREACHED(); | 93 NOTREACHED(); |
83 | 94 |
84 if (intents_dispatcher_) { | 95 if (intents_dispatcher_) { |
85 // Ensure we only call SendReplyMessage once. | 96 // Ensure we only call SendReplyMessage once. |
86 content::WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; | 97 content::WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; |
87 intents_dispatcher_ = NULL; | 98 intents_dispatcher_ = NULL; |
88 intents_dispatcher->SendReplyMessage(reply_type, data); | 99 intents_dispatcher->SendReplyMessage(reply_type, data); |
89 } | 100 } |
90 } | 101 } |
OLD | NEW |