Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: content/browser/intents/intent_injector.cc

Issue 10713007: Make isolated file system works for a device root (e.g. X:\\) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "content/browser/child_process_security_policy_impl.h" 13 #include "content/browser/child_process_security_policy_impl.h"
14 #include "content/browser/intents/web_intents_dispatcher_impl.h" 14 #include "content/browser/intents/web_intents_dispatcher_impl.h"
15 #include "content/browser/renderer_host/render_process_host_impl.h" 15 #include "content/browser/renderer_host/render_process_host_impl.h"
16 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
17 #include "content/browser/web_contents/web_contents_impl.h" 17 #include "content/browser/web_contents/web_contents_impl.h"
18 #include "content/common/intents_messages.h" 18 #include "content/common/intents_messages.h"
19 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
20 #include "webkit/fileapi/file_system_util.h" 20 #include "webkit/fileapi/file_system_util.h"
21 #include "webkit/fileapi/isolated_context.h"
21 #include "webkit/glue/web_intent_data.h" 22 #include "webkit/glue/web_intent_data.h"
22 #include "webkit/glue/web_intent_reply_data.h" 23 #include "webkit/glue/web_intent_reply_data.h"
23 24
24 using content::ChildProcessSecurityPolicy; 25 using content::ChildProcessSecurityPolicy;
25 using content::RenderViewHost; 26 using content::RenderViewHost;
26 using content::WebContents; 27 using content::WebContents;
27 using content::WebIntentsDispatcher; 28 using content::WebIntentsDispatcher;
28 29
29 IntentInjector::IntentInjector(WebContents* web_contents) 30 IntentInjector::IntentInjector(WebContents* web_contents)
30 : content::WebContentsObserver(web_contents), 31 : content::WebContentsObserver(web_contents),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (source_intent_->data_type == webkit_glue::WebIntentData::BLOB) { 85 if (source_intent_->data_type == webkit_glue::WebIntentData::BLOB) {
85 // Grant read permission on the blob file to the delivered context. 86 // Grant read permission on the blob file to the delivered context.
86 const int child_id = render_view_host->GetProcess()->GetID(); 87 const int child_id = render_view_host->GetProcess()->GetID();
87 ChildProcessSecurityPolicy* policy = 88 ChildProcessSecurityPolicy* policy =
88 ChildProcessSecurityPolicy::GetInstance(); 89 ChildProcessSecurityPolicy::GetInstance();
89 if (!policy->CanReadFile(child_id, source_intent_->blob_file)) 90 if (!policy->CanReadFile(child_id, source_intent_->blob_file))
90 policy->GrantReadFile(child_id, source_intent_->blob_file); 91 policy->GrantReadFile(child_id, source_intent_->blob_file);
91 } else if (source_intent_->data_type == 92 } else if (source_intent_->data_type ==
92 webkit_glue::WebIntentData::FILESYSTEM) { 93 webkit_glue::WebIntentData::FILESYSTEM) {
93 const int child_id = render_view_host->GetProcess()->GetID(); 94 const int child_id = render_view_host->GetProcess()->GetID();
95 std::vector<fileapi::IsolatedContext::FileInfo> files;
96 const bool valid =
97 fileapi::IsolatedContext::GetInstance()->GetRegisteredFileInfo(
98 source_intent_->filesystem_id, &files);
99 DCHECK(valid);
100 DCHECK_EQ(1U, files.size());
94 ChildProcessSecurityPolicy* policy = 101 ChildProcessSecurityPolicy* policy =
95 ChildProcessSecurityPolicy::GetInstance(); 102 ChildProcessSecurityPolicy::GetInstance();
96 if (!policy->CanReadFile(child_id, source_intent_->root_path)) 103 if (!policy->CanReadFile(child_id, files[0].path))
97 policy->GrantReadFile(child_id, source_intent_->root_path); 104 policy->GrantReadFile(child_id, files[0].path);
98 policy->GrantReadFileSystem(child_id, source_intent_->filesystem_id); 105 policy->GrantReadFileSystem(child_id, source_intent_->filesystem_id);
99 } 106 }
100 107
101 render_view_host->Send(new IntentsMsg_SetWebIntentData( 108 render_view_host->Send(new IntentsMsg_SetWebIntentData(
102 render_view_host->GetRoutingID(), *(source_intent_.get()))); 109 render_view_host->GetRoutingID(), *(source_intent_.get())));
103 } 110 }
104 111
105 bool IntentInjector::OnMessageReceived(const IPC::Message& message) { 112 bool IntentInjector::OnMessageReceived(const IPC::Message& message) {
106 bool handled = true; 113 bool handled = true;
107 IPC_BEGIN_MESSAGE_MAP(IntentInjector, message) 114 IPC_BEGIN_MESSAGE_MAP(IntentInjector, message)
108 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply); 115 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply);
109 IPC_MESSAGE_UNHANDLED(handled = false) 116 IPC_MESSAGE_UNHANDLED(handled = false)
110 IPC_END_MESSAGE_MAP() 117 IPC_END_MESSAGE_MAP()
111 return handled; 118 return handled;
112 } 119 }
113 120
114 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, 121 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type,
115 const string16& data) { 122 const string16& data) {
116 if (!intents_dispatcher_) 123 if (!intents_dispatcher_)
117 return; 124 return;
118 125
119 // Ensure SendReplyMessage is only called once. 126 // Ensure SendReplyMessage is only called once.
120 WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; 127 WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_;
121 intents_dispatcher_ = NULL; 128 intents_dispatcher_ = NULL;
122 intents_dispatcher->SendReplyMessage(reply_type, data); 129 intents_dispatcher->SendReplyMessage(reply_type, data);
123 } 130 }
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/media_file_system_registry.cc ('k') | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698