| 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/renderer_host/database_dispatcher_host.h" | 5 #include "chrome/browser/renderer_host/database_dispatcher_host.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include "base/file_descriptor_posix.h" | 8 #include "base/file_descriptor_posix.h" |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/thread.h" | 12 #include "base/thread.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
| 15 #include "chrome/browser/host_content_settings_map.h" | 15 #include "chrome/browser/host_content_settings_map.h" |
| 16 #include "chrome/browser/net/chrome_url_request_context.h" | 16 #include "chrome/browser/net/chrome_url_request_context.h" |
| 17 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 17 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 18 #include "chrome/browser/renderer_host/database_permission_request.h" | |
| 19 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
| 20 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 21 #include "third_party/sqlite/sqlite3.h" | 20 #include "third_party/sqlite/sqlite3.h" |
| 22 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" |
| 23 #include "webkit/database/database_util.h" | 22 #include "webkit/database/database_util.h" |
| 24 #include "webkit/database/vfs_backend.h" | 23 #include "webkit/database/vfs_backend.h" |
| 25 | 24 |
| 26 using WebKit::WebSecurityOrigin; | 25 using WebKit::WebSecurityOrigin; |
| 27 using webkit_database::DatabaseTracker; | 26 using webkit_database::DatabaseTracker; |
| 28 using webkit_database::DatabaseUtil; | 27 using webkit_database::DatabaseUtil; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 382 |
| 384 void DatabaseDispatcherHost::OnAllowDatabase(const std::string& origin_url, | 383 void DatabaseDispatcherHost::OnAllowDatabase(const std::string& origin_url, |
| 385 const string16& name, | 384 const string16& name, |
| 386 const string16& display_name, | 385 const string16& display_name, |
| 387 unsigned long estimated_size, | 386 unsigned long estimated_size, |
| 388 IPC::Message* reply_msg) { | 387 IPC::Message* reply_msg) { |
| 389 GURL url = GURL(origin_url); | 388 GURL url = GURL(origin_url); |
| 390 ContentSetting content_setting = | 389 ContentSetting content_setting = |
| 391 host_content_settings_map_->GetContentSetting( | 390 host_content_settings_map_->GetContentSetting( |
| 392 url, CONTENT_SETTINGS_TYPE_COOKIES, ""); | 391 url, CONTENT_SETTINGS_TYPE_COOKIES, ""); |
| 393 if (content_setting == CONTENT_SETTING_ASK) { | |
| 394 // Create a task for each possible outcome. | |
| 395 scoped_ptr<Task> on_allow(NewRunnableMethod( | |
| 396 this, &DatabaseDispatcherHost::AllowDatabaseResponse, | |
| 397 reply_msg, CONTENT_SETTING_ALLOW)); | |
| 398 scoped_ptr<Task> on_block(NewRunnableMethod( | |
| 399 this, &DatabaseDispatcherHost::AllowDatabaseResponse, | |
| 400 reply_msg, CONTENT_SETTING_BLOCK)); | |
| 401 // And then let the permission request object do the rest. | |
| 402 scoped_refptr<DatabasePermissionRequest> request( | |
| 403 new DatabasePermissionRequest(url, name, display_name, estimated_size, | |
| 404 on_allow.release(), on_block.release(), | |
| 405 host_content_settings_map_)); | |
| 406 request->RequestPermission(); | |
| 407 | |
| 408 // Tell the renderer that it needs to run a nested message loop. | |
| 409 Send(new ViewMsg_SignalCookiePromptEvent()); | |
| 410 return; | |
| 411 } | |
| 412 | |
| 413 AllowDatabaseResponse(reply_msg, content_setting); | 392 AllowDatabaseResponse(reply_msg, content_setting); |
| 414 } | 393 } |
| 415 | 394 |
| 416 void DatabaseDispatcherHost::AllowDatabaseResponse( | 395 void DatabaseDispatcherHost::AllowDatabaseResponse( |
| 417 IPC::Message* reply_msg, ContentSetting content_setting) { | 396 IPC::Message* reply_msg, ContentSetting content_setting) { |
| 418 DCHECK((content_setting == CONTENT_SETTING_ALLOW) || | 397 DCHECK((content_setting == CONTENT_SETTING_ALLOW) || |
| 419 (content_setting == CONTENT_SETTING_BLOCK) || | 398 (content_setting == CONTENT_SETTING_BLOCK) || |
| 420 (content_setting == CONTENT_SETTING_SESSION_ONLY)); | 399 (content_setting == CONTENT_SETTING_SESSION_ONLY)); |
| 421 ViewHostMsg_AllowDatabase::WriteReplyParams( | 400 ViewHostMsg_AllowDatabase::WriteReplyParams( |
| 422 reply_msg, content_setting != CONTENT_SETTING_BLOCK); | 401 reply_msg, content_setting != CONTENT_SETTING_BLOCK); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 447 database_size, space_available)); | 426 database_size, space_available)); |
| 448 } | 427 } |
| 449 } | 428 } |
| 450 | 429 |
| 451 void DatabaseDispatcherHost::OnDatabaseScheduledForDeletion( | 430 void DatabaseDispatcherHost::OnDatabaseScheduledForDeletion( |
| 452 const string16& origin_identifier, | 431 const string16& origin_identifier, |
| 453 const string16& database_name) { | 432 const string16& database_name) { |
| 454 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); | 433 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); |
| 455 Send(new ViewMsg_DatabaseCloseImmediately(origin_identifier, database_name)); | 434 Send(new ViewMsg_DatabaseCloseImmediately(origin_identifier, database_name)); |
| 456 } | 435 } |
| OLD | NEW |