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

Side by Side Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 356543003: Audit the last usage of Geolocation and Notification permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add auditing for actual usage, too. Created 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/notifications/desktop_notification_service.h" 5 #include "chrome/browser/notifications/desktop_notification_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 CONTENT_SETTING_DEFAULT); 474 CONTENT_SETTING_DEFAULT);
475 } 475 }
476 476
477 void DesktopNotificationService::ResetAllOrigins() { 477 void DesktopNotificationService::ResetAllOrigins() {
478 profile_->GetHostContentSettingsMap()->ClearSettingsForOneType( 478 profile_->GetHostContentSettingsMap()->ClearSettingsForOneType(
479 CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 479 CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
480 } 480 }
481 481
482 ContentSetting DesktopNotificationService::GetContentSetting( 482 ContentSetting DesktopNotificationService::GetContentSetting(
483 const GURL& origin) { 483 const GURL& origin) {
484 return profile_->GetHostContentSettingsMap()->GetContentSetting( 484 return profile_->GetHostContentSettingsMap()
485 origin, 485 ->GetContentSettingAndMaybeUpdateLastUsage(
486 origin, 486 origin,
487 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 487 origin,
488 NO_RESOURCE_IDENTIFIER); 488 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
489 NO_RESOURCE_IDENTIFIER);
489 } 490 }
490 491
491 void DesktopNotificationService::RequestPermission( 492 void DesktopNotificationService::RequestPermission(
492 const GURL& origin, 493 const GURL& origin,
493 content::RenderFrameHost* render_frame_host, 494 content::RenderFrameHost* render_frame_host,
494 const base::Closure& callback) { 495 const base::Closure& callback) {
495 // If |origin| hasn't been seen before and the default content setting for 496 // If |origin| hasn't been seen before and the default content setting for
496 // notifications is "ask", show an infobar. 497 // notifications is "ask", show an infobar.
497 // The cache can only answer queries on the IO thread once it's initialized, 498 // The cache can only answer queries on the IO thread once it's initialized,
498 // so don't ask the cache. 499 // so don't ask the cache.
499 WebContents* web_contents = WebContents::FromRenderFrameHost( 500 WebContents* web_contents = WebContents::FromRenderFrameHost(
500 render_frame_host); 501 render_frame_host);
501 ContentSetting setting = GetContentSetting(origin); 502 ContentSetting setting = GetContentSetting(origin);
503
502 if (setting == CONTENT_SETTING_ASK) { 504 if (setting == CONTENT_SETTING_ASK) {
503 if (PermissionBubbleManager::Enabled()) { 505 if (PermissionBubbleManager::Enabled()) {
504 PermissionBubbleManager* bubble_manager = 506 PermissionBubbleManager* bubble_manager =
505 PermissionBubbleManager::FromWebContents(web_contents); 507 PermissionBubbleManager::FromWebContents(web_contents);
506 if (bubble_manager) { 508 if (bubble_manager) {
507 bubble_manager->AddRequest(new NotificationPermissionRequest( 509 bubble_manager->AddRequest(new NotificationPermissionRequest(
508 this, 510 this,
509 origin, 511 origin,
510 DisplayNameForOriginInProcessId( 512 DisplayNameForOriginInProcessId(
511 origin, render_frame_host->GetProcess()->GetID()), 513 origin, render_frame_host->GetProcess()->GetID()),
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // Tell the IO thread that this extension's permission for notifications 731 // Tell the IO thread that this extension's permission for notifications
730 // has changed. 732 // has changed.
731 extensions::InfoMap* extension_info_map = 733 extensions::InfoMap* extension_info_map =
732 extensions::ExtensionSystem::Get(profile_)->info_map(); 734 extensions::ExtensionSystem::Get(profile_)->info_map();
733 BrowserThread::PostTask( 735 BrowserThread::PostTask(
734 BrowserThread::IO, FROM_HERE, 736 BrowserThread::IO, FROM_HERE,
735 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 737 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
736 extension_info_map, notifier_id.id, !enabled)); 738 extension_info_map, notifier_id.id, !enabled));
737 #endif 739 #endif
738 } 740 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698