| 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 23 matching lines...) Expand all Loading... |
| 34 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {} | 34 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {} |
| 35 | 35 |
| 36 void DurableStoragePermissionContext::DecidePermission( | 36 void DurableStoragePermissionContext::DecidePermission( |
| 37 content::WebContents* web_contents, | 37 content::WebContents* web_contents, |
| 38 const PermissionRequestID& id, | 38 const PermissionRequestID& id, |
| 39 const GURL& requesting_origin, | 39 const GURL& requesting_origin, |
| 40 const GURL& embedding_origin, | 40 const GURL& embedding_origin, |
| 41 bool user_gesture, | 41 bool user_gesture, |
| 42 const BrowserPermissionCallback& callback) { | 42 const BrowserPermissionCallback& callback) { |
| 43 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 43 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 44 DCHECK_NE(CONTENT_SETTING_ALLOW, | 44 DCHECK_NE( |
| 45 GetPermissionStatus(requesting_origin, embedding_origin)); | 45 CONTENT_SETTING_ALLOW, |
| 46 DCHECK_NE(CONTENT_SETTING_BLOCK, | 46 GetPermissionStatus(requesting_origin, embedding_origin).content_setting); |
| 47 GetPermissionStatus(requesting_origin, embedding_origin)); | 47 DCHECK_NE( |
| 48 CONTENT_SETTING_BLOCK, |
| 49 GetPermissionStatus(requesting_origin, embedding_origin).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 |