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

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

Issue 2110343002: Reintroduce plumbing for user gesture into permission system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 5 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 16 matching lines...) Expand all
27 Profile* profile) 27 Profile* profile)
28 : PermissionContextBase(profile, 28 : PermissionContextBase(profile,
29 content::PermissionType::DURABLE_STORAGE, 29 content::PermissionType::DURABLE_STORAGE,
30 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {} 30 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) {}
31 31
32 void DurableStoragePermissionContext::DecidePermission( 32 void DurableStoragePermissionContext::DecidePermission(
33 content::WebContents* web_contents, 33 content::WebContents* web_contents,
34 const PermissionRequestID& id, 34 const PermissionRequestID& id,
35 const GURL& requesting_origin, 35 const GURL& requesting_origin,
36 const GURL& embedding_origin, 36 const GURL& embedding_origin,
37 bool user_gesture,
37 const BrowserPermissionCallback& callback) { 38 const BrowserPermissionCallback& callback) {
38 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 39 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
39 40
40 // TODO(dgrogan): Remove bookmarks check in favor of site engagement. In the 41 // TODO(dgrogan): Remove bookmarks check in favor of site engagement. In the
41 // meantime maybe grant permission to A2HS origins as well. 42 // meantime maybe grant permission to A2HS origins as well.
42 BookmarkModel* model = BookmarkModelFactory::GetForProfileIfExists(profile()); 43 BookmarkModel* model = BookmarkModelFactory::GetForProfileIfExists(profile());
43 if (model) { 44 if (model) {
44 std::vector<bookmarks::BookmarkModel::URLAndTitle> bookmarks; 45 std::vector<bookmarks::BookmarkModel::URLAndTitle> bookmarks;
45 model->GetBookmarks(&bookmarks); 46 model->GetBookmarks(&bookmarks);
46 if (IsOriginBookmarked(bookmarks, requesting_origin)) { 47 if (IsOriginBookmarked(bookmarks, requesting_origin)) {
(...skipping 30 matching lines...) Expand all
77 const std::vector<bookmarks::BookmarkModel::URLAndTitle>& bookmarks, 78 const std::vector<bookmarks::BookmarkModel::URLAndTitle>& bookmarks,
78 const GURL& origin) { 79 const GURL& origin) {
79 BookmarkModel::URLAndTitle looking_for; 80 BookmarkModel::URLAndTitle looking_for;
80 looking_for.url = origin; 81 looking_for.url = origin;
81 return std::binary_search(bookmarks.begin(), bookmarks.end(), looking_for, 82 return std::binary_search(bookmarks.begin(), bookmarks.end(), looking_for,
82 [](const BookmarkModel::URLAndTitle& a, 83 [](const BookmarkModel::URLAndTitle& a,
83 const BookmarkModel::URLAndTitle& b) { 84 const BookmarkModel::URLAndTitle& b) {
84 return a.url.GetOrigin() < b.url.GetOrigin(); 85 return a.url.GetOrigin() < b.url.GetOrigin();
85 }); 86 });
86 } 87 }
OLDNEW
« no previous file with comments | « chrome/browser/storage/durable_storage_permission_context.h ('k') | chromecast/browser/cast_permission_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698