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

Side by Side Diff: content/browser/file_system/file_system_dispatcher_host.cc

Issue 7012007: Chrome side of having the WebKit FileSystem API use WebPermissionClient for checking if using fil... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_system/file_system_dispatcher_host.h" 5 #include "content/browser/file_system/file_system_dispatcher_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "chrome/browser/content_settings/host_content_settings_map.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "content/browser/resource_context.h" 15 #include "content/browser/resource_context.h"
17 #include "content/common/file_system_messages.h" 16 #include "content/common/file_system_messages.h"
18 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
19 #include "ipc/ipc_platform_file.h" 18 #include "ipc/ipc_platform_file.h"
20 #include "net/url_request/url_request_context.h" 19 #include "net/url_request/url_request_context.h"
21 #include "webkit/fileapi/file_system_callback_dispatcher.h" 20 #include "webkit/fileapi/file_system_callback_dispatcher.h"
22 #include "webkit/fileapi/file_system_context.h" 21 #include "webkit/fileapi/file_system_context.h"
23 #include "webkit/fileapi/file_system_operation.h" 22 #include "webkit/fileapi/file_system_operation.h"
24 #include "webkit/fileapi/file_system_operation.h" 23 #include "webkit/fileapi/file_system_operation.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 dispatcher_host_->Send(new FileSystemMsg_DidOpenFile( 97 dispatcher_host_->Send(new FileSystemMsg_DidOpenFile(
99 request_id_, file_for_transit)); 98 request_id_, file_for_transit));
100 } 99 }
101 100
102 private: 101 private:
103 scoped_refptr<FileSystemDispatcherHost> dispatcher_host_; 102 scoped_refptr<FileSystemDispatcherHost> dispatcher_host_;
104 int request_id_; 103 int request_id_;
105 }; 104 };
106 105
107 FileSystemDispatcherHost::FileSystemDispatcherHost( 106 FileSystemDispatcherHost::FileSystemDispatcherHost(
108 const content::ResourceContext* resource_context, 107 const content::ResourceContext* resource_context)
109 HostContentSettingsMap* host_content_settings_map)
110 : context_(NULL), 108 : context_(NULL),
111 host_content_settings_map_(host_content_settings_map),
112 resource_context_(resource_context), 109 resource_context_(resource_context),
113 request_context_(NULL) { 110 request_context_(NULL) {
114 DCHECK(resource_context_); 111 DCHECK(resource_context_);
115 DCHECK(host_content_settings_map_);
116 } 112 }
117 113
118 FileSystemDispatcherHost::FileSystemDispatcherHost( 114 FileSystemDispatcherHost::FileSystemDispatcherHost(
119 net::URLRequestContext* request_context, 115 net::URLRequestContext* request_context,
120 HostContentSettingsMap* host_content_settings_map,
121 fileapi::FileSystemContext* file_system_context) 116 fileapi::FileSystemContext* file_system_context)
122 : context_(file_system_context), 117 : context_(file_system_context),
123 host_content_settings_map_(host_content_settings_map),
124 resource_context_(NULL), 118 resource_context_(NULL),
125 request_context_(request_context) { 119 request_context_(request_context) {
126 DCHECK(request_context_); 120 DCHECK(request_context_);
127 DCHECK(host_content_settings_map_);
128 DCHECK(context_); 121 DCHECK(context_);
129 } 122 }
130 123
131 FileSystemDispatcherHost::~FileSystemDispatcherHost() { 124 FileSystemDispatcherHost::~FileSystemDispatcherHost() {
132 } 125 }
133 126
134 void FileSystemDispatcherHost::OnChannelConnected(int32 peer_pid) { 127 void FileSystemDispatcherHost::OnChannelConnected(int32 peer_pid) {
135 BrowserMessageFilter::OnChannelConnected(peer_pid); 128 BrowserMessageFilter::OnChannelConnected(peer_pid);
136 129
137 if (resource_context_) { 130 if (resource_context_) {
(...skipping 26 matching lines...) Expand all
164 IPC_MESSAGE_HANDLER(FileSystemHostMsg_CancelWrite, OnCancel) 157 IPC_MESSAGE_HANDLER(FileSystemHostMsg_CancelWrite, OnCancel)
165 IPC_MESSAGE_HANDLER(FileSystemHostMsg_OpenFile, OnOpenFile) 158 IPC_MESSAGE_HANDLER(FileSystemHostMsg_OpenFile, OnOpenFile)
166 IPC_MESSAGE_UNHANDLED(handled = false) 159 IPC_MESSAGE_UNHANDLED(handled = false)
167 IPC_END_MESSAGE_MAP_EX() 160 IPC_END_MESSAGE_MAP_EX()
168 return handled; 161 return handled;
169 } 162 }
170 163
171 void FileSystemDispatcherHost::OnOpen( 164 void FileSystemDispatcherHost::OnOpen(
172 int request_id, const GURL& origin_url, fileapi::FileSystemType type, 165 int request_id, const GURL& origin_url, fileapi::FileSystemType type,
173 int64 requested_size, bool create) { 166 int64 requested_size, bool create) {
174 ContentSetting content_setting =
175 host_content_settings_map_->GetContentSetting(
176 origin_url, CONTENT_SETTINGS_TYPE_COOKIES, "");
177 DCHECK((content_setting == CONTENT_SETTING_ALLOW) ||
178 (content_setting == CONTENT_SETTING_BLOCK) ||
179 (content_setting == CONTENT_SETTING_SESSION_ONLY));
180 if (content_setting == CONTENT_SETTING_BLOCK) {
181 // TODO(kinuko): Need to notify the UI thread to indicate that
182 // there's a blocked content.
183 Send(new FileSystemMsg_OpenComplete(
184 request_id, false, std::string(), GURL()));
185 return;
186 }
187
188 GetNewOperation(request_id)->OpenFileSystem(origin_url, type, create); 167 GetNewOperation(request_id)->OpenFileSystem(origin_url, type, create);
189 } 168 }
190 169
191 void FileSystemDispatcherHost::OnMove( 170 void FileSystemDispatcherHost::OnMove(
192 int request_id, const GURL& src_path, const GURL& dest_path) { 171 int request_id, const GURL& src_path, const GURL& dest_path) {
193 GetNewOperation(request_id)->Move(src_path, dest_path); 172 GetNewOperation(request_id)->Move(src_path, dest_path);
194 } 173 }
195 174
196 void FileSystemDispatcherHost::OnCopy( 175 void FileSystemDispatcherHost::OnCopy(
197 int request_id, const GURL& src_path, const GURL& dest_path) { 176 int request_id, const GURL& src_path, const GURL& dest_path) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 context_, 265 context_,
287 NULL); 266 NULL);
288 operations_.AddWithID(operation, request_id); 267 operations_.AddWithID(operation, request_id);
289 return operation; 268 return operation;
290 } 269 }
291 270
292 void FileSystemDispatcherHost::UnregisterOperation(int request_id) { 271 void FileSystemDispatcherHost::UnregisterOperation(int request_id) {
293 DCHECK(operations_.Lookup(request_id)); 272 DCHECK(operations_.Lookup(request_id));
294 operations_.Remove(request_id); 273 operations_.Remove(request_id);
295 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698