diff options
14 files changed, 141 insertions, 148 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 7604bac3..2886537 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -1948,31 +1948,37 @@ blink::WebNotificationPresenter::Permission int render_process_id) { #if defined(ENABLE_NOTIFICATIONS) DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - // Sometimes a notification may be invoked during the shutdown. - // See http://crbug.com/256638 - if (browser_shutdown::IsTryingToQuit()) - return blink::WebNotificationPresenter::PermissionNotAllowed; ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); - - DesktopNotificationService* notification_service = - io_data->GetNotificationService(); - if (notification_service) { - InfoMap* extension_info_map = io_data->GetExtensionInfoMap(); - ExtensionSet extensions; - extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( - source_origin, render_process_id, - extensions::APIPermission::kNotification, &extensions); - for (ExtensionSet::const_iterator iter = extensions.begin(); - iter != extensions.end(); ++iter) { - NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id()); - if (notification_service->IsNotifierEnabled(notifier_id)) - return blink::WebNotificationPresenter::PermissionAllowed; - } - - return notification_service->HasPermission(source_origin); - } - + InfoMap* extension_info_map = io_data->GetExtensionInfoMap(); + + // We want to see if there is an extension that hasn't been manually disabled + // that has the notifications permission and applies to this security origin. + // First, get the list of extensions with permission for the origin. + ExtensionSet extensions; + extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( + source_origin, render_process_id, + extensions::APIPermission::kNotification, &extensions); + for (ExtensionSet::const_iterator iter = extensions.begin(); + iter != extensions.end(); ++iter) { + // Then, check to see if it's been disabled by the user. + if (!extension_info_map->AreNotificationsDisabled((*iter)->id())) + return blink::WebNotificationPresenter::PermissionAllowed; + } + + // No enabled extensions exist, so check the normal host content settings. + HostContentSettingsMap* host_content_settings_map = + io_data->GetHostContentSettingsMap(); + ContentSetting setting = host_content_settings_map->GetContentSetting( + source_origin, + source_origin, + CONTENT_SETTINGS_TYPE_NOTIFICATIONS, + NO_RESOURCE_IDENTIFIER); + + if (setting == CONTENT_SETTING_ALLOW) + return blink::WebNotificationPresenter::PermissionAllowed; + if (setting == CONTENT_SETTING_BLOCK) + return blink::WebNotificationPresenter::PermissionDenied; return blink::WebNotificationPresenter::PermissionNotAllowed; #else return blink::WebNotificationPresenter::PermissionAllowed; diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc index ab6ec9a..b2054cb 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc @@ -125,10 +125,14 @@ void WebRequestActionWithThreadsTest::SetUp() { extension_info_map_ = new InfoMap; ASSERT_TRUE(extension_info_map_.get()); extension_info_map_->AddExtension( - extension_.get(), base::Time::Now(), false /*incognito_enabled*/); + extension_.get(), + base::Time::Now(), + false /*incognito_enabled*/, + false /*notifications_disabled*/); extension_info_map_->AddExtension(extension_all_urls_.get(), base::Time::Now(), - false /*incognito_enabled*/); + false /*incognito_enabled*/, + false /*notifications_disabled*/); } bool WebRequestActionWithThreadsTest::ActionWorksOnRequest( diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc index b2cce2c..93de526 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc @@ -256,10 +256,12 @@ void WebRequestRulesRegistryTest::SetUp() { ASSERT_TRUE(extension_info_map_.get()); extension_info_map_->AddExtension(extension_.get(), base::Time() + base::TimeDelta::FromDays(1), - false /*incognito_enabled*/); + false /*incognito_enabled*/, + false /*notifications_disabled*/); extension_info_map_->AddExtension(extension2_.get(), base::Time() + base::TimeDelta::FromDays(2), - false /*incognito_enabled*/); + false /*incognito_enabled*/, + false /*notifications_disabled*/); } diff --git a/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc b/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc index 1157807..c9e03b0 100644 --- a/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc @@ -63,9 +63,13 @@ void ExtensionWebRequestHelpersTestWithThreadsTest::SetUp() { extension_info_map_ = new extensions::InfoMap; extension_info_map_->AddExtension(permissionless_extension_.get(), base::Time::Now(), - false /*incognito_enabled*/); + false /*incognito_enabled*/, + false /*notifications_disabled*/); extension_info_map_->AddExtension( - com_extension_.get(), base::Time::Now(), false /*incognito_enabled*/); + com_extension_.get(), + base::Time::Now(), + false /*incognito_enabled*/, + false /*notifications_disabled*/); } TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest, TestHideRequestForURL) { diff --git a/chrome/browser/extensions/extension_protocols_unittest.cc b/chrome/browser/extensions/extension_protocols_unittest.cc index ede181d..0bfa1d7 100644 --- a/chrome/browser/extensions/extension_protocols_unittest.cc +++ b/chrome/browser/extensions/extension_protocols_unittest.cc @@ -165,7 +165,7 @@ TEST_F(ExtensionProtocolTest, IncognitoRequest) { scoped_refptr<Extension> extension = CreateTestExtension(cases[i].name, cases[i].incognito_split_mode); extension_info_map_->AddExtension( - extension.get(), base::Time::Now(), cases[i].incognito_enabled); + extension.get(), base::Time::Now(), cases[i].incognito_enabled, false); // First test a main frame request. { @@ -225,7 +225,10 @@ TEST_F(ExtensionProtocolTest, ComponentResourceRequest) { SetProtocolHandler(false); scoped_refptr<Extension> extension = CreateWebStoreExtension(); - extension_info_map_->AddExtension(extension.get(), base::Time::Now(), false); + extension_info_map_->AddExtension(extension.get(), + base::Time::Now(), + false, + false); // First test it with the extension enabled. { @@ -259,7 +262,10 @@ TEST_F(ExtensionProtocolTest, ResourceRequestResponseHeaders) { SetProtocolHandler(false); scoped_refptr<Extension> extension = CreateTestResponseHeaderExtension(); - extension_info_map_->AddExtension(extension.get(), base::Time::Now(), false); + extension_info_map_->AddExtension(extension.get(), + base::Time::Now(), + false, + false); { net::URLRequest request(extension->GetResourceURL("test.dat"), @@ -294,7 +300,10 @@ TEST_F(ExtensionProtocolTest, AllowFrameRequests) { SetProtocolHandler(false); scoped_refptr<Extension> extension = CreateTestExtension("foo", false); - extension_info_map_->AddExtension(extension.get(), base::Time::Now(), false); + extension_info_map_->AddExtension(extension.get(), + base::Time::Now(), + false, + false); // All MAIN_FRAME and SUB_FRAME requests should succeed. { diff --git a/chrome/browser/extensions/extension_system.cc b/chrome/browser/extensions/extension_system.cc index 3bbfead..3062ef9 100644 --- a/chrome/browser/extensions/extension_system.cc +++ b/chrome/browser/extensions/extension_system.cc @@ -46,6 +46,12 @@ #include "extensions/common/constants.h" #include "extensions/common/manifest.h" +#if defined(ENABLE_NOTIFICATIONS) +#include "chrome/browser/notifications/desktop_notification_service.h" +#include "chrome/browser/notifications/desktop_notification_service_factory.h" +#include "ui/message_center/notifier_settings.h" +#endif + #if defined(OS_CHROMEOS) #include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/chromeos/extensions/device_local_account_management_policy_provider.h" @@ -397,13 +403,24 @@ void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( } bool incognito_enabled = extension_util::IsIncognitoEnabled(extension->id(), extension_service()); - BrowserThread::PostTask(BrowserThread::IO, - FROM_HERE, - base::Bind(&InfoMap::AddExtension, - info_map(), - make_scoped_refptr(extension), - install_time, - incognito_enabled)); + + bool notifications_disabled = false; +#if defined(ENABLE_NOTIFICATIONS) + message_center::NotifierId notifier_id( + message_center::NotifierId::APPLICATION, + extension->id()); + + DesktopNotificationService* notification_service = + DesktopNotificationServiceFactory::GetForProfile(profile_); + notifications_disabled = + !notification_service->IsNotifierEnabled(notifier_id); +#endif + + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&InfoMap::AddExtension, info_map(), + make_scoped_refptr(extension), install_time, + incognito_enabled, notifications_disabled)); } void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 6fbaa2a..2863ce7 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -58,7 +58,6 @@ using content::BrowserThread; using content::RenderViewHost; using content::WebContents; using message_center::NotifierId; -using blink::WebNotificationPresenter; using blink::WebTextDirection; @@ -650,27 +649,6 @@ void DesktopNotificationService::OnStringListPrefChanged( } } -blink::WebNotificationPresenter::Permission - DesktopNotificationService::HasPermission(const GURL& origin) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - HostContentSettingsMap* host_content_settings_map = - profile_->GetHostContentSettingsMap(); - ContentSetting setting = host_content_settings_map->GetContentSetting( - origin, - origin, - CONTENT_SETTINGS_TYPE_NOTIFICATIONS, - NO_RESOURCE_IDENTIFIER); - - if (setting == CONTENT_SETTING_ALLOW) - return blink::WebNotificationPresenter::PermissionAllowed; - if (setting == CONTENT_SETTING_BLOCK) - return blink::WebNotificationPresenter::PermissionDenied; - if (setting == CONTENT_SETTING_ASK) - return blink::WebNotificationPresenter::PermissionNotAllowed; - NOTREACHED() << "Invalid notifications settings value: " << setting; - return blink::WebNotificationPresenter::PermissionNotAllowed; -} - void DesktopNotificationService::Observe( int type, const content::NotificationSource& source, @@ -700,4 +678,14 @@ void DesktopNotificationService::FirePermissionLevelChangedEvent( args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> DispatchEventToExtension(notifier_id.id, event.Pass()); + + // Tell the IO thread that this extension's permission for notifications + // has changed. + extensions::InfoMap* extension_info_map = + extensions::ExtensionSystem::Get(profile_)->info_map(); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&extensions::InfoMap::SetNotificationsDisabled, + extension_info_map, notifier_id.id, !enabled)); + } diff --git a/chrome/browser/notifications/desktop_notification_service.h b/chrome/browser/notifications/desktop_notification_service.h index 61cc48b..c4bf961 100644 --- a/chrome/browser/notifications/desktop_notification_service.h +++ b/chrome/browser/notifications/desktop_notification_service.h @@ -151,11 +151,6 @@ class DesktopNotificationService : public BrowserContextKeyedService, ContentSetting GetContentSetting(const GURL& origin); - // Checks to see if a given origin has permission to create desktop - // notifications. - blink::WebNotificationPresenter::Permission - HasPermission(const GURL& origin); - // Returns true if the notifier with |notifier_id| is allowed to send // notifications. bool IsNotifierEnabled(const message_center::NotifierId& notifier_id); diff --git a/chrome/browser/notifications/desktop_notification_service_unittest.cc b/chrome/browser/notifications/desktop_notification_service_unittest.cc index adcbb84..3fcf7e7 100644 --- a/chrome/browser/notifications/desktop_notification_service_unittest.cc +++ b/chrome/browser/notifications/desktop_notification_service_unittest.cc @@ -27,43 +27,6 @@ class DesktopNotificationServiceTest : public ChromeRenderViewHostTestHarness { DesktopNotificationService* service_; }; -TEST_F(DesktopNotificationServiceTest, SettingsForSchemes) { - GURL url("file:///html/test.html"); - - EXPECT_EQ(CONTENT_SETTING_ASK, - service_->GetDefaultContentSetting(NULL)); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionNotAllowed, - service_->HasPermission(url)); - - service_->GrantPermission(url); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionAllowed, - service_->HasPermission(url)); - - service_->DenyPermission(url); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionDenied, - service_->HasPermission(url)); - - GURL https_url("https://testurl"); - GURL http_url("http://testurl"); - EXPECT_EQ(CONTENT_SETTING_ASK, - service_->GetDefaultContentSetting(NULL)); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionNotAllowed, - service_->HasPermission(http_url)); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionNotAllowed, - service_->HasPermission(https_url)); - - service_->GrantPermission(https_url); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionNotAllowed, - service_->HasPermission(http_url)); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionAllowed, - service_->HasPermission(https_url)); - - service_->DenyPermission(http_url); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionDenied, - service_->HasPermission(http_url)); - EXPECT_EQ(blink::WebNotificationPresenter::PermissionAllowed, - service_->HasPermission(https_url)); -} TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) { service_->GrantPermission(GURL("http://allowed2.com")); diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 758dc88..4d8610e 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -44,7 +44,6 @@ #include "chrome/browser/net/load_time_stats.h" #include "chrome/browser/net/proxy_service_factory.h" #include "chrome/browser/net/resource_prefetch_predictor_observer.h" -#include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/policy/url_blacklist_manager.h" #include "chrome/browser/predictors/resource_prefetch_predictor.h" #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" @@ -255,11 +254,6 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { new chrome_browser_net::ResourcePrefetchPredictorObserver(predictor)); } -#if defined(ENABLE_NOTIFICATIONS) - params->notification_service = - DesktopNotificationServiceFactory::GetForProfile(profile); -#endif - ProtocolHandlerRegistry* protocol_handler_registry = ProtocolHandlerRegistryFactory::GetForProfile(profile); DCHECK(protocol_handler_registry); @@ -388,9 +382,6 @@ ProfileIOData::AppRequestContext::~AppRequestContext() {} ProfileIOData::ProfileParams::ProfileParams() : io_thread(NULL), -#if defined(ENABLE_NOTIFICATIONS) - notification_service(NULL), -#endif profile(NULL) { } @@ -398,9 +389,6 @@ ProfileIOData::ProfileParams::~ProfileParams() {} ProfileIOData::ProfileIOData(bool is_incognito) : initialized_(false), -#if defined(ENABLE_NOTIFICATIONS) - notification_service_(NULL), -#endif resource_context_(new ResourceContext(this)), load_time_stats_(NULL), initialized_on_UI_thread_(false), @@ -621,13 +609,6 @@ HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { return host_content_settings_map_.get(); } -#if defined(ENABLE_NOTIFICATIONS) -DesktopNotificationService* ProfileIOData::GetNotificationService() const { - DCHECK(initialized_); - return notification_service_; -} -#endif - void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); #if defined(OS_CHROMEOS) @@ -807,9 +788,6 @@ void ProfileIOData::Init(content::ProtocolHandlerMap* protocol_handlers) const { // Take ownership over these parameters. cookie_settings_ = profile_params_->cookie_settings; host_content_settings_map_ = profile_params_->host_content_settings_map; -#if defined(ENABLE_NOTIFICATIONS) - notification_service_ = profile_params_->notification_service; -#endif extension_info_map_ = profile_params_->extension_info_map; resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index 493a4a1..d820172 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -29,7 +29,6 @@ class ChromeHttpUserAgentSettings; class ChromeNetworkDelegate; class CookieSettings; -class DesktopNotificationService; class HostContentSettingsMap; class ManagedModeURLFilter; class Profile; @@ -119,10 +118,6 @@ class ProfileIOData { CookieSettings* GetCookieSettings() const; HostContentSettingsMap* GetHostContentSettingsMap() const; -#if defined(ENABLE_NOTIFICATIONS) - DesktopNotificationService* GetNotificationService() const; -#endif - IntegerPrefMember* session_startup_pref() const { return &session_startup_pref_; } @@ -256,10 +251,6 @@ class ProfileIOData { scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> resource_prefetch_predictor_observer_; -#if defined(ENABLE_NOTIFICATIONS) - DesktopNotificationService* notification_service; -#endif - // This pointer exists only as a means of conveying a url job factory // pointer from the protocol handler registry on the UI thread to the // the URLRequestContext on the IO thread. The consumer MUST take @@ -499,10 +490,6 @@ class ProfileIOData { mutable scoped_ptr<policy::PolicyCertVerifier> cert_verifier_; #endif -#if defined(ENABLE_NOTIFICATIONS) - mutable DesktopNotificationService* notification_service_; -#endif - mutable scoped_ptr<net::TransportSecurityPersister> transport_security_persister_; diff --git a/extensions/browser/info_map.cc b/extensions/browser/info_map.cc index f790868..012f719 100644 --- a/extensions/browser/info_map.cc +++ b/extensions/browser/info_map.cc @@ -29,6 +29,9 @@ struct InfoMap::ExtraData { // True if the user has allowed this extension to run in incognito mode. bool incognito_enabled; + // True if the user has disabled notifications for this extension manually. + bool notifications_disabled; + ExtraData(); ~ExtraData(); }; @@ -43,13 +46,15 @@ const ProcessMap& InfoMap::process_map() const { return process_map_; } void InfoMap::AddExtension(const Extension* extension, base::Time install_time, - bool incognito_enabled) { + bool incognito_enabled, + bool notifications_disabled) { CheckOnValidThread(); extensions_.Insert(extension); disabled_extensions_.Remove(extension->id()); extra_data_[extension->id()].install_time = install_time; extra_data_[extension->id()].incognito_enabled = incognito_enabled; + extra_data_[extension->id()].notifications_disabled = notifications_disabled; } void InfoMap::RemoveExtension(const std::string& extension_id, @@ -171,6 +176,22 @@ bool InfoMap::IsSigninProcess(int process_id) const { return process_id == signin_process_id_; } +void InfoMap::SetNotificationsDisabled( + const std::string& extension_id, + bool notifications_disabled) { + ExtraDataMap::iterator iter = extra_data_.find(extension_id); + if (iter != extra_data_.end()) + iter->second.notifications_disabled = notifications_disabled; +} + +bool InfoMap::AreNotificationsDisabled( + const std::string& extension_id) const { + ExtraDataMap::const_iterator iter = extra_data_.find(extension_id); + if (iter != extra_data_.end()) + return iter->second.notifications_disabled; + return false; +} + InfoMap::~InfoMap() { if (quota_service_) { BrowserThread::DeleteSoon( diff --git a/extensions/browser/info_map.h b/extensions/browser/info_map.h index d68933f..407982c 100644 --- a/extensions/browser/info_map.h +++ b/extensions/browser/info_map.h @@ -35,7 +35,8 @@ class InfoMap : public base::RefCountedThreadSafe<InfoMap> { // Callback for when new extensions are loaded. void AddExtension(const extensions::Extension* extension, base::Time install_time, - bool incognito_enabled); + bool incognito_enabled, + bool notifications_disabled); // Callback for when an extension is unloaded. void RemoveExtension(const std::string& extension_id, @@ -85,6 +86,12 @@ class InfoMap : public base::RefCountedThreadSafe<InfoMap> { void SetSigninProcess(int process_id); bool IsSigninProcess(int process_id) const; + // Notifications can be enabled/disabled in real time by the user. + void SetNotificationsDisabled(const std::string& extension_id, + bool notifications_disabled); + bool AreNotificationsDisabled(const std::string& extension_id) + const; + private: friend class base::RefCountedThreadSafe<InfoMap>; diff --git a/extensions/browser/info_map_unittest.cc b/extensions/browser/info_map_unittest.cc index 5136069..b023eed 100644 --- a/extensions/browser/info_map_unittest.cc +++ b/extensions/browser/info_map_unittest.cc @@ -90,9 +90,9 @@ TEST_F(InfoMapTest, RefCounting) { EXPECT_TRUE(extension3->HasOneRef()); // Add a ref to each extension and give it to the info map. - info_map->AddExtension(extension1.get(), base::Time(), false); - info_map->AddExtension(extension2.get(), base::Time(), false); - info_map->AddExtension(extension3.get(), base::Time(), false); + info_map->AddExtension(extension1.get(), base::Time(), false, false); + info_map->AddExtension(extension2.get(), base::Time(), false, false); + info_map->AddExtension(extension3.get(), base::Time(), false, false); // Release extension1, and the info map should have the only ref. const Extension* weak_extension1 = extension1.get(); @@ -116,8 +116,8 @@ TEST_F(InfoMapTest, Properties) { scoped_refptr<Extension> extension1(CreateExtension("extension1")); scoped_refptr<Extension> extension2(CreateExtension("extension2")); - info_map->AddExtension(extension1.get(), base::Time(), false); - info_map->AddExtension(extension2.get(), base::Time(), false); + info_map->AddExtension(extension1.get(), base::Time(), false, false); + info_map->AddExtension(extension2.get(), base::Time(), false, false); EXPECT_EQ(2u, info_map->extensions().size()); EXPECT_EQ(extension1.get(), info_map->extensions().GetByID(extension1->id())); @@ -137,8 +137,8 @@ TEST_F(InfoMapTest, CheckPermissions) { ASSERT_TRUE(app->is_app()); ASSERT_TRUE(app->web_extent().MatchesURL(app_url)); - info_map->AddExtension(app.get(), base::Time(), false); - info_map->AddExtension(extension.get(), base::Time(), false); + info_map->AddExtension(app.get(), base::Time(), false, false); + info_map->AddExtension(extension.get(), base::Time(), false, false); // The app should have the notifications permission, either from a // chrome-extension URL or from its web extent. @@ -161,4 +161,16 @@ TEST_F(InfoMapTest, CheckPermissions) { EXPECT_FALSE(match); } +TEST_F(InfoMapTest, TestNotificationsDisabled) { + scoped_refptr<InfoMap> info_map(new InfoMap()); + scoped_refptr<Extension> app(LoadManifest("manifest_tests", + "valid_app.json")); + info_map->AddExtension(app.get(), base::Time(), false, false); + + EXPECT_FALSE(info_map->AreNotificationsDisabled(app->id())); + info_map->SetNotificationsDisabled(app->id(), true); + EXPECT_TRUE(info_map->AreNotificationsDisabled(app->id())); + info_map->SetNotificationsDisabled(app->id(), false); +} + } // namespace extensions |