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_permission_request.h" | 5 #include "chrome/browser/renderer_host/database_permission_request.h" |
6 | 6 |
7 | 7 |
8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/browser/host_content_settings_map.h" | 10 #include "chrome/browser/host_content_settings_map.h" |
11 #include "chrome/browser/message_box_handler.h" | 11 #include "chrome/browser/message_box_handler.h" |
12 | 12 |
13 DatabasePermissionRequest::DatabasePermissionRequest( | 13 DatabasePermissionRequest::DatabasePermissionRequest( |
14 const GURL& url, | 14 const GURL& url, |
15 const string16& database_name, | 15 const string16& database_name, |
| 16 const string16& display_name, |
| 17 unsigned long estimated_size, |
16 Task* on_allow, | 18 Task* on_allow, |
17 Task* on_block, | 19 Task* on_block, |
18 HostContentSettingsMap* settings_map) | 20 HostContentSettingsMap* settings_map) |
19 : url_(url), | 21 : url_(url), |
20 database_name_(database_name), | 22 database_name_(database_name), |
| 23 display_name_(display_name), |
| 24 estimated_size_(estimated_size), |
21 on_allow_(on_allow), | 25 on_allow_(on_allow), |
22 on_block_(on_block), | 26 on_block_(on_block), |
23 host_content_settings_map_(settings_map) { | 27 host_content_settings_map_(settings_map) { |
24 DCHECK(on_allow_.get()); | 28 DCHECK(on_allow_.get()); |
25 DCHECK(on_block_.get()); | 29 DCHECK(on_block_.get()); |
26 } | 30 } |
27 | 31 |
28 DatabasePermissionRequest::~DatabasePermissionRequest() { | 32 DatabasePermissionRequest::~DatabasePermissionRequest() { |
29 } | 33 } |
30 | 34 |
(...skipping 17 matching lines...) Expand all Loading... |
48 Browser* browser = BrowserList::GetLastActive(); | 52 Browser* browser = BrowserList::GetLastActive(); |
49 if (!browser || !browser->GetSelectedTabContents()) { | 53 if (!browser || !browser->GetSelectedTabContents()) { |
50 BlockSiteData(); | 54 BlockSiteData(); |
51 return; | 55 return; |
52 } | 56 } |
53 | 57 |
54 self_ref_ = this; | 58 self_ref_ = this; |
55 // Will call either AllowSiteData or BlockSiteData which will NULL out our | 59 // Will call either AllowSiteData or BlockSiteData which will NULL out our |
56 // self reference. | 60 // self reference. |
57 RunDatabasePrompt(browser->GetSelectedTabContents(), | 61 RunDatabasePrompt(browser->GetSelectedTabContents(), |
58 host_content_settings_map_, url_, database_name_, this); | 62 host_content_settings_map_, url_, database_name_, |
| 63 display_name_, estimated_size_, this); |
59 } | 64 } |
60 | 65 |
61 void DatabasePermissionRequest::AllowSiteData(bool session_expire) { | 66 void DatabasePermissionRequest::AllowSiteData(bool session_expire) { |
62 SendResponse(CONTENT_SETTING_ALLOW); | 67 SendResponse(CONTENT_SETTING_ALLOW); |
63 } | 68 } |
64 | 69 |
65 void DatabasePermissionRequest::BlockSiteData() { | 70 void DatabasePermissionRequest::BlockSiteData() { |
66 SendResponse(CONTENT_SETTING_BLOCK); | 71 SendResponse(CONTENT_SETTING_BLOCK); |
67 } | 72 } |
68 | 73 |
69 void DatabasePermissionRequest::SendResponse(ContentSetting content_setting) { | 74 void DatabasePermissionRequest::SendResponse(ContentSetting content_setting) { |
70 if (content_setting == CONTENT_SETTING_ALLOW) { | 75 if (content_setting == CONTENT_SETTING_ALLOW) { |
71 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, on_allow_.release()); | 76 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, on_allow_.release()); |
72 } else { | 77 } else { |
73 DCHECK(content_setting == CONTENT_SETTING_BLOCK); | 78 DCHECK(content_setting == CONTENT_SETTING_BLOCK); |
74 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, on_block_.release()); | 79 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, on_block_.release()); |
75 } | 80 } |
76 | 81 |
77 // Release all resources. | 82 // Release all resources. |
78 on_allow_.reset(); | 83 on_allow_.reset(); |
79 on_block_.reset(); | 84 on_block_.reset(); |
80 | 85 |
81 // This seems safer than possibly being deleted while in method(s) related to | 86 // This seems safer than possibly being deleted while in method(s) related to |
82 // this object. Any thread will do, but UI is always around and can be | 87 // this object. Any thread will do, but UI is always around and can be |
83 // posted without locking, so we'll ask it to do the release. | 88 // posted without locking, so we'll ask it to do the release. |
84 ChromeThread::ReleaseSoon(ChromeThread::UI, FROM_HERE, self_ref_.release()); | 89 ChromeThread::ReleaseSoon(ChromeThread::UI, FROM_HERE, self_ref_.release()); |
85 } | 90 } |
OLD | NEW |