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/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 if (source_intent_.get() == NULL || !web_contents()->GetRenderViewHost()) | 75 if (source_intent_.get() == NULL || !web_contents()->GetRenderViewHost()) |
76 return; | 76 return; |
77 | 77 |
78 // Only deliver the intent to the renderer if it has the same origin | 78 // Only deliver the intent to the renderer if it has the same origin |
79 // as the initial delivery target. | 79 // as the initial delivery target. |
80 if (initial_url_.GetOrigin() != | 80 if (initial_url_.GetOrigin() != |
81 render_view_host->GetSiteInstance()->GetSiteURL().GetOrigin()) { | 81 render_view_host->GetSiteInstance()->GetSiteURL().GetOrigin()) { |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 if (source_intent_->data_type == webkit_glue::WebIntentData::BLOB) { | 85 // If we're passing a browser-originated blob, either directly or as part of a |
86 // Grant read permission on the blob file to the delivered context. | 86 // payload, grant read permission on the blob file to the delivered context. |
| 87 if (source_intent_->data_type == webkit_glue::WebIntentData::BLOB || |
| 88 (source_intent_->data_type == webkit_glue::WebIntentData::MIME_TYPE && |
| 89 !source_intent_->blob_file.empty())) { |
87 const int child_id = render_view_host->GetProcess()->GetID(); | 90 const int child_id = render_view_host->GetProcess()->GetID(); |
88 ChildProcessSecurityPolicy* policy = | 91 ChildProcessSecurityPolicy* policy = |
89 ChildProcessSecurityPolicy::GetInstance(); | 92 ChildProcessSecurityPolicy::GetInstance(); |
90 if (!policy->CanReadFile(child_id, source_intent_->blob_file)) | 93 if (!policy->CanReadFile(child_id, source_intent_->blob_file)) |
91 policy->GrantReadFile(child_id, source_intent_->blob_file); | 94 policy->GrantReadFile(child_id, source_intent_->blob_file); |
92 } else if (source_intent_->data_type == | 95 } else if (source_intent_->data_type == |
93 webkit_glue::WebIntentData::FILESYSTEM) { | 96 webkit_glue::WebIntentData::FILESYSTEM) { |
94 const int child_id = render_view_host->GetProcess()->GetID(); | 97 const int child_id = render_view_host->GetProcess()->GetID(); |
95 FilePath path; | 98 FilePath path; |
96 const bool valid = | 99 const bool valid = |
(...skipping 23 matching lines...) Expand all Loading... |
120 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, | 123 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, |
121 const string16& data) { | 124 const string16& data) { |
122 if (!intents_dispatcher_) | 125 if (!intents_dispatcher_) |
123 return; | 126 return; |
124 | 127 |
125 // Ensure SendReplyMessage is only called once. | 128 // Ensure SendReplyMessage is only called once. |
126 WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; | 129 WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; |
127 intents_dispatcher_ = NULL; | 130 intents_dispatcher_ = NULL; |
128 intents_dispatcher->SendReplyMessage(reply_type, data); | 131 intents_dispatcher->SendReplyMessage(reply_type, data); |
129 } | 132 } |
OLD | NEW |