OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/storage/durable_storage_permission_context.h" | 5 #include "chrome/browser/storage/durable_storage_permission_context.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {} | 32 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {} |
33 | 33 |
34 void DurableStoragePermissionContext::DecidePermission( | 34 void DurableStoragePermissionContext::DecidePermission( |
35 content::WebContents* web_contents, | 35 content::WebContents* web_contents, |
36 const PermissionRequestID& id, | 36 const PermissionRequestID& id, |
37 const GURL& requesting_origin, | 37 const GURL& requesting_origin, |
38 const GURL& embedding_origin, | 38 const GURL& embedding_origin, |
39 bool user_gesture, | 39 bool user_gesture, |
40 const BrowserPermissionCallback& callback) { | 40 const BrowserPermissionCallback& callback) { |
41 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 41 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
42 DCHECK_NE( | 42 DCHECK_NE(CONTENT_SETTING_ALLOW, |
43 CONTENT_SETTING_ALLOW, | 43 GetPermissionStatus(nullptr /* render_frame_host */, |
44 GetPermissionStatus(requesting_origin, embedding_origin).content_setting); | 44 requesting_origin, embedding_origin) |
45 DCHECK_NE( | 45 .content_setting); |
46 CONTENT_SETTING_BLOCK, | 46 DCHECK_NE(CONTENT_SETTING_BLOCK, |
47 GetPermissionStatus(requesting_origin, embedding_origin).content_setting); | 47 GetPermissionStatus(nullptr /* render_frame_host */, |
| 48 requesting_origin, embedding_origin) |
| 49 .content_setting); |
48 | 50 |
49 // Durable is only allowed to be granted to the top-level origin. Embedding | 51 // Durable is only allowed to be granted to the top-level origin. Embedding |
50 // origin is the last committed navigation origin to the web contents. | 52 // origin is the last committed navigation origin to the web contents. |
51 if (requesting_origin != embedding_origin) { | 53 if (requesting_origin != embedding_origin) { |
52 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 54 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
53 false /* persist */, CONTENT_SETTING_DEFAULT); | 55 false /* persist */, CONTENT_SETTING_DEFAULT); |
54 return; | 56 return; |
55 } | 57 } |
56 | 58 |
57 // Don't grant durable if we can't write cookies. | 59 // Don't grant durable if we can't write cookies. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 101 |
100 HostContentSettingsMapFactory::GetForProfile(profile()) | 102 HostContentSettingsMapFactory::GetForProfile(profile()) |
101 ->SetContentSettingDefaultScope(requesting_origin, GURL(), | 103 ->SetContentSettingDefaultScope(requesting_origin, GURL(), |
102 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, | 104 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, |
103 std::string(), content_setting); | 105 std::string(), content_setting); |
104 } | 106 } |
105 | 107 |
106 bool DurableStoragePermissionContext::IsRestrictedToSecureOrigins() const { | 108 bool DurableStoragePermissionContext::IsRestrictedToSecureOrigins() const { |
107 return true; | 109 return true; |
108 } | 110 } |
OLD | NEW |