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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 void IntentInjector::SetIntent( | 53 void IntentInjector::SetIntent( |
54 WebIntentsDispatcher* intents_dispatcher, | 54 WebIntentsDispatcher* intents_dispatcher, |
55 const webkit_glue::WebIntentData& intent) { | 55 const webkit_glue::WebIntentData& intent) { |
56 intents_dispatcher_ = intents_dispatcher; | 56 intents_dispatcher_ = intents_dispatcher; |
57 intents_dispatcher_->RegisterReplyNotification( | 57 intents_dispatcher_->RegisterReplyNotification( |
58 base::Bind(&IntentInjector::OnSendReturnMessage, | 58 base::Bind(&IntentInjector::OnSendReturnMessage, |
59 weak_factory_.GetWeakPtr())); | 59 weak_factory_.GetWeakPtr())); |
60 source_intent_.reset(new webkit_glue::WebIntentData(intent)); | 60 source_intent_.reset(new webkit_glue::WebIntentData(intent)); |
61 initial_url_ = web_contents()->GetPendingSiteInstance()->GetSite(); | 61 initial_url_ = web_contents()->GetPendingSiteInstance()->GetSiteURL(); |
62 } | 62 } |
63 | 63 |
64 void IntentInjector::Abandon() { | 64 void IntentInjector::Abandon() { |
65 intents_dispatcher_ = NULL; | 65 intents_dispatcher_ = NULL; |
66 delete this; | 66 delete this; |
67 } | 67 } |
68 | 68 |
69 void IntentInjector::OnSendReturnMessage( | 69 void IntentInjector::OnSendReturnMessage( |
70 webkit_glue::WebIntentReplyType reply_type) { | 70 webkit_glue::WebIntentReplyType reply_type) { |
71 intents_dispatcher_ = NULL; | 71 intents_dispatcher_ = NULL; |
72 } | 72 } |
73 | 73 |
74 void IntentInjector::RenderViewCreated(RenderViewHost* render_view_host) { | 74 void IntentInjector::RenderViewCreated(RenderViewHost* render_view_host) { |
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()->GetSite().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 (source_intent_->data_type == webkit_glue::WebIntentData::BLOB) { |
86 // Grant read permission on the blob file to the delivered context. | 86 // Grant read permission on the blob file to the delivered context. |
87 const int child_id = render_view_host->GetProcess()->GetID(); | 87 const int child_id = render_view_host->GetProcess()->GetID(); |
88 ChildProcessSecurityPolicy* policy = | 88 ChildProcessSecurityPolicy* policy = |
89 ChildProcessSecurityPolicy::GetInstance(); | 89 ChildProcessSecurityPolicy::GetInstance(); |
90 if (!policy->CanReadFile(child_id, source_intent_->blob_file)) | 90 if (!policy->CanReadFile(child_id, source_intent_->blob_file)) |
91 policy->GrantReadFile(child_id, source_intent_->blob_file); | 91 policy->GrantReadFile(child_id, source_intent_->blob_file); |
(...skipping 28 matching lines...) Expand all Loading... |
120 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, | 120 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, |
121 const string16& data) { | 121 const string16& data) { |
122 if (!intents_dispatcher_) | 122 if (!intents_dispatcher_) |
123 return; | 123 return; |
124 | 124 |
125 // Ensure SendReplyMessage is only called once. | 125 // Ensure SendReplyMessage is only called once. |
126 WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; | 126 WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; |
127 intents_dispatcher_ = NULL; | 127 intents_dispatcher_ = NULL; |
128 intents_dispatcher->SendReplyMessage(reply_type, data); | 128 intents_dispatcher->SendReplyMessage(reply_type, data); |
129 } | 129 } |
OLD | NEW |