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

Side by Side Diff: chrome/browser/storage/durable_storage_permission_context.cc

Issue 2627853002: Show the search geolocation disclosure from geolocation API use. (Closed)
Patch Set: Fix ChromeOS Created 3 years, 11 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
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(CONTENT_SETTING_ALLOW,
45 GetPermissionStatus(requesting_origin, embedding_origin)); 45 GetPermissionStatus(requesting_origin, embedding_origin));
46 DCHECK_NE(CONTENT_SETTING_BLOCK, 46 DCHECK_NE(CONTENT_SETTING_BLOCK,
47 GetPermissionStatus(requesting_origin, embedding_origin)); 47 GetPermissionStatus(requesting_origin, embedding_origin));
48 48
49 // Durable is only allowed to be granted to the top-level origin. Embedding 49 // 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. 50 // origin is the last committed navigation origin to the web contents.
51 if (requesting_origin != embedding_origin) { 51 if (requesting_origin != embedding_origin) {
52 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 52 NotifyPermissionSet(web_contents, id, requesting_origin, embedding_origin,
53 false /* persist */, CONTENT_SETTING_DEFAULT); 53 callback, false /* persist */, CONTENT_SETTING_DEFAULT);
54 return; 54 return;
55 } 55 }
56 56
57 // Don't grant durable if we can't write cookies. 57 // Don't grant durable if we can't write cookies.
58 scoped_refptr<content_settings::CookieSettings> cookie_settings = 58 scoped_refptr<content_settings::CookieSettings> cookie_settings =
59 CookieSettingsFactory::GetForProfile(profile()); 59 CookieSettingsFactory::GetForProfile(profile());
60 if (!cookie_settings->IsSettingCookieAllowed(requesting_origin, 60 if (!cookie_settings->IsSettingCookieAllowed(requesting_origin,
61 requesting_origin)) { 61 requesting_origin)) {
62 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 62 NotifyPermissionSet(web_contents, id, requesting_origin, embedding_origin,
63 false /* persist */, CONTENT_SETTING_DEFAULT); 63 callback, false /* persist */, CONTENT_SETTING_DEFAULT);
64 return; 64 return;
65 } 65 }
66 66
67 const size_t kMaxImportantResults = 10; 67 const size_t kMaxImportantResults = 10;
68 std::vector<ImportantSitesUtil::ImportantDomainInfo> important_sites = 68 std::vector<ImportantSitesUtil::ImportantDomainInfo> important_sites =
69 ImportantSitesUtil::GetImportantRegisterableDomains(profile(), 69 ImportantSitesUtil::GetImportantRegisterableDomains(profile(),
70 kMaxImportantResults); 70 kMaxImportantResults);
71 71
72 std::string registerable_domain = 72 std::string registerable_domain =
73 net::registry_controlled_domains::GetDomainAndRegistry( 73 net::registry_controlled_domains::GetDomainAndRegistry(
74 requesting_origin, 74 requesting_origin,
75 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 75 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
76 if (registerable_domain.empty() && requesting_origin.HostIsIPAddress()) 76 if (registerable_domain.empty() && requesting_origin.HostIsIPAddress())
77 registerable_domain = requesting_origin.host(); 77 registerable_domain = requesting_origin.host();
78 78
79 for (const auto& important_site : important_sites) { 79 for (const auto& important_site : important_sites) {
80 if (important_site.registerable_domain == registerable_domain) { 80 if (important_site.registerable_domain == registerable_domain) {
81 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 81 NotifyPermissionSet(web_contents, id, requesting_origin, embedding_origin,
82 true /* persist */, CONTENT_SETTING_ALLOW); 82 callback, true /* persist */, CONTENT_SETTING_ALLOW);
83 return; 83 return;
84 } 84 }
85 } 85 }
86 86
87 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 87 NotifyPermissionSet(web_contents, id, requesting_origin, embedding_origin,
88 false /* persist */, CONTENT_SETTING_DEFAULT); 88 callback, false /* persist */, CONTENT_SETTING_DEFAULT);
89 } 89 }
90 90
91 void DurableStoragePermissionContext::UpdateContentSetting( 91 void DurableStoragePermissionContext::UpdateContentSetting(
92 const GURL& requesting_origin, 92 const GURL& requesting_origin,
93 const GURL& embedding_origin_ignored, 93 const GURL& embedding_origin_ignored,
94 ContentSetting content_setting) { 94 ContentSetting content_setting) {
95 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); 95 DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin());
96 DCHECK_EQ(embedding_origin_ignored, embedding_origin_ignored.GetOrigin()); 96 DCHECK_EQ(embedding_origin_ignored, embedding_origin_ignored.GetOrigin());
97 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 97 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
98 content_setting == CONTENT_SETTING_BLOCK); 98 content_setting == CONTENT_SETTING_BLOCK);
99 99
100 HostContentSettingsMapFactory::GetForProfile(profile()) 100 HostContentSettingsMapFactory::GetForProfile(profile())
101 ->SetContentSettingDefaultScope(requesting_origin, GURL(), 101 ->SetContentSettingDefaultScope(requesting_origin, GURL(),
102 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, 102 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE,
103 std::string(), content_setting); 103 std::string(), content_setting);
104 } 104 }
105 105
106 bool DurableStoragePermissionContext::IsRestrictedToSecureOrigins() const { 106 bool DurableStoragePermissionContext::IsRestrictedToSecureOrigins() const {
107 return true; 107 return true;
108 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698