OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/renderer_webkitclient_impl.h" | 5 #include "chrome/renderer/renderer_webkitclient_impl.h" |
6 | 6 |
| 7 #if defined(USE_SYSTEM_SQLITE) |
| 8 #include <sqlite3.h> |
| 9 #else |
| 10 #include "third_party/sqlite/preprocessed/sqlite3.h" |
| 11 #endif |
| 12 |
7 #include "base/command_line.h" | 13 #include "base/command_line.h" |
8 #include "base/file_path.h" | 14 #include "base/file_path.h" |
9 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
10 #include "chrome/common/appcache/appcache_dispatcher.h" | 16 #include "chrome/common/appcache/appcache_dispatcher.h" |
11 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/db_message_filter.h" | 18 #include "chrome/common/db_message_filter.h" |
13 #include "chrome/common/render_messages.h" | 19 #include "chrome/common/render_messages.h" |
14 #include "chrome/common/webmessageportchannel_impl.h" | 20 #include "chrome/common/webmessageportchannel_impl.h" |
15 #include "chrome/plugin/npobject_util.h" | 21 #include "chrome/plugin/npobject_util.h" |
16 #include "chrome/renderer/net/render_dns_master.h" | 22 #include "chrome/renderer/net/render_dns_master.h" |
17 #include "chrome/renderer/render_thread.h" | 23 #include "chrome/renderer/render_thread.h" |
18 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" | 24 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" |
19 #include "chrome/renderer/visitedlink_slave.h" | 25 #include "chrome/renderer/visitedlink_slave.h" |
20 #include "webkit/api/public/WebString.h" | 26 #include "webkit/api/public/WebString.h" |
21 #include "webkit/api/public/WebURL.h" | 27 #include "webkit/api/public/WebURL.h" |
22 #include "webkit/appcache/web_application_cache_host_impl.h" | 28 #include "webkit/appcache/web_application_cache_host_impl.h" |
23 #include "webkit/glue/glue_util.h" | 29 #include "webkit/glue/glue_util.h" |
24 #include "webkit/glue/webkit_glue.h" | 30 #include "webkit/glue/webkit_glue.h" |
25 | 31 |
26 #if defined(OS_LINUX) | 32 #if defined(OS_LINUX) |
27 #include "chrome/renderer/renderer_sandbox_support_linux.h" | 33 #include "chrome/renderer/renderer_sandbox_support_linux.h" |
28 #endif | 34 #endif |
29 | 35 |
| 36 #if defined(OS_POSIX) |
| 37 #include "base/file_descriptor_posix.h" |
| 38 #endif |
| 39 |
30 using WebKit::WebApplicationCacheHost; | 40 using WebKit::WebApplicationCacheHost; |
31 using WebKit::WebApplicationCacheHostClient; | 41 using WebKit::WebApplicationCacheHostClient; |
32 using WebKit::WebStorageArea; | 42 using WebKit::WebStorageArea; |
33 using WebKit::WebStorageNamespace; | 43 using WebKit::WebStorageNamespace; |
34 using WebKit::WebString; | 44 using WebKit::WebString; |
35 using WebKit::WebURL; | 45 using WebKit::WebURL; |
36 | 46 |
37 //------------------------------------------------------------------------------ | 47 //------------------------------------------------------------------------------ |
38 | 48 |
39 WebKit::WebClipboard* RendererWebKitClientImpl::clipboard() { | 49 WebKit::WebClipboard* RendererWebKitClientImpl::clipboard() { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 num_characters); | 229 num_characters); |
220 unicode_font_families_.insert(make_pair(key, family_name)); | 230 unicode_font_families_.insert(make_pair(key, family_name)); |
221 return WebString::fromUTF8(family_name); | 231 return WebString::fromUTF8(family_name); |
222 } | 232 } |
223 | 233 |
224 #endif | 234 #endif |
225 | 235 |
226 //------------------------------------------------------------------------------ | 236 //------------------------------------------------------------------------------ |
227 | 237 |
228 base::PlatformFile RendererWebKitClientImpl::databaseOpenFile( | 238 base::PlatformFile RendererWebKitClientImpl::databaseOpenFile( |
229 const WebString& file_name, int desired_flags) { | 239 const WebString& file_name, int desired_flags, |
| 240 base::PlatformFile* dir_handle) { |
230 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); | 241 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); |
231 int message_id = db_message_filter->GetUniqueID(); | 242 int message_id = db_message_filter->GetUniqueID(); |
232 return db_message_filter->SendAndWait( | 243 |
233 new ViewHostMsg_DatabaseOpenFile( | 244 ViewMsg_DatabaseOpenFileResponse_Params default_response = |
234 FilePath(webkit_glue::WebStringToFilePathString(file_name)), | 245 #if defined(OS_WIN) |
235 desired_flags, message_id), | 246 { base::kInvalidPlatformFileValue }; |
236 message_id, base::kInvalidPlatformFileValue); | 247 #elif defined(OS_POSIX) |
| 248 { base::FileDescriptor(base::kInvalidPlatformFileValue, true), |
| 249 base::FileDescriptor(base::kInvalidPlatformFileValue, true) }; |
| 250 #endif |
| 251 |
| 252 ViewMsg_DatabaseOpenFileResponse_Params result = |
| 253 db_message_filter->SendAndWait( |
| 254 new ViewHostMsg_DatabaseOpenFile( |
| 255 FilePath(webkit_glue::WebStringToFilePathString(file_name)), |
| 256 desired_flags, message_id), |
| 257 message_id, default_response); |
| 258 |
| 259 #if defined(OS_WIN) |
| 260 if (dir_handle) { |
| 261 *dir_handle = base::kInvalidPlatformFileValue; |
| 262 } |
| 263 return result.file_handle; |
| 264 #elif defined(OS_POSIX) |
| 265 if (dir_handle) { |
| 266 *dir_handle = result.dir_handle.fd; |
| 267 } |
| 268 return result.file_handle.fd; |
| 269 #endif |
237 } | 270 } |
238 | 271 |
239 bool RendererWebKitClientImpl::databaseDeleteFile(const WebString& file_name) { | 272 int RendererWebKitClientImpl::databaseDeleteFile( |
| 273 const WebString& file_name, bool sync_dir) { |
240 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); | 274 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); |
241 int message_id = db_message_filter->GetUniqueID(); | 275 int message_id = db_message_filter->GetUniqueID(); |
242 return db_message_filter->SendAndWait( | 276 return db_message_filter->SendAndWait( |
243 new ViewHostMsg_DatabaseDeleteFile( | 277 new ViewHostMsg_DatabaseDeleteFile( |
244 FilePath(webkit_glue::WebStringToFilePathString(file_name)), | 278 FilePath(webkit_glue::WebStringToFilePathString(file_name)), sync_dir, |
245 message_id), | 279 message_id), |
246 message_id, false); | 280 message_id, SQLITE_IOERR_DELETE); |
247 } | 281 } |
248 | 282 |
249 long RendererWebKitClientImpl::databaseGetFileAttributes( | 283 long RendererWebKitClientImpl::databaseGetFileAttributes( |
250 const WebString& file_name) { | 284 const WebString& file_name) { |
251 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); | 285 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); |
252 int message_id = db_message_filter->GetUniqueID(); | 286 int message_id = db_message_filter->GetUniqueID(); |
253 return db_message_filter->SendAndWait( | 287 return db_message_filter->SendAndWait( |
254 new ViewHostMsg_DatabaseGetFileAttributes( | 288 new ViewHostMsg_DatabaseGetFileAttributes( |
255 FilePath(webkit_glue::WebStringToFilePathString(file_name)), | 289 FilePath(webkit_glue::WebStringToFilePathString(file_name)), |
256 message_id), | 290 message_id), |
257 message_id, -1L); | 291 message_id, -1L); |
258 } | 292 } |
259 | 293 |
260 long long RendererWebKitClientImpl::databaseGetFileSize( | 294 long long RendererWebKitClientImpl::databaseGetFileSize( |
261 const WebString& file_name) { | 295 const WebString& file_name) { |
262 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); | 296 DBMessageFilter* db_message_filter = DBMessageFilter::GetInstance(); |
263 int message_id = db_message_filter->GetUniqueID(); | 297 int message_id = db_message_filter->GetUniqueID(); |
264 return db_message_filter->SendAndWait( | 298 return db_message_filter->SendAndWait( |
265 new ViewHostMsg_DatabaseGetFileSize( | 299 new ViewHostMsg_DatabaseGetFileSize( |
266 FilePath(webkit_glue::WebStringToFilePathString(file_name)), | 300 FilePath(webkit_glue::WebStringToFilePathString(file_name)), |
267 message_id), | 301 message_id), |
268 message_id, 0LL); | 302 message_id, 0LL); |
269 } | 303 } |
OLD | NEW |