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

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

Issue 409643002: Remove DEPRECATED extension notification from desktop_notification_service.* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "net/base/escape.h" 46 #include "net/base/escape.h"
47 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
48 #include "ui/base/resource/resource_bundle.h" 48 #include "ui/base/resource/resource_bundle.h"
49 #include "ui/base/webui/web_ui_util.h" 49 #include "ui/base/webui/web_ui_util.h"
50 #include "ui/message_center/notifier_settings.h" 50 #include "ui/message_center/notifier_settings.h"
51 51
52 #if defined(ENABLE_EXTENSIONS) 52 #if defined(ENABLE_EXTENSIONS)
53 #include "chrome/browser/extensions/api/notifications/notifications_api.h" 53 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
54 #include "chrome/browser/extensions/extension_service.h" 54 #include "chrome/browser/extensions/extension_service.h"
55 #include "extensions/browser/event_router.h" 55 #include "extensions/browser/event_router.h"
56 #include "extensions/browser/extension_registry.h"
56 #include "extensions/browser/extension_system.h" 57 #include "extensions/browser/extension_system.h"
57 #include "extensions/browser/extension_util.h" 58 #include "extensions/browser/extension_util.h"
58 #include "extensions/browser/info_map.h" 59 #include "extensions/browser/info_map.h"
59 #include "extensions/common/constants.h" 60 #include "extensions/common/constants.h"
60 #include "extensions/common/extension.h" 61 #include "extensions/common/extension.h"
61 #include "extensions/common/extension_set.h" 62 #include "extensions/common/extension_set.h"
62 #endif 63 #endif
63 64
64 using blink::WebTextDirection; 65 using blink::WebTextDirection;
65 using content::BrowserThread; 66 using content::BrowserThread;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 blink::WebTextDirectionDefault, 381 blink::WebTextDirectionDefault,
381 base::string16(), replace_id, delegate); 382 base::string16(), replace_id, delegate);
382 g_browser_process->notification_ui_manager()->Add(notification, profile); 383 g_browser_process->notification_ui_manager()->Add(notification, profile);
383 return notification.delegate_id(); 384 return notification.delegate_id();
384 } 385 }
385 386
386 DesktopNotificationService::DesktopNotificationService( 387 DesktopNotificationService::DesktopNotificationService(
387 Profile* profile, 388 Profile* profile,
388 NotificationUIManager* ui_manager) 389 NotificationUIManager* ui_manager)
389 : profile_(profile), 390 : profile_(profile),
390 ui_manager_(ui_manager) { 391 ui_manager_(ui_manager),
392 extension_registry_observer_(this) {
391 OnStringListPrefChanged( 393 OnStringListPrefChanged(
392 prefs::kMessageCenterDisabledExtensionIds, &disabled_extension_ids_); 394 prefs::kMessageCenterDisabledExtensionIds, &disabled_extension_ids_);
393 OnStringListPrefChanged( 395 OnStringListPrefChanged(
394 prefs::kMessageCenterDisabledSystemComponentIds, 396 prefs::kMessageCenterDisabledSystemComponentIds,
395 &disabled_system_component_ids_); 397 &disabled_system_component_ids_);
396 disabled_extension_id_pref_.Init( 398 disabled_extension_id_pref_.Init(
397 prefs::kMessageCenterDisabledExtensionIds, 399 prefs::kMessageCenterDisabledExtensionIds,
398 profile_->GetPrefs(), 400 profile_->GetPrefs(),
399 base::Bind( 401 base::Bind(
400 &DesktopNotificationService::OnStringListPrefChanged, 402 &DesktopNotificationService::OnStringListPrefChanged,
401 base::Unretained(this), 403 base::Unretained(this),
402 base::Unretained(prefs::kMessageCenterDisabledExtensionIds), 404 base::Unretained(prefs::kMessageCenterDisabledExtensionIds),
403 base::Unretained(&disabled_extension_ids_))); 405 base::Unretained(&disabled_extension_ids_)));
404 disabled_system_component_id_pref_.Init( 406 disabled_system_component_id_pref_.Init(
405 prefs::kMessageCenterDisabledSystemComponentIds, 407 prefs::kMessageCenterDisabledSystemComponentIds,
406 profile_->GetPrefs(), 408 profile_->GetPrefs(),
407 base::Bind( 409 base::Bind(
408 &DesktopNotificationService::OnStringListPrefChanged, 410 &DesktopNotificationService::OnStringListPrefChanged,
409 base::Unretained(this), 411 base::Unretained(this),
410 base::Unretained(prefs::kMessageCenterDisabledSystemComponentIds), 412 base::Unretained(prefs::kMessageCenterDisabledSystemComponentIds),
411 base::Unretained(&disabled_system_component_ids_))); 413 base::Unretained(&disabled_system_component_ids_)));
412 registrar_.Add(this, 414 extension_registry_observer_.Add(
413 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, 415 extensions::ExtensionRegistry::Get(profile_));
414 content::Source<Profile>(profile_));
415 } 416 }
416 417
417 DesktopNotificationService::~DesktopNotificationService() { 418 DesktopNotificationService::~DesktopNotificationService() {
418 } 419 }
419 420
420 void DesktopNotificationService::GrantPermission(const GURL& origin) { 421 void DesktopNotificationService::GrantPermission(const GURL& origin) {
421 ContentSettingsPattern primary_pattern = 422 ContentSettingsPattern primary_pattern =
422 ContentSettingsPattern::FromURLNoWildcard(origin); 423 ContentSettingsPattern::FromURLNoWildcard(origin);
423 profile_->GetHostContentSettingsMap()->SetContentSetting( 424 profile_->GetHostContentSettingsMap()->SetContentSetting(
424 primary_pattern, 425 primary_pattern,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 const base::ListValue* pref_list = pref_service->GetList(pref_name); 684 const base::ListValue* pref_list = pref_service->GetList(pref_name);
684 for (size_t i = 0; i < pref_list->GetSize(); ++i) { 685 for (size_t i = 0; i < pref_list->GetSize(); ++i) {
685 std::string element; 686 std::string element;
686 if (pref_list->GetString(i, &element) && !element.empty()) 687 if (pref_list->GetString(i, &element) && !element.empty())
687 ids_field->insert(element); 688 ids_field->insert(element);
688 else 689 else
689 LOG(WARNING) << i << "-th element is not a string for " << pref_name; 690 LOG(WARNING) << i << "-th element is not a string for " << pref_name;
690 } 691 }
691 } 692 }
692 693
693 void DesktopNotificationService::Observe( 694 void DesktopNotificationService::OnExtensionUninstalled(
694 int type, 695 content::BrowserContext* browser_context,
695 const content::NotificationSource& source, 696 const extensions::Extension* extension,
696 const content::NotificationDetails& details) { 697 extensions::UninstallReason reason) {
697 #if defined(ENABLE_EXTENSIONS) 698 #if defined(ENABLE_EXTENSIONS)
698 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, type);
699
700 extensions::Extension* extension =
701 content::Details<extensions::Extension>(details).ptr();
702 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); 699 NotifierId notifier_id(NotifierId::APPLICATION, extension->id());
703 if (IsNotifierEnabled(notifier_id)) 700 if (IsNotifierEnabled(notifier_id))
704 return; 701 return;
705 702
706 // The settings for ephemeral apps will be persisted across cache evictions. 703 // The settings for ephemeral apps will be persisted across cache evictions.
707 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) 704 if (extensions::util::IsEphemeralApp(extension->id(), profile_))
708 return; 705 return;
709 706
710 SetNotifierEnabled(notifier_id, true); 707 SetNotifierEnabled(notifier_id, true);
711 #endif 708 #endif
(...skipping 18 matching lines...) Expand all
730 // Tell the IO thread that this extension's permission for notifications 727 // Tell the IO thread that this extension's permission for notifications
731 // has changed. 728 // has changed.
732 extensions::InfoMap* extension_info_map = 729 extensions::InfoMap* extension_info_map =
733 extensions::ExtensionSystem::Get(profile_)->info_map(); 730 extensions::ExtensionSystem::Get(profile_)->info_map();
734 BrowserThread::PostTask( 731 BrowserThread::PostTask(
735 BrowserThread::IO, FROM_HERE, 732 BrowserThread::IO, FROM_HERE,
736 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 733 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
737 extension_info_map, notifier_id.id, !enabled)); 734 extension_info_map, notifier_id.id, !enabled));
738 #endif 735 #endif
739 } 736 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698