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

Side by Side Diff: chrome/browser/permissions/permission_manager.cc

Issue 2697473002: Remove last usage functions from HostContentSettingsMap and clean up prefs (Closed)
Patch Set: adjust a comment Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/permissions/permission_manager.h" 5 #include "chrome/browser/permissions/permission_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 PermissionType permission, 417 PermissionType permission,
418 const GURL& requesting_origin, 418 const GURL& requesting_origin,
419 const GURL& embedding_origin) { 419 const GURL& embedding_origin) {
420 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 420 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
421 if (IsConstantPermission(permission)) 421 if (IsConstantPermission(permission))
422 return GetPermissionStatusForConstantPermission(permission); 422 return GetPermissionStatusForConstantPermission(permission);
423 return GetPermissionStatus(PermissionTypeToContentSetting(permission), 423 return GetPermissionStatus(PermissionTypeToContentSetting(permission),
424 requesting_origin, embedding_origin); 424 requesting_origin, embedding_origin);
425 } 425 }
426 426
427 void PermissionManager::RegisterPermissionUsage(PermissionType permission,
428 const GURL& requesting_origin,
429 const GURL& embedding_origin) {
430 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
431 // This is required because constant permissions don't have a
432 // ContentSettingsType.
433 if (IsConstantPermission(permission))
434 return;
435
436 HostContentSettingsMapFactory::GetForProfile(profile_)->UpdateLastUsage(
437 requesting_origin,
438 embedding_origin,
439 PermissionTypeToContentSetting(permission));
440 }
441
442 int PermissionManager::SubscribePermissionStatusChange( 427 int PermissionManager::SubscribePermissionStatusChange(
443 PermissionType permission, 428 PermissionType permission,
444 const GURL& requesting_origin, 429 const GURL& requesting_origin,
445 const GURL& embedding_origin, 430 const GURL& embedding_origin,
446 const base::Callback<void(PermissionStatus)>& callback) { 431 const base::Callback<void(PermissionStatus)>& callback) {
447 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 432 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
448 if (subscriptions_.IsEmpty()) 433 if (subscriptions_.IsEmpty())
449 HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this); 434 HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this);
450 435
451 auto subscription = base::MakeUnique<Subscription>(); 436 auto subscription = base::MakeUnique<Subscription>();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 subscription->current_value = new_value; 495 subscription->current_value = new_value;
511 496
512 // Add the callback to |callbacks| which will be run after the loop to 497 // Add the callback to |callbacks| which will be run after the loop to
513 // prevent re-entrance issues. 498 // prevent re-entrance issues.
514 callbacks.push_back(base::Bind(subscription->callback, new_value)); 499 callbacks.push_back(base::Bind(subscription->callback, new_value));
515 } 500 }
516 501
517 for (const auto& callback : callbacks) 502 for (const auto& callback : callbacks)
518 callback.Run(); 503 callback.Run();
519 } 504 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698