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

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

Issue 3243005: Revert 57715 - Add a helper class that keeps per-profile information for File... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 3 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/file_system/file_system_dispatcher_host.h" 5 #include "chrome/browser/file_system/file_system_dispatcher_host.h"
6 6
7 #include "base/thread.h" 7 #include "base/thread.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_thread.h" 10 #include "chrome/browser/chrome_thread.h"
11 #include "chrome/browser/file_system/file_system_host_context.h"
12 #include "chrome/browser/host_content_settings_map.h" 11 #include "chrome/browser/host_content_settings_map.h"
13 #include "chrome/browser/renderer_host/browser_render_process_host.h" 12 #include "chrome/browser/renderer_host/browser_render_process_host.h"
14 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
15 #include "chrome/common/render_messages_params.h" 14 #include "chrome/common/render_messages_params.h"
16 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebFileError.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebFileError.h"
18 #include "webkit/glue/webkit_glue.h"
19 17
20 FileSystemDispatcherHost::FileSystemDispatcherHost( 18 FileSystemDispatcherHost::FileSystemDispatcherHost(
21 IPC::Message::Sender* sender, 19 IPC::Message::Sender* sender,
22 FileSystemHostContext* file_system_host_context,
23 HostContentSettingsMap* host_content_settings_map) 20 HostContentSettingsMap* host_content_settings_map)
24 : message_sender_(sender), 21 : message_sender_(sender),
25 process_handle_(0), 22 process_handle_(0),
26 shutdown_(false), 23 shutdown_(false),
27 context_(file_system_host_context),
28 host_content_settings_map_(host_content_settings_map) { 24 host_content_settings_map_(host_content_settings_map) {
29 DCHECK(message_sender_); 25 DCHECK(message_sender_);
30 } 26 }
31 27
32 void FileSystemDispatcherHost::Init(base::ProcessHandle process_handle) { 28 void FileSystemDispatcherHost::Init(base::ProcessHandle process_handle) {
33 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 29 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
34 DCHECK(!shutdown_); 30 DCHECK(!shutdown_);
35 DCHECK(!process_handle_); 31 DCHECK(!process_handle_);
36 DCHECK(process_handle); 32 DCHECK(process_handle);
37 process_handle_ = process_handle; 33 process_handle_ = process_handle;
(...skipping 13 matching lines...) Expand all
51 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenFileSystemRequest, OnOpenFileSystem) 47 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenFileSystemRequest, OnOpenFileSystem)
52 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Move, OnMove) 48 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Move, OnMove)
53 // TODO(kinuko): add more. 49 // TODO(kinuko): add more.
54 IPC_MESSAGE_UNHANDLED(handled = false) 50 IPC_MESSAGE_UNHANDLED(handled = false)
55 IPC_END_MESSAGE_MAP_EX() 51 IPC_END_MESSAGE_MAP_EX()
56 return handled; 52 return handled;
57 } 53 }
58 54
59 void FileSystemDispatcherHost::OnOpenFileSystem( 55 void FileSystemDispatcherHost::OnOpenFileSystem(
60 const ViewHostMsg_OpenFileSystemRequest_Params& params) { 56 const ViewHostMsg_OpenFileSystemRequest_Params& params) {
57 string16 name;
58 string16 root_path;
61 59
62 // TODO(kinuko): hook up ContentSettings cookies type checks. 60 // TODO(kinuko): not implemented yet.
63
64 FilePath root_path;
65 std::string name;
66
67 if (!context_->GetFileSystemRootPath(params.origin_url,
68 params.type,
69 &root_path,
70 &name)) {
71 Send(new ViewMsg_OpenFileSystemRequest_Complete(
72 params.routing_id,
73 params.request_id,
74 false,
75 string16(),
76 string16()));
77 return;
78 }
79
80 // TODO(kinuko): creates the root directory and if it succeeds.
81 61
82 Send(new ViewMsg_OpenFileSystemRequest_Complete( 62 Send(new ViewMsg_OpenFileSystemRequest_Complete(
83 params.routing_id, 63 params.routing_id,
84 params.request_id, 64 params.request_id,
85 true, 65 false,
86 UTF8ToUTF16(name), 66 name, root_path));
87 webkit_glue::FilePathToWebString(root_path)));
88 } 67 }
89 68
90 void FileSystemDispatcherHost::OnMove( 69 void FileSystemDispatcherHost::OnMove(
91 int request_id, const string16& src_path, const string16& dest_path) { 70 int request_id, const string16& src_path, const string16& dest_path) {
92 if (!context_->CheckValidFileSystemPath(
93 webkit_glue::WebStringToFilePath(src_path)) ||
94 !context_->CheckValidFileSystemPath(
95 webkit_glue::WebStringToFilePath(dest_path))) {
96 Send(new ViewMsg_FileSystem_Failed(
97 request_id, WebKit::WebFileErrorSecurity));
98 return;
99 }
100
101 // TODO(kinuko): not implemented yet. 71 // TODO(kinuko): not implemented yet.
102 72
103 Send(new ViewMsg_FileSystem_Failed( 73 Send(new ViewMsg_FileSystem_Failed(
104 request_id, WebKit::WebFileErrorAbort)); 74 request_id, WebKit::WebFileErrorAbort));
105 } 75 }
106 76
107 void FileSystemDispatcherHost::Send(IPC::Message* message) { 77 void FileSystemDispatcherHost::Send(IPC::Message* message) {
108 if (!ChromeThread::CurrentlyOn(ChromeThread::IO)) { 78 if (!ChromeThread::CurrentlyOn(ChromeThread::IO)) {
109 if (!ChromeThread::PostTask( 79 if (!ChromeThread::PostTask(
110 ChromeThread::IO, FROM_HERE, 80 ChromeThread::IO, FROM_HERE,
111 NewRunnableMethod(this, 81 NewRunnableMethod(this,
112 &FileSystemDispatcherHost::Send, 82 &FileSystemDispatcherHost::Send,
113 message))) 83 message)))
114 delete message; 84 delete message;
115 return; 85 return;
116 } 86 }
117 87
118 if (!shutdown_ && message_sender_) 88 if (!shutdown_ && message_sender_)
119 message_sender_->Send(message); 89 message_sender_->Send(message);
120 else 90 else
121 delete message; 91 delete message;
122 } 92 }
OLDNEW
« no previous file with comments | « chrome/browser/file_system/file_system_dispatcher_host.h ('k') | chrome/browser/file_system/file_system_host_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698