Chromium Code Reviews| Index: chrome/browser/storage/durable_storage_permission_context.cc |
| diff --git a/chrome/browser/storage/durable_storage_permission_context.cc b/chrome/browser/storage/durable_storage_permission_context.cc |
| index 5d3c29e74d1ac0da56e045225348616f6594fa6f..1152910cf64b529edeb81cae3723842b2105464e 100644 |
| --- a/chrome/browser/storage/durable_storage_permission_context.cc |
| +++ b/chrome/browser/storage/durable_storage_permission_context.cc |
| @@ -11,6 +11,7 @@ |
| #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| +#include "chrome/browser/engagement/important_sites_util.h" |
| #include "chrome/browser/permissions/permission_request_id.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "components/bookmarks/browser/bookmark_model.h" |
| @@ -21,10 +22,13 @@ |
| #include "content/public/browser/child_process_security_policy.h" |
| #include "content/public/browser/permission_type.h" |
| #include "content/public/common/origin_util.h" |
| +#include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| #include "url/gurl.h" |
| using bookmarks::BookmarkModel; |
| +namespace {} // namespace |
|
raymes
2016/10/05 23:04:27
nit: is this still needed?
dmurph
2016/10/06 01:02:00
Done.
|
| + |
| DurableStoragePermissionContext::DurableStoragePermissionContext( |
| Profile* profile) |
| : PermissionContextBase(profile, |
| @@ -62,13 +66,20 @@ void DurableStoragePermissionContext::DecidePermission( |
| return; |
| } |
| - // TODO(dmurph): Remove bookmarks check in favor of important sites. |
| - BookmarkModel* model = |
| - BookmarkModelFactory::GetForBrowserContextIfExists(profile()); |
| - if (model) { |
| - std::vector<bookmarks::BookmarkModel::URLAndTitle> bookmarks; |
| - model->GetBookmarks(&bookmarks); |
| - if (IsOriginBookmarked(bookmarks, requesting_origin)) { |
| + static const size_t kMaxImportantResults = 10; |
|
michaeln
2016/10/05 23:27:45
why static? i dont see the need for static here
an
dmurph
2016/10/06 01:02:00
We discussed this on the bug, we are limiting the
|
| + std::vector<ImportantSitesUtil::ImportantDomainInfo> important_sites = |
| + ImportantSitesUtil::GetImportantRegisterableDomains(profile(), |
| + kMaxImportantResults); |
| + |
| + std::string registerable_domain = |
| + net::registry_controlled_domains::GetDomainAndRegistry( |
| + requesting_origin, |
| + net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| + if (registerable_domain.empty() && requesting_origin.HostIsIPAddress()) |
| + registerable_domain = requesting_origin.host(); |
| + |
| + for (const auto& important_site : important_sites) { |
| + if (important_site.registerable_domain == registerable_domain) { |
|
michaeln
2016/10/05 23:27:45
maybe not for this cl, but nice utlits could be
Im
dmurph
2016/10/06 01:02:00
SGTM, I'll make that in another CL.
|
| NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| true /* persist */, CONTENT_SETTING_ALLOW); |
| return; |
| @@ -97,15 +108,3 @@ void DurableStoragePermissionContext::UpdateContentSetting( |
| bool DurableStoragePermissionContext::IsRestrictedToSecureOrigins() const { |
| return true; |
| } |
| - |
| -bool DurableStoragePermissionContext::IsOriginBookmarked( |
| - const std::vector<bookmarks::BookmarkModel::URLAndTitle>& bookmarks, |
| - const GURL& origin) { |
| - BookmarkModel::URLAndTitle looking_for; |
| - looking_for.url = origin; |
| - return std::binary_search(bookmarks.begin(), bookmarks.end(), looking_for, |
| - [](const BookmarkModel::URLAndTitle& a, |
| - const BookmarkModel::URLAndTitle& b) { |
| - return a.url.GetOrigin() < b.url.GetOrigin(); |
| - }); |
| -} |