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

Side by Side Diff: chrome/browser/renderer_host/database_permission_request.cc

Issue 3299020: Remove vestigial cookie/web app permissions prompting UI now that the async U... (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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/renderer_host/database_permission_request.h"
6
7
8 #include "chrome/browser/browser_list.h"
9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/host_content_settings_map.h"
11 #include "chrome/browser/message_box_handler.h"
12
13 DatabasePermissionRequest::DatabasePermissionRequest(
14 const GURL& url,
15 const string16& database_name,
16 const string16& display_name,
17 unsigned long estimated_size,
18 Task* on_allow,
19 Task* on_block,
20 HostContentSettingsMap* settings_map)
21 : url_(url),
22 database_name_(database_name),
23 display_name_(display_name),
24 estimated_size_(estimated_size),
25 on_allow_(on_allow),
26 on_block_(on_block),
27 host_content_settings_map_(settings_map) {
28 DCHECK(on_allow_.get());
29 DCHECK(on_block_.get());
30 }
31
32 DatabasePermissionRequest::~DatabasePermissionRequest() {
33 }
34
35 void DatabasePermissionRequest::RequestPermission() {
36 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
37 ChromeThread::PostTask(
38 ChromeThread::UI, FROM_HERE, NewRunnableMethod(
39 this, &DatabasePermissionRequest::RequestPermission));
40 return;
41 }
42 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
43
44 // Cookie settings may have changed.
45 ContentSetting setting = host_content_settings_map_->GetContentSetting(
46 url_, CONTENT_SETTINGS_TYPE_COOKIES, "");
47 if (setting != CONTENT_SETTING_ASK) {
48 SendResponse(setting);
49 return;
50 }
51
52 Browser* browser = BrowserList::GetLastActive();
53 if (!browser || !browser->GetSelectedTabContents()) {
54 BlockSiteData();
55 return;
56 }
57
58 self_ref_ = this;
59 // Will call either AllowSiteData or BlockSiteData which will NULL out our
60 // self reference.
61 RunDatabasePrompt(browser->GetSelectedTabContents(),
62 host_content_settings_map_, url_, database_name_,
63 display_name_, estimated_size_, this);
64 }
65
66 void DatabasePermissionRequest::AllowSiteData(bool session_expire) {
67 SendResponse(CONTENT_SETTING_ALLOW);
68 }
69
70 void DatabasePermissionRequest::BlockSiteData() {
71 SendResponse(CONTENT_SETTING_BLOCK);
72 }
73
74 void DatabasePermissionRequest::SendResponse(ContentSetting content_setting) {
75 if (content_setting == CONTENT_SETTING_ALLOW) {
76 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, on_allow_.release());
77 } else {
78 DCHECK(content_setting == CONTENT_SETTING_BLOCK);
79 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, on_block_.release());
80 }
81
82 // Release all resources.
83 on_allow_.reset();
84 on_block_.reset();
85
86 // This seems safer than possibly being deleted while in method(s) related to
87 // this object. Any thread will do, but UI is always around and can be
88 // posted without locking, so we'll ask it to do the release.
89 ChromeThread::ReleaseSoon(ChromeThread::UI, FROM_HERE, self_ref_.release());
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698