| OLD | NEW | 
|    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2011 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/memory/ref_counted.h" |    7 #include "base/memory/ref_counted.h" | 
|    8 #include "base/message_loop.h" |    8 #include "base/message_loop.h" | 
|    9 #include "base/synchronization/waitable_event.h" |    9 #include "base/synchronization/waitable_event.h" | 
 |   10 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 
|   10 #include "chrome/browser/notifications/notifications_prefs_cache.h" |   11 #include "chrome/browser/notifications/notifications_prefs_cache.h" | 
|   11 #include "chrome/browser/prefs/pref_service.h" |   12 #include "chrome/browser/prefs/pref_service.h" | 
|   12 #include "chrome/browser/prefs/scoped_user_pref_update.h" |   13 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 
|   13 #include "chrome/common/pref_names.h" |   14 #include "chrome/common/pref_names.h" | 
|   14 #include "chrome/test/testing_profile.h" |   15 #include "chrome/test/testing_profile.h" | 
|   15 #include "content/browser/browser_thread.h" |   16 #include "content/browser/browser_thread.h" | 
|   16 #include "content/browser/renderer_host/test_render_view_host.h" |   17 #include "content/browser/renderer_host/test_render_view_host.h" | 
|   17 #include "grit/generated_resources.h" |   18 #include "grit/generated_resources.h" | 
|   18 #include "testing/gtest/include/gtest/gtest.h" |   19 #include "testing/gtest/include/gtest/gtest.h" | 
|   19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
     ter.h" |   20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
     ter.h" | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   95   DesktopNotificationServiceTest() { |   96   DesktopNotificationServiceTest() { | 
|   96   } |   97   } | 
|   97  |   98  | 
|   98   virtual void SetUp() { |   99   virtual void SetUp() { | 
|   99     RenderViewHostTestHarness::SetUp(); |  100     RenderViewHostTestHarness::SetUp(); | 
|  100     proxy_ = new ThreadProxy; |  101     proxy_ = new ThreadProxy; | 
|  101     proxy_->PauseIOThread(); |  102     proxy_->PauseIOThread(); | 
|  102  |  103  | 
|  103     // Creates the service, calls InitPrefs() on it which loads data from the |  104     // Creates the service, calls InitPrefs() on it which loads data from the | 
|  104     // profile into the cache and then puts the cache in io thread mode. |  105     // profile into the cache and then puts the cache in io thread mode. | 
|  105     service_ = profile()->GetDesktopNotificationService(); |  106     service_ = DesktopNotificationServiceFactory::GetForProfile(profile()); | 
|  106     cache_ = service_->prefs_cache(); |  107     cache_ = service_->prefs_cache(); | 
|  107   } |  108   } | 
|  108  |  109  | 
|  109   virtual void TearDown() { |  110   virtual void TearDown() { | 
|  110     // The io thread's waiting on the io_event_ might hold a ref to |proxy_|, |  111     // The io thread's waiting on the io_event_ might hold a ref to |proxy_|, | 
|  111     // preventing its destruction. Clear that ref. |  112     // preventing its destruction. Clear that ref. | 
|  112     proxy_->DrainIOThread(); |  113     proxy_->DrainIOThread(); | 
|  113     RenderViewHostTestHarness::TearDown(); |  114     RenderViewHostTestHarness::TearDown(); | 
|  114   } |  115   } | 
|  115  |  116  | 
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  274   EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionDenied, |  275   EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionDenied, | 
|  275             proxy_->CacheHasPermission(cache_, denied_url)); |  276             proxy_->CacheHasPermission(cache_, denied_url)); | 
|  276  |  277  | 
|  277   service_->ResetBlockedOrigin(denied_url); |  278   service_->ResetBlockedOrigin(denied_url); | 
|  278  |  279  | 
|  279   EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionNotAllowed, |  280   EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionNotAllowed, | 
|  280             proxy_->CacheHasPermission(cache_, denied_url)); |  281             proxy_->CacheHasPermission(cache_, denied_url)); | 
|  281 } |  282 } | 
|  282  |  283  | 
|  283 }  // namespace |  284 }  // namespace | 
| OLD | NEW |