Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | 426 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, |
| 427 content::Source<Profile>(profile_)); | 427 content::Source<Profile>(profile_)); |
| 428 } | 428 } |
| 429 | 429 |
| 430 DesktopNotificationService::~DesktopNotificationService() { | 430 DesktopNotificationService::~DesktopNotificationService() { |
| 431 } | 431 } |
| 432 | 432 |
| 433 void DesktopNotificationService::GrantPermission(const GURL& origin) { | 433 void DesktopNotificationService::GrantPermission(const GURL& origin) { |
| 434 ContentSettingsPattern primary_pattern = | 434 ContentSettingsPattern primary_pattern = |
| 435 ContentSettingsPattern::FromURLNoWildcard(origin); | 435 ContentSettingsPattern::FromURLNoWildcard(origin); |
| 436 profile_->GetHostContentSettingsMap()->UpdateLastUsage( | |
|
dewittj
2014/06/26 15:56:51
Why isn't this just done inside SetContentSetting?
Daniel Nishi
2014/06/26 20:31:25
Good point. I've moved this part into SetContentSe
| |
| 437 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | |
| 436 profile_->GetHostContentSettingsMap()->SetContentSetting( | 438 profile_->GetHostContentSettingsMap()->SetContentSetting( |
| 437 primary_pattern, | 439 primary_pattern, |
| 438 ContentSettingsPattern::Wildcard(), | 440 ContentSettingsPattern::Wildcard(), |
| 439 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 441 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 440 NO_RESOURCE_IDENTIFIER, | 442 NO_RESOURCE_IDENTIFIER, |
| 441 CONTENT_SETTING_ALLOW); | 443 CONTENT_SETTING_ALLOW); |
| 442 } | 444 } |
| 443 | 445 |
| 444 void DesktopNotificationService::DenyPermission(const GURL& origin) { | 446 void DesktopNotificationService::DenyPermission(const GURL& origin) { |
| 445 ContentSettingsPattern primary_pattern = | 447 ContentSettingsPattern primary_pattern = |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 const GURL& origin, | 507 const GURL& origin, |
| 506 content::RenderFrameHost* render_frame_host, | 508 content::RenderFrameHost* render_frame_host, |
| 507 const base::Closure& callback) { | 509 const base::Closure& callback) { |
| 508 // If |origin| hasn't been seen before and the default content setting for | 510 // If |origin| hasn't been seen before and the default content setting for |
| 509 // notifications is "ask", show an infobar. | 511 // notifications is "ask", show an infobar. |
| 510 // The cache can only answer queries on the IO thread once it's initialized, | 512 // The cache can only answer queries on the IO thread once it's initialized, |
| 511 // so don't ask the cache. | 513 // so don't ask the cache. |
| 512 WebContents* web_contents = WebContents::FromRenderFrameHost( | 514 WebContents* web_contents = WebContents::FromRenderFrameHost( |
| 513 render_frame_host); | 515 render_frame_host); |
| 514 ContentSetting setting = GetContentSetting(origin); | 516 ContentSetting setting = GetContentSetting(origin); |
| 517 | |
| 518 if (setting == CONTENT_SETTING_ALLOW) { | |
|
dewittj
2014/06/26 15:56:51
why only content setting allow? This is probably
Daniel Nishi
2014/06/26 20:31:25
It's on allow because we're trying to track when t
| |
| 519 profile_->GetHostContentSettingsMap()->UpdateLastUsage( | |
| 520 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | |
| 521 } | |
| 522 | |
| 515 if (setting == CONTENT_SETTING_ASK) { | 523 if (setting == CONTENT_SETTING_ASK) { |
| 516 if (PermissionBubbleManager::Enabled()) { | 524 if (PermissionBubbleManager::Enabled()) { |
| 517 PermissionBubbleManager* bubble_manager = | 525 PermissionBubbleManager* bubble_manager = |
| 518 PermissionBubbleManager::FromWebContents(web_contents); | 526 PermissionBubbleManager::FromWebContents(web_contents); |
| 519 if (bubble_manager) { | 527 if (bubble_manager) { |
| 520 bubble_manager->AddRequest(new NotificationPermissionRequest( | 528 bubble_manager->AddRequest(new NotificationPermissionRequest( |
| 521 this, | 529 this, |
| 522 origin, | 530 origin, |
| 523 DisplayNameForOriginInProcessId( | 531 DisplayNameForOriginInProcessId( |
| 524 origin, render_frame_host->GetProcess()->GetID()), | 532 origin, render_frame_host->GetProcess()->GetID()), |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 // Tell the IO thread that this extension's permission for notifications | 760 // Tell the IO thread that this extension's permission for notifications |
| 753 // has changed. | 761 // has changed. |
| 754 extensions::InfoMap* extension_info_map = | 762 extensions::InfoMap* extension_info_map = |
| 755 extensions::ExtensionSystem::Get(profile_)->info_map(); | 763 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 756 BrowserThread::PostTask( | 764 BrowserThread::PostTask( |
| 757 BrowserThread::IO, FROM_HERE, | 765 BrowserThread::IO, FROM_HERE, |
| 758 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 766 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 759 extension_info_map, notifier_id.id, !enabled)); | 767 extension_info_map, notifier_id.id, !enabled)); |
| 760 #endif | 768 #endif |
| 761 } | 769 } |
| OLD | NEW |