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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // notifications is "ask", show an infobar. | 507 // notifications is "ask", show an infobar. |
508 // The cache can only answer queries on the IO thread once it's initialized, | 508 // The cache can only answer queries on the IO thread once it's initialized, |
509 // so don't ask the cache. | 509 // so don't ask the cache. |
510 WebContents* web_contents = WebContents::FromRenderFrameHost( | 510 WebContents* web_contents = WebContents::FromRenderFrameHost( |
511 render_frame_host); | 511 render_frame_host); |
512 ContentSetting setting = GetContentSetting(origin); | 512 ContentSetting setting = GetContentSetting(origin); |
513 if (setting == CONTENT_SETTING_ASK) { | 513 if (setting == CONTENT_SETTING_ASK) { |
514 if (PermissionBubbleManager::Enabled()) { | 514 if (PermissionBubbleManager::Enabled()) { |
515 PermissionBubbleManager* bubble_manager = | 515 PermissionBubbleManager* bubble_manager = |
516 PermissionBubbleManager::FromWebContents(web_contents); | 516 PermissionBubbleManager::FromWebContents(web_contents); |
517 bubble_manager->AddRequest(new NotificationPermissionRequest( | 517 if (bubble_manager) { |
518 this, | 518 bubble_manager->AddRequest(new NotificationPermissionRequest( |
519 origin, | 519 this, |
520 DisplayNameForOriginInProcessId( | 520 origin, |
521 origin, render_frame_host->GetProcess()->GetID()), | 521 DisplayNameForOriginInProcessId( |
522 callback)); | 522 origin, render_frame_host->GetProcess()->GetID()), |
| 523 callback)); |
| 524 } |
523 return; | 525 return; |
524 } | 526 } |
525 | 527 |
526 // Show an info bar requesting permission. | 528 // Show an info bar requesting permission. |
527 InfoBarService* infobar_service = | 529 InfoBarService* infobar_service = |
528 InfoBarService::FromWebContents(web_contents); | 530 InfoBarService::FromWebContents(web_contents); |
529 // |infobar_service| may be NULL, e.g., if this request originated in a | 531 // |infobar_service| may be NULL, e.g., if this request originated in a |
530 // browser action popup, extension background page, or any HTML that runs | 532 // browser action popup, extension background page, or any HTML that runs |
531 // outside of a tab. | 533 // outside of a tab. |
532 if (infobar_service) { | 534 if (infobar_service) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 // Tell the IO thread that this extension's permission for notifications | 750 // Tell the IO thread that this extension's permission for notifications |
749 // has changed. | 751 // has changed. |
750 extensions::InfoMap* extension_info_map = | 752 extensions::InfoMap* extension_info_map = |
751 extensions::ExtensionSystem::Get(profile_)->info_map(); | 753 extensions::ExtensionSystem::Get(profile_)->info_map(); |
752 BrowserThread::PostTask( | 754 BrowserThread::PostTask( |
753 BrowserThread::IO, FROM_HERE, | 755 BrowserThread::IO, FROM_HERE, |
754 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 756 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
755 extension_info_map, notifier_id.id, !enabled)); | 757 extension_info_map, notifier_id.id, !enabled)); |
756 #endif | 758 #endif |
757 } | 759 } |
OLD | NEW |