| OLD | NEW |
| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool FileSystemDispatcherHost::OnMessageReceived( | 45 bool FileSystemDispatcherHost::OnMessageReceived( |
| 46 const IPC::Message& message, bool* message_was_ok) { | 46 const IPC::Message& message, bool* message_was_ok) { |
| 47 DCHECK(!shutdown_); | 47 DCHECK(!shutdown_); |
| 48 *message_was_ok = true; | 48 *message_was_ok = true; |
| 49 bool handled = true; | 49 bool handled = true; |
| 50 IPC_BEGIN_MESSAGE_MAP_EX(FileSystemDispatcherHost, message, *message_was_ok) | 50 IPC_BEGIN_MESSAGE_MAP_EX(FileSystemDispatcherHost, message, *message_was_ok) |
| 51 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenFileSystemRequest, OnOpenFileSystem) | 51 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenFileSystemRequest, OnOpenFileSystem) |
| 52 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Move, OnMove) | 52 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Move, OnMove) |
| 53 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Copy, OnCopy) | 53 // TODO(kinuko): add more. |
| 54 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Remove, OnRemove) | |
| 55 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadMetadata, OnReadMetadata) | |
| 56 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Create, OnCreate) | |
| 57 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Exists, OnExists) | |
| 58 IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadDirectory, OnReadDirectory) | |
| 59 IPC_MESSAGE_UNHANDLED(handled = false) | 54 IPC_MESSAGE_UNHANDLED(handled = false) |
| 60 IPC_END_MESSAGE_MAP_EX() | 55 IPC_END_MESSAGE_MAP_EX() |
| 61 return handled; | 56 return handled; |
| 62 } | 57 } |
| 63 | 58 |
| 64 void FileSystemDispatcherHost::OnOpenFileSystem( | 59 void FileSystemDispatcherHost::OnOpenFileSystem( |
| 65 const ViewHostMsg_OpenFileSystemRequest_Params& params) { | 60 const ViewHostMsg_OpenFileSystemRequest_Params& params) { |
| 66 | 61 |
| 67 // TODO(kinuko): hook up ContentSettings cookies type checks. | 62 // TODO(kinuko): hook up ContentSettings cookies type checks. |
| 68 | 63 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 97 if (!context_->CheckValidFileSystemPath( | 92 if (!context_->CheckValidFileSystemPath( |
| 98 webkit_glue::WebStringToFilePath(src_path)) || | 93 webkit_glue::WebStringToFilePath(src_path)) || |
| 99 !context_->CheckValidFileSystemPath( | 94 !context_->CheckValidFileSystemPath( |
| 100 webkit_glue::WebStringToFilePath(dest_path))) { | 95 webkit_glue::WebStringToFilePath(dest_path))) { |
| 101 Send(new ViewMsg_FileSystem_Failed( | 96 Send(new ViewMsg_FileSystem_Failed( |
| 102 request_id, WebKit::WebFileErrorSecurity)); | 97 request_id, WebKit::WebFileErrorSecurity)); |
| 103 return; | 98 return; |
| 104 } | 99 } |
| 105 | 100 |
| 106 // TODO(kinuko): not implemented yet. | 101 // TODO(kinuko): not implemented yet. |
| 107 Send(new ViewMsg_FileSystem_DidFail( | |
| 108 request_id, WebKit::WebFileErrorAbort)); | |
| 109 } | |
| 110 | 102 |
| 111 void FileSystemDispatcherHost::OnCopy( | 103 Send(new ViewMsg_FileSystem_Failed( |
| 112 int request_id, | |
| 113 const string16& src_path, | |
| 114 const string16& dest_path) { | |
| 115 // TODO(kinuko): not implemented yet. | |
| 116 Send(new ViewMsg_FileSystem_DidFail( | |
| 117 request_id, WebKit::WebFileErrorAbort)); | |
| 118 } | |
| 119 | |
| 120 void FileSystemDispatcherHost::OnRemove( | |
| 121 int request_id, | |
| 122 const string16& path) { | |
| 123 // TODO(kinuko): not implemented yet. | |
| 124 Send(new ViewMsg_FileSystem_DidFail( | |
| 125 request_id, WebKit::WebFileErrorAbort)); | |
| 126 } | |
| 127 | |
| 128 void FileSystemDispatcherHost::OnReadMetadata( | |
| 129 int request_id, | |
| 130 const string16& path) { | |
| 131 // TODO(kinuko): not implemented yet. | |
| 132 Send(new ViewMsg_FileSystem_DidFail( | |
| 133 request_id, WebKit::WebFileErrorAbort)); | |
| 134 } | |
| 135 | |
| 136 void FileSystemDispatcherHost::OnCreate( | |
| 137 int request_id, | |
| 138 const string16& path, | |
| 139 bool exclusive, | |
| 140 bool is_directory) { | |
| 141 // TODO(kinuko): not implemented yet. | |
| 142 Send(new ViewMsg_FileSystem_DidFail( | |
| 143 request_id, WebKit::WebFileErrorAbort)); | |
| 144 } | |
| 145 | |
| 146 void FileSystemDispatcherHost::OnExists( | |
| 147 int request_id, | |
| 148 const string16& path, | |
| 149 bool is_directory) { | |
| 150 // TODO(kinuko): not implemented yet. | |
| 151 Send(new ViewMsg_FileSystem_DidFail( | |
| 152 request_id, WebKit::WebFileErrorAbort)); | |
| 153 } | |
| 154 | |
| 155 void FileSystemDispatcherHost::OnReadDirectory( | |
| 156 int request_id, | |
| 157 const string16& path) { | |
| 158 // TODO(kinuko): not implemented yet. | |
| 159 Send(new ViewMsg_FileSystem_DidFail( | |
| 160 request_id, WebKit::WebFileErrorAbort)); | 104 request_id, WebKit::WebFileErrorAbort)); |
| 161 } | 105 } |
| 162 | 106 |
| 163 void FileSystemDispatcherHost::Send(IPC::Message* message) { | 107 void FileSystemDispatcherHost::Send(IPC::Message* message) { |
| 164 if (!ChromeThread::CurrentlyOn(ChromeThread::IO)) { | 108 if (!ChromeThread::CurrentlyOn(ChromeThread::IO)) { |
| 165 if (!ChromeThread::PostTask( | 109 if (!ChromeThread::PostTask( |
| 166 ChromeThread::IO, FROM_HERE, | 110 ChromeThread::IO, FROM_HERE, |
| 167 NewRunnableMethod(this, | 111 NewRunnableMethod(this, |
| 168 &FileSystemDispatcherHost::Send, | 112 &FileSystemDispatcherHost::Send, |
| 169 message))) | 113 message))) |
| 170 delete message; | 114 delete message; |
| 171 return; | 115 return; |
| 172 } | 116 } |
| 173 | 117 |
| 174 if (!shutdown_ && message_sender_) | 118 if (!shutdown_ && message_sender_) |
| 175 message_sender_->Send(message); | 119 message_sender_->Send(message); |
| 176 else | 120 else |
| 177 delete message; | 121 delete message; |
| 178 } | 122 } |
| OLD | NEW |