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

Side by Side Diff: chrome/browser/in_process_webkit/dom_storage_permission_request.cc

Issue 651023: Pass in the HostContentSettingsMap to the CookieModalDialog so IsValid can ma... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
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/in_process_webkit/dom_storage_permission_request.h" 5 #include "chrome/browser/in_process_webkit/dom_storage_permission_request.h"
6 6
7 #include "chrome/browser/browser_list.h" 7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/message_box_handler.h" 8 #include "chrome/browser/message_box_handler.h"
9 9
10 DOMStoragePermissionRequest::DOMStoragePermissionRequest( 10 DOMStoragePermissionRequest::DOMStoragePermissionRequest(
11 const GURL& url, 11 const GURL& url,
12 const string16& key, 12 const string16& key,
13 const string16& value, 13 const string16& value,
14 HostContentSettingsMap* settings) 14 HostContentSettingsMap* settings)
15 : url_(url), 15 : url_(url),
16 key_(key), 16 key_(key),
17 value_(value), 17 value_(value),
18 event_(true, false), // manual reset, not initially signaled 18 event_(true, false), // manual reset, not initially signaled
19 host_content_settings_map_(settings) { 19 host_content_settings_map_(settings) {
20 } 20 }
21 21
22 ContentSetting DOMStoragePermissionRequest::WaitOnResponse() { 22 ContentSetting DOMStoragePermissionRequest::WaitOnResponse() {
23 event_.Wait(); 23 event_.Wait();
24 return response_content_setting_; 24 return response_content_setting_;
25 } 25 }
26 26
27 // static 27 // static
28 void DOMStoragePermissionRequest::PromptUser( 28 void DOMStoragePermissionRequest::PromptUser(
29 DOMStoragePermissionRequest* dom_storage_permission_request) { 29 DOMStoragePermissionRequest* request) {
30 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 30 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
31 31
32 // Cookie settings may have changed. 32 // Cookie settings may have changed.
33 ContentSetting setting = 33 ContentSetting setting =
34 dom_storage_permission_request->host_content_settings_map_-> 34 request->host_content_settings_map_->GetContentSetting(
35 GetContentSetting(dom_storage_permission_request->url(), 35 request->url_, CONTENT_SETTINGS_TYPE_COOKIES);
36 CONTENT_SETTINGS_TYPE_COOKIES);
37 if (setting != CONTENT_SETTING_ASK) { 36 if (setting != CONTENT_SETTING_ASK) {
38 dom_storage_permission_request->SendResponse(setting, false); 37 request->SendResponse(setting);
39 return; 38 return;
40 } 39 }
41 40
42 Browser* browser = BrowserList::GetLastActive(); 41 Browser* browser = BrowserList::GetLastActive();
43 if (!browser || !browser->GetSelectedTabContents()) { 42 if (!browser || !browser->GetSelectedTabContents()) {
44 dom_storage_permission_request->SendResponse(CONTENT_SETTING_BLOCK, false); 43 request->SendResponse(CONTENT_SETTING_BLOCK);
45 return; 44 return;
46 } 45 }
47 46
48 #if defined(OS_WIN) 47 #if defined(OS_WIN)
49 RunLocalStoragePrompt(browser->GetSelectedTabContents(), 48 RunLocalStoragePrompt(browser->GetSelectedTabContents(),
50 dom_storage_permission_request->url(), 49 request->host_content_settings_map_, request->url_,
51 dom_storage_permission_request->key(), 50 request->key_, request->value_, request);
52 dom_storage_permission_request->value(),
53 dom_storage_permission_request);
54 #else 51 #else
55 // TODO(darin): Enable prompting for other ports. 52 // TODO(darin): Enable prompting for other ports.
56 dom_storage_permission_request->SendResponse(CONTENT_SETTING_BLOCK, false); 53 request->SendResponse(CONTENT_SETTING_BLOCK);
57 #endif 54 #endif
58 } 55 }
59 56
60 void DOMStoragePermissionRequest::AllowSiteData(bool remember, 57 void DOMStoragePermissionRequest::AllowSiteData(bool session_expire) {
61 bool session_expire) { 58 SendResponse(CONTENT_SETTING_ALLOW);
62 // The session_expire parameter is not relevant.
63 SendResponse(CONTENT_SETTING_ALLOW, remember);
64 } 59 }
65 60
66 void DOMStoragePermissionRequest::BlockSiteData(bool remember) { 61 void DOMStoragePermissionRequest::BlockSiteData() {
67 SendResponse(CONTENT_SETTING_BLOCK, remember); 62 SendResponse(CONTENT_SETTING_BLOCK);
68 } 63 }
69 64
70 void DOMStoragePermissionRequest::SendResponse(ContentSetting content_setting, 65 void DOMStoragePermissionRequest::SendResponse(
71 bool remember) { 66 ContentSetting content_setting) {
72 response_content_setting_ = content_setting; 67 response_content_setting_ = content_setting;
73 if (remember) {
74 host_content_settings_map_->SetContentSetting(
75 url_.host(), CONTENT_SETTINGS_TYPE_COOKIES, content_setting);
76 }
77 event_.Signal(); 68 event_.Signal();
78 } 69 }
OLDNEW
« no previous file with comments | « chrome/browser/in_process_webkit/dom_storage_permission_request.h ('k') | chrome/browser/message_box_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698