summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc4
-rw-r--r--content/browser/browser_child_process_host.cc6
-rw-r--r--content/browser/browser_main.cc4
-rw-r--r--content/browser/browser_process_sub_thread.cc4
-rw-r--r--content/browser/browser_process_sub_thread.h4
-rw-r--r--content/browser/cert_store.cc6
-rw-r--r--content/browser/debugger/render_view_devtools_agent_host.cc4
-rw-r--r--content/browser/debugger/worker_devtools_manager.cc4
-rw-r--r--content/browser/download/download_manager.cc4
-rw-r--r--content/browser/download/mhtml_generation_manager.cc4
-rw-r--r--content/browser/host_zoom_map.cc8
-rw-r--r--content/browser/mach_broker_mac.cc10
-rw-r--r--content/browser/notification_service_impl.cc147
-rw-r--r--content/browser/notification_service_impl.h92
-rw-r--r--content/browser/notification_service_impl_unittest.cc167
-rw-r--r--content/browser/plugin_service.cc4
-rw-r--r--content/browser/renderer_host/backing_store_manager.cc1
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc12
-rw-r--r--content/browser/renderer_host/render_message_filter.cc1
-rw-r--r--content/browser/renderer_host/render_process_host.cc6
-rw-r--r--content/browser/renderer_host/render_view_host.cc24
-rw-r--r--content/browser/renderer_host/render_widget_host.cc22
-rw-r--r--content/browser/renderer_host/render_widget_host_view_win.cc4
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.cc4
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_browsertest.cc3
-rw-r--r--content/browser/site_instance.cc8
-rw-r--r--content/browser/ssl/ssl_client_auth_handler.cc7
-rw-r--r--content/browser/ssl/ssl_manager.cc10
-rw-r--r--content/browser/tab_contents/interstitial_page.cc6
-rw-r--r--content/browser/tab_contents/navigation_controller.cc18
-rw-r--r--content/browser/tab_contents/render_view_host_manager.cc8
-rw-r--r--content/browser/tab_contents/tab_contents.cc38
-rw-r--r--content/browser/user_metrics.cc6
33 files changed, 529 insertions, 121 deletions
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc
index 777ec03..08336ada 100644
--- a/content/browser/appcache/chrome_appcache_service.cc
+++ b/content/browser/appcache/chrome_appcache_service.cc
@@ -6,8 +6,8 @@
#include "base/file_path.h"
#include "base/file_util.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "net/base/net_errors.h"
#include "webkit/quota/quota_manager.h"
@@ -28,7 +28,7 @@ void ChromeAppCacheService::InitializeOnIOThread(
resource_context_ = resource_context;
registrar_.Add(
this, content::NOTIFICATION_PURGE_MEMORY,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
// Init our base class.
Initialize(cache_path_,
diff --git a/content/browser/browser_child_process_host.cc b/content/browser/browser_child_process_host.cc
index e2e99a5..7b79495 100644
--- a/content/browser/browser_child_process_host.cc
+++ b/content/browser/browser_child_process_host.cc
@@ -16,7 +16,7 @@
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/resource_message_filter.h"
#include "content/browser/trace_message_filter.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/plugin_messages.h"
#include "content/common/process_watcher.h"
#include "content/common/result_codes.h"
@@ -44,8 +44,8 @@ class ChildNotificationTask : public Task {
: notification_type_(notification_type), info_(*info) { }
virtual void Run() {
- NotificationService::current()->
- Notify(notification_type_, NotificationService::AllSources(),
+ content::NotificationService::current()->
+ Notify(notification_type_, content::NotificationService::AllSources(),
content::Details<ChildProcessInfo>(&info_));
}
diff --git a/content/browser/browser_main.cc b/content/browser/browser_main.cc
index 8c75d2a..5bccf00 100644
--- a/content/browser/browser_main.cc
+++ b/content/browser/browser_main.cc
@@ -14,9 +14,9 @@
#include "base/threading/thread_restrictions.h"
#include "base/tracked_objects.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/notification_service_impl.h"
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
-#include "content/common/notification_service.h"
#include "content/common/result_codes.h"
#include "content/common/sandbox_policy.h"
#include "content/public/browser/content_browser_client.h"
@@ -375,7 +375,7 @@ bool ExitedMainMessageLoop() {
int BrowserMain(const MainFunctionParams& parameters) {
TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, "");
- NotificationService main_notification_service;
+ NotificationServiceImpl main_notification_service;
scoped_ptr<content::BrowserMainParts> parts(
content::GetContentClient()->browser()->CreateBrowserMainParts(
diff --git a/content/browser/browser_process_sub_thread.cc b/content/browser/browser_process_sub_thread.cc
index ed904a3..f748d08 100644
--- a/content/browser/browser_process_sub_thread.cc
+++ b/content/browser/browser_process_sub_thread.cc
@@ -5,7 +5,7 @@
#include "content/browser/browser_process_sub_thread.h"
#include "build/build_config.h"
-#include "content/common/notification_service.h"
+#include "content/browser/notification_service_impl.h"
#if defined(OS_WIN)
#include <Objbase.h>
@@ -26,7 +26,7 @@ void BrowserProcessSubThread::Init() {
CoInitialize(NULL);
#endif
- notification_service_ = new NotificationService;
+ notification_service_ = new NotificationServiceImpl;
}
void BrowserProcessSubThread::CleanUp() {
diff --git a/content/browser/browser_process_sub_thread.h b/content/browser/browser_process_sub_thread.h
index bfaab3f..adbda97 100644
--- a/content/browser/browser_process_sub_thread.h
+++ b/content/browser/browser_process_sub_thread.h
@@ -10,7 +10,9 @@
#include "content/browser/browser_thread.h"
#include "content/common/content_export.h"
+namespace content {
class NotificationService;
+}
// ----------------------------------------------------------------------------
// BrowserProcessSubThread
@@ -34,7 +36,7 @@ class CONTENT_EXPORT BrowserProcessSubThread : public BrowserThread {
// Each specialized thread has its own notification service.
// Note: We don't use scoped_ptr because the destructor runs on the wrong
// thread.
- NotificationService* notification_service_;
+ content::NotificationService* notification_service_;
DISALLOW_COPY_AND_ASSIGN(BrowserProcessSubThread);
};
diff --git a/content/browser/cert_store.cc b/content/browser/cert_store.cc
index 22c8c47..2caf2f14 100644
--- a/content/browser/cert_store.cc
+++ b/content/browser/cert_store.cc
@@ -10,7 +10,7 @@
#include "base/stl_util.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
template <typename T>
@@ -37,9 +37,9 @@ CertStore::CertStore() : next_cert_id_(1) {
// is not used anymore.
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
CertStore::~CertStore() {
diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc
index 1adf627..8eff4c7 100644
--- a/content/browser/debugger/render_view_devtools_agent_host.cc
+++ b/content/browser/debugger/render_view_devtools_agent_host.cc
@@ -12,8 +12,8 @@
#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/devtools_messages.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
RenderViewDevToolsAgentHost::Instances RenderViewDevToolsAgentHost::instances_;
@@ -54,7 +54,7 @@ void RenderViewDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) {
}
void RenderViewDevToolsAgentHost::NotifyClientClosing() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
content::Source<content::BrowserContext>(
render_view_host_->site_instance()->GetProcess()->browser_context()),
diff --git a/content/browser/debugger/worker_devtools_manager.cc b/content/browser/debugger/worker_devtools_manager.cc
index 9f5e626..c0e01b7 100644
--- a/content/browser/debugger/worker_devtools_manager.cc
+++ b/content/browser/debugger/worker_devtools_manager.cc
@@ -17,7 +17,7 @@
#include "content/common/devtools_messages.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
class WorkerDevToolsManager::AgentHosts
@@ -54,7 +54,7 @@ public:
private:
AgentHosts() {
registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
~AgentHosts() {}
diff --git a/content/browser/download/download_manager.cc b/content/browser/download/download_manager.cc
index c875a56..7f31385 100644
--- a/content/browser/download/download_manager.cc
+++ b/content/browser/download/download_manager.cc
@@ -31,8 +31,8 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
namespace {
@@ -1073,7 +1073,7 @@ void DownloadManager::SavePageDownloadFinished(DownloadItem* download) {
save_page_downloads_.erase(download->id());
if (download->IsComplete())
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
content::Source<DownloadManager>(this),
content::Details<DownloadItem>(download));
diff --git a/content/browser/download/mhtml_generation_manager.cc b/content/browser/download/mhtml_generation_manager.cc
index 2802c24..3c8f76c 100644
--- a/content/browser/download/mhtml_generation_manager.cc
+++ b/content/browser/download/mhtml_generation_manager.cc
@@ -8,7 +8,7 @@
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/notification_types.h"
@@ -113,7 +113,7 @@ void MHTMLGenerationManager::JobFinished(int job_id, int64 file_size) {
details.file_path = job.file_path;
details.file_size = file_size;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_MHTML_GENERATED,
content::Source<RenderViewHost>(rvh),
content::Details<NotificationDetails>(&details));
diff --git a/content/browser/host_zoom_map.cc b/content/browser/host_zoom_map.cc
index 6aa228b..19b64f1 100644
--- a/content/browser/host_zoom_map.cc
+++ b/content/browser/host_zoom_map.cc
@@ -12,7 +12,7 @@
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
@@ -41,7 +41,7 @@ HostZoomMap::HostZoomMap(HostZoomMap* original)
void HostZoomMap::Init() {
registrar_.Add(
this, content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
double HostZoomMap::GetZoomLevel(const std::string& host) const {
@@ -61,7 +61,7 @@ void HostZoomMap::SetZoomLevel(std::string host, double level) {
host_zoom_levels_[host] = level;
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
content::Source<HostZoomMap>(this),
content::Details<const std::string>(&host));
@@ -109,7 +109,7 @@ void HostZoomMap::SetTemporaryZoomLevel(int render_process_id,
}
std::string host;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
content::Source<HostZoomMap>(this),
content::Details<const std::string>(&host));
diff --git a/content/browser/mach_broker_mac.cc b/content/browser/mach_broker_mac.cc
index 2dbd1c8..6905c7f 100644
--- a/content/browser/mach_broker_mac.cc
+++ b/content/browser/mach_broker_mac.cc
@@ -15,7 +15,7 @@
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/common/child_process_info.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/content_switches.h"
@@ -36,16 +36,16 @@ class RegisterNotificationTask : public Task {
virtual void Run() {
broker_->registrar_.Add(broker_,
content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
broker_->registrar_.Add(broker_,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
broker_->registrar_.Add(broker_,
content::NOTIFICATION_CHILD_PROCESS_CRASHED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
broker_->registrar_.Add(broker_,
content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
private:
diff --git a/content/browser/notification_service_impl.cc b/content/browser/notification_service_impl.cc
new file mode 100644
index 0000000..795cb30
--- /dev/null
+++ b/content/browser/notification_service_impl.cc
@@ -0,0 +1,147 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/notification_service_impl.h"
+
+#include "base/lazy_instance.h"
+#include "base/threading/thread_local.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_types.h"
+
+static base::LazyInstance<base::ThreadLocalPointer<NotificationServiceImpl> >
+ lazy_tls_ptr(base::LINKER_INITIALIZED);
+
+// static
+NotificationServiceImpl* NotificationServiceImpl::current() {
+ return lazy_tls_ptr.Pointer()->Get();
+}
+
+// static
+content::NotificationService* content::NotificationService::current() {
+ return NotificationServiceImpl::current();
+}
+
+// static
+bool NotificationServiceImpl::HasKey(const NotificationSourceMap& map,
+ const content::NotificationSource& source) {
+ return map.find(source.map_key()) != map.end();
+}
+
+NotificationServiceImpl::NotificationServiceImpl() {
+ DCHECK(current() == NULL);
+ lazy_tls_ptr.Pointer()->Set(this);
+}
+
+void NotificationServiceImpl::AddObserver(
+ content::NotificationObserver* observer,
+ int type,
+ const content::NotificationSource& source) {
+ // We have gotten some crashes where the observer pointer is NULL. The problem
+ // is that this happens when we actually execute a notification, so have no
+ // way of knowing who the bad observer was. We want to know when this happens
+ // in release mode so we know what code to blame the crash on (since this is
+ // guaranteed to crash later).
+ CHECK(observer);
+
+ NotificationObserverList* observer_list;
+ if (HasKey(observers_[type], source)) {
+ observer_list = observers_[type][source.map_key()];
+ } else {
+ observer_list = new NotificationObserverList;
+ observers_[type][source.map_key()] = observer_list;
+ }
+
+ observer_list->AddObserver(observer);
+#ifndef NDEBUG
+ ++observer_counts_[type];
+#endif
+}
+
+void NotificationServiceImpl::RemoveObserver(
+ content::NotificationObserver* observer,
+ int type,
+ const content::NotificationSource& source) {
+ // This is a very serious bug. An object is most likely being deleted on
+ // the wrong thread, and as a result another thread's NotificationServiceImpl
+ // has its deleted pointer in its map. A garbge object will be called in the
+ // future.
+ // NOTE: when this check shows crashes, use BrowserThread::DeleteOnIOThread or
+ // other variants as the trait on the object.
+ CHECK(HasKey(observers_[type], source));
+
+ NotificationObserverList* observer_list =
+ observers_[type][source.map_key()];
+ if (observer_list) {
+ observer_list->RemoveObserver(observer);
+#ifndef NDEBUG
+ --observer_counts_[type];
+#endif
+ }
+
+ // TODO(jhughes): Remove observer list from map if empty?
+}
+
+void NotificationServiceImpl::Notify(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK(type > content::NOTIFICATION_ALL) <<
+ "Allowed for observing, but not posting.";
+
+ // There's no particular reason for the order in which the different
+ // classes of observers get notified here.
+
+ // Notify observers of all types and all sources
+ if (HasKey(observers_[content::NOTIFICATION_ALL], AllSources()) &&
+ source != AllSources()) {
+ FOR_EACH_OBSERVER(content::NotificationObserver,
+ *observers_[content::NOTIFICATION_ALL][AllSources().map_key()],
+ Observe(type, source, details));
+ }
+
+ // Notify observers of all types and the given source
+ if (HasKey(observers_[content::NOTIFICATION_ALL], source)) {
+ FOR_EACH_OBSERVER(content::NotificationObserver,
+ *observers_[content::NOTIFICATION_ALL][source.map_key()],
+ Observe(type, source, details));
+ }
+
+ // Notify observers of the given type and all sources
+ if (HasKey(observers_[type], AllSources()) &&
+ source != AllSources()) {
+ FOR_EACH_OBSERVER(content::NotificationObserver,
+ *observers_[type][AllSources().map_key()],
+ Observe(type, source, details));
+ }
+
+ // Notify observers of the given type and the given source
+ if (HasKey(observers_[type], source)) {
+ FOR_EACH_OBSERVER(content::NotificationObserver,
+ *observers_[type][source.map_key()],
+ Observe(type, source, details));
+ }
+}
+
+
+NotificationServiceImpl::~NotificationServiceImpl() {
+ lazy_tls_ptr.Pointer()->Set(NULL);
+
+#ifndef NDEBUG
+ for (int i = 0; i < static_cast<int>(observer_counts_.size()); i++) {
+ if (observer_counts_[i] > 0) {
+ // This may not be completely fixable -- see
+ // http://code.google.com/p/chromium/issues/detail?id=11010 .
+ VLOG(1) << observer_counts_[i] << " notification observer(s) leaked "
+ "of notification type " << i;
+ }
+ }
+#endif
+
+ for (int i = 0; i < static_cast<int>(observers_.size()); i++) {
+ NotificationSourceMap omap = observers_[i];
+ for (NotificationSourceMap::iterator it = omap.begin();
+ it != omap.end(); ++it)
+ delete it->second;
+ }
+}
diff --git a/content/browser/notification_service_impl.h b/content/browser/notification_service_impl.h
new file mode 100644
index 0000000..0898234
--- /dev/null
+++ b/content/browser/notification_service_impl.h
@@ -0,0 +1,92 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_IMPL_H_
+#define CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_IMPL_H_
+#pragma once
+
+#include <map>
+
+#include "base/observer_list.h"
+#include "content/common/content_export.h"
+#include "content/public/browser/notification_service.h"
+
+namespace content {
+class NotificationObserver;
+class NotificationRegistrar;
+}
+
+class NotificationServiceImpl : public content::NotificationService {
+ public:
+ static NotificationServiceImpl* current();
+
+ // Normally instantiated when the thread is created. Not all threads have
+ // a NotificationService. Only one instance should be created per thread.
+ NotificationServiceImpl();
+ virtual ~NotificationServiceImpl();
+
+ // content::NotificationService
+ virtual void Notify(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details);
+
+ private:
+ friend class content::NotificationRegistrar;
+
+ typedef ObserverList<content::NotificationObserver> NotificationObserverList;
+ typedef std::map<uintptr_t, NotificationObserverList*> NotificationSourceMap;
+ typedef std::map<int, NotificationSourceMap> NotificationObserverMap;
+ typedef std::map<int, int> NotificationObserverCount;
+
+ // Convenience function to determine whether a source has a
+ // NotificationObserverList in the given map;
+ static bool HasKey(const NotificationSourceMap& map,
+ const content::NotificationSource& source);
+
+ // NOTE: Rather than using this directly, you should use a
+ // NotificationRegistrar.
+ //
+ // Registers a NotificationObserver to be called whenever a matching
+ // notification is posted. Observer is a pointer to an object subclassing
+ // NotificationObserver to be notified when an event matching the other two
+ // parameters is posted to this service. Type is the type of events to be
+ // notified about (or content::NOTIFICATION_ALL to receive events of all
+ // types).
+ // Source is a NotificationSource object (created using
+ // "Source<classname>(pointer)"), if this observer only wants to
+ // receive events from that object, or NotificationService::AllSources()
+ // to receive events from all sources.
+ //
+ // A given observer can be registered only once for each combination of
+ // type and source. If the same object is registered more than once,
+ // it must be removed for each of those combinations of type and source later.
+ //
+ // The caller retains ownership of the object pointed to by observer.
+ void AddObserver(content::NotificationObserver* observer,
+ int type, const content::NotificationSource& source);
+
+ // NOTE: Rather than using this directly, you should use a
+ // NotificationRegistrar.
+ //
+ // Removes the object pointed to by observer from receiving notifications
+ // that match type and source. If no object matching the parameters is
+ // currently registered, this method is a no-op.
+ void RemoveObserver(content::NotificationObserver* observer,
+ int type, const content::NotificationSource& source);
+
+ // Keeps track of the observers for each type of notification.
+ // Until we get a prohibitively large number of notification types,
+ // a simple array is probably the fastest way to dispatch.
+ NotificationObserverMap observers_;
+
+#ifndef NDEBUG
+ // Used to check to see that AddObserver and RemoveObserver calls are
+ // balanced.
+ NotificationObserverCount observer_counts_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationServiceImpl);
+};
+
+#endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_IMPL_H_
diff --git a/content/browser/notification_service_impl_unittest.cc b/content/browser/notification_service_impl_unittest.cc
new file mode 100644
index 0000000..62a0e51
--- /dev/null
+++ b/content/browser/notification_service_impl_unittest.cc
@@ -0,0 +1,167 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/notification_service_impl.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_types.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// Bogus class to act as a NotificationSource for the messages.
+class TestSource {};
+
+class TestObserver : public content::NotificationObserver {
+public:
+ TestObserver() : notification_count_(0) {}
+
+ int notification_count() { return notification_count_; }
+
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ ++notification_count_;
+ }
+
+private:
+ int notification_count_;
+};
+
+} // namespace
+
+
+class NotificationServiceImplTest : public testing::Test {
+ protected:
+ content::NotificationRegistrar registrar_;
+};
+
+TEST_F(NotificationServiceImplTest, Basic) {
+ TestSource test_source;
+ TestSource other_source;
+
+ // Check the equality operators defined for NotificationSource
+ EXPECT_TRUE(content::Source<TestSource>(&test_source) ==
+ content::Source<TestSource>(&test_source));
+ EXPECT_TRUE(content::Source<TestSource>(&test_source) !=
+ content::Source<TestSource>(&other_source));
+
+ TestObserver all_types_all_sources;
+ TestObserver idle_all_sources;
+ TestObserver all_types_test_source;
+ TestObserver idle_test_source;
+
+ // Make sure it doesn't freak out when there are no observers.
+ content::NotificationService* service =
+ content::NotificationService::current();
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source),
+ content::NotificationService::NoDetails());
+
+ registrar_.Add(&all_types_all_sources, content::NOTIFICATION_ALL,
+ content::NotificationService::AllSources());
+ registrar_.Add(&idle_all_sources, content::NOTIFICATION_IDLE,
+ content::NotificationService::AllSources());
+ registrar_.Add(&all_types_test_source, content::NOTIFICATION_ALL,
+ content::Source<TestSource>(&test_source));
+ registrar_.Add(&idle_test_source, content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source));
+
+ EXPECT_EQ(0, all_types_all_sources.notification_count());
+ EXPECT_EQ(0, idle_all_sources.notification_count());
+ EXPECT_EQ(0, all_types_test_source.notification_count());
+ EXPECT_EQ(0, idle_test_source.notification_count());
+
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source),
+ content::NotificationService::NoDetails());
+
+ EXPECT_EQ(1, all_types_all_sources.notification_count());
+ EXPECT_EQ(1, idle_all_sources.notification_count());
+ EXPECT_EQ(1, all_types_test_source.notification_count());
+ EXPECT_EQ(1, idle_test_source.notification_count());
+
+ service->Notify(content::NOTIFICATION_BUSY,
+ content::Source<TestSource>(&test_source),
+ content::NotificationService::NoDetails());
+
+ EXPECT_EQ(2, all_types_all_sources.notification_count());
+ EXPECT_EQ(1, idle_all_sources.notification_count());
+ EXPECT_EQ(2, all_types_test_source.notification_count());
+ EXPECT_EQ(1, idle_test_source.notification_count());
+
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&other_source),
+ content::NotificationService::NoDetails());
+
+ EXPECT_EQ(3, all_types_all_sources.notification_count());
+ EXPECT_EQ(2, idle_all_sources.notification_count());
+ EXPECT_EQ(2, all_types_test_source.notification_count());
+ EXPECT_EQ(1, idle_test_source.notification_count());
+
+ service->Notify(content::NOTIFICATION_BUSY,
+ content::Source<TestSource>(&other_source),
+ content::NotificationService::NoDetails());
+
+ EXPECT_EQ(4, all_types_all_sources.notification_count());
+ EXPECT_EQ(2, idle_all_sources.notification_count());
+ EXPECT_EQ(2, all_types_test_source.notification_count());
+ EXPECT_EQ(1, idle_test_source.notification_count());
+
+ // Try send with NULL source.
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::NotificationService::AllSources(),
+ content::NotificationService::NoDetails());
+
+ EXPECT_EQ(5, all_types_all_sources.notification_count());
+ EXPECT_EQ(3, idle_all_sources.notification_count());
+ EXPECT_EQ(2, all_types_test_source.notification_count());
+ EXPECT_EQ(1, idle_test_source.notification_count());
+
+ registrar_.RemoveAll();
+
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source),
+ content::NotificationService::NoDetails());
+
+ EXPECT_EQ(5, all_types_all_sources.notification_count());
+ EXPECT_EQ(3, idle_all_sources.notification_count());
+ EXPECT_EQ(2, all_types_test_source.notification_count());
+ EXPECT_EQ(1, idle_test_source.notification_count());
+}
+
+TEST_F(NotificationServiceImplTest, MultipleRegistration) {
+ TestSource test_source;
+
+ TestObserver idle_test_source;
+
+ content::NotificationService* service =
+ content::NotificationService::current();
+
+ registrar_.Add(&idle_test_source, content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source));
+ registrar_.Add(&idle_test_source, content::NOTIFICATION_ALL,
+ content::Source<TestSource>(&test_source));
+
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source),
+ content::NotificationService::NoDetails());
+ EXPECT_EQ(2, idle_test_source.notification_count());
+
+ registrar_.Remove(&idle_test_source, content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source));
+
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source),
+ content::NotificationService::NoDetails());
+ EXPECT_EQ(3, idle_test_source.notification_count());
+
+ registrar_.Remove(&idle_test_source, content::NOTIFICATION_ALL,
+ content::Source<TestSource>(&test_source));
+
+ service->Notify(content::NOTIFICATION_IDLE,
+ content::Source<TestSource>(&test_source),
+ content::NotificationService::NoDetails());
+ EXPECT_EQ(3, idle_test_source.notification_count());
+}
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index b88bed2..378ee28 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -24,7 +24,7 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/resource_context.h"
#include "content/browser/utility_process_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/pepper_plugin_registry.h"
#include "content/common/plugin_messages.h"
#include "content/common/utility_messages.h"
@@ -131,7 +131,7 @@ PluginService::PluginService()
// We need to know when the browser comes forward so we can bring modal plugin
// windows forward too.
registrar_.Add(this, content::NOTIFICATION_APP_ACTIVATED,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
#endif
}
diff --git a/content/browser/renderer_host/backing_store_manager.cc b/content/browser/renderer_host/backing_store_manager.cc
index 16e84b5..c6dedd4 100644
--- a/content/browser/renderer_host/backing_store_manager.cc
+++ b/content/browser/renderer_host/backing_store_manager.cc
@@ -9,7 +9,6 @@
#include "base/sys_info.h"
#include "content/browser/renderer_host/backing_store.h"
#include "content/browser/renderer_host/render_widget_host.h"
-#include "content/common/notification_service.h"
#include "content/public/common/content_switches.h"
namespace {
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index 7711a50..f5b10a9 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -72,7 +72,7 @@
#include "content/common/child_process_info.h"
#include "content/common/child_process_messages.h"
#include "content/common/gpu/gpu_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/process_watcher.h"
#include "content/common/resource_messages.h"
#include "content/common/result_codes.h"
@@ -870,7 +870,7 @@ void BrowserRenderProcessHost::ProcessDied(
// already handled the error.
RendererClosedDetails details(status, exit_code, was_alive);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
content::Source<RenderProcessHost>(this),
content::Details<RendererClosedDetails>(&details));
@@ -900,10 +900,10 @@ void BrowserRenderProcessHost::OnShutdownRequest() {
// Notify any tabs that might have swapped out renderers from this process.
// They should not attempt to swap them back in.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CLOSING,
content::Source<RenderProcessHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
Send(new ChildProcessMsg_Shutdown());
}
@@ -965,10 +965,10 @@ void BrowserRenderProcessHost::OnProcessLaunched() {
// The queued messages contain such things as "navigate". If this notification
// was after, we can end up executing JavaScript before the initialization
// happens.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::Source<RenderProcessHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
while (!queued_messages_.empty()) {
Send(queued_messages_.front());
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 1e67aba..5f3e5cd 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -31,7 +31,6 @@
#include "content/common/child_process_host.h"
#include "content/common/child_process_messages.h"
#include "content/common/desktop_notification_messages.h"
-#include "content/common/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_switches.h"
diff --git a/content/browser/renderer_host/render_process_host.cc b/content/browser/renderer_host/render_process_host.cc
index 1969e35..d9ce96b 100644
--- a/content/browser/renderer_host/render_process_host.cc
+++ b/content/browser/renderer_host/render_process_host.cc
@@ -13,8 +13,8 @@
#include "content/browser/webui/web_ui_factory.h"
#include "content/common/child_process_info.h"
#include "content/common/content_constants.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/content_switches.h"
@@ -149,10 +149,10 @@ void RenderProcessHost::Release(int listener_id) {
void RenderProcessHost::Cleanup() {
// When no other owners of this object, we can delete ourselves
if (listeners_.IsEmpty()) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::Source<RenderProcessHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
deleting_soon_ = true;
// It's important not to wait for the DeleteTask to delete the channel
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index 5fa3bb6..8135f5e 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -33,7 +33,7 @@
#include "content/common/content_constants.h"
#include "content/common/desktop_notification_messages.h"
#include "content/common/drag_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/result_codes.h"
#include "content/common/speech_input_messages.h"
#include "content/common/swapped_out_messages.h"
@@ -131,20 +131,20 @@ RenderViewHost::RenderViewHost(SiteInstance* instance,
content::GetContentClient()->browser()->RenderViewHostCreated(this);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
RenderViewHost::~RenderViewHost() {
FOR_EACH_OBSERVER(
RenderViewHostObserver, observers_, RenderViewHostDestruction());
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
ClearPowerSaveBlockers();
@@ -370,10 +370,10 @@ void RenderViewHost::ClosePage() {
if (IsRenderViewLive()) {
// TODO(creis): Should this be moved to Shutdown? It may not be called for
// RenderViewHosts that have been swapped out.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
Send(new ViewMsg_ClosePage(routing_id()));
} else {
@@ -1074,10 +1074,10 @@ void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) {
}
void RenderViewHost::OnTargetDropACK() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void RenderViewHost::OnTakeFocus(bool reverse) {
@@ -1344,10 +1344,10 @@ void RenderViewHost::OnAccessibilityNotifications(
}
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
content::Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
Send(new ViewMsg_AccessibilityNotifications_ACK(routing_id()));
@@ -1361,7 +1361,7 @@ void RenderViewHost::OnScriptEvalResponse(int id, const ListValue& result) {
return;
}
std::pair<int, Value*> details(id, result_value);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
content::Source<RenderViewHost>(this),
content::Details<std::pair<int, Value*> >(&details));
diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc
index b98a702..c826f07 100644
--- a/content/browser/renderer_host/render_widget_host.cc
+++ b/content/browser/renderer_host/render_widget_host.cc
@@ -21,7 +21,7 @@
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/user_metrics.h"
#include "content/common/gpu/gpu_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/result_codes.h"
#include "content/common/view_messages.h"
#include "content/public/browser/native_web_keyboard_event.h"
@@ -265,7 +265,7 @@ void RenderWidgetHost::WasHidden() {
process_->WidgetHidden();
bool is_visible = false;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
content::Source<RenderWidgetHost>(this),
content::Details<bool>(&is_visible));
@@ -300,7 +300,7 @@ void RenderWidgetHost::WasRestored() {
process_->WidgetRestored();
bool is_visible = true;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
content::Source<RenderWidgetHost>(this),
content::Details<bool>(&is_visible));
@@ -833,10 +833,10 @@ bool RenderWidgetHost::IsFullscreen() const {
}
void RenderWidgetHost::Destroy() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
content::Source<RenderWidgetHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// Tell the view to die.
// Note that in the process of the view shutting down, it can call a ton
@@ -861,10 +861,10 @@ void RenderWidgetHost::CheckRendererIsUnresponsive() {
}
// OK, looks like we have a hung renderer!
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_HANG,
content::Source<RenderWidgetHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
is_unresponsive_ = true;
NotifyRendererUnresponsive();
}
@@ -934,7 +934,7 @@ void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) {
void RenderWidgetHost::OnMsgPaintAtSizeAck(int tag, const gfx::Size& size) {
PaintAtSizeAckDetails details = {tag, size};
gfx::Size size_details = size;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK,
content::Source<RenderWidgetHost>(this),
content::Details<PaintAtSizeAckDetails>(&details));
@@ -1038,10 +1038,10 @@ void RenderWidgetHost::OnMsgUpdateRect(
view_being_painted_ = false;
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT,
content::Source<RenderWidgetHost>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// If we got a resize ack, then perhaps we have another resize to send?
if (is_resize_ack && view_) {
@@ -1090,7 +1090,7 @@ void RenderWidgetHost::OnMsgInputEventAck(WebInputEvent::Type event_type,
}
}
// This is used only for testing.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK,
content::Source<RenderWidgetHost>(this),
content::Details<int>(&type));
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index 9087bb0..ec83c95 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -24,7 +24,7 @@
#include "content/browser/renderer_host/backing_store_win.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_widget_host.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/plugin_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
@@ -236,7 +236,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
render_widget_host_->SetView(this);
registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
index e15bf14..626d310 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc
@@ -51,7 +51,7 @@
#include "content/browser/ssl/ssl_client_auth_handler.h"
#include "content/browser/ssl/ssl_manager.h"
#include "content/browser/worker_host/worker_service.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/resource_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
@@ -1904,7 +1904,7 @@ void ResourceDispatcherHost::NotifyOnUI(int type,
RenderViewHost::FromID(render_process_id, render_view_id);
if (rvh) {
RenderViewHostDelegate* rvhd = rvh->delegate();
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
type, content::Source<RenderViewHostDelegate>(rvhd),
content::Details<T>(detail));
}
diff --git a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
index 98ed614..d2b5ffe 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
@@ -8,6 +8,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "net/test/test_server.h"
@@ -31,7 +32,7 @@ bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url,
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_TAB_ADDED,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
// Create dynamic popup.
if (!ui_test_utils::ExecuteJavaScript(
diff --git a/content/browser/site_instance.cc b/content/browser/site_instance.cc
index 8f65c4d..ad79d74 100644
--- a/content/browser/site_instance.cc
+++ b/content/browser/site_instance.cc
@@ -7,8 +7,8 @@
#include "content/browser/browsing_instance.h"
#include "content/browser/renderer_host/browser_render_process_host.h"
#include "content/browser/webui/web_ui_factory.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/url_constants.h"
#include "net/base/registry_controlled_domain.h"
@@ -38,14 +38,14 @@ SiteInstance::SiteInstance(BrowsingInstance* browsing_instance)
DCHECK(browsing_instance);
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
- NotificationService::AllBrowserContextsAndSources());
+ content::NotificationService::AllBrowserContextsAndSources());
}
SiteInstance::~SiteInstance() {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SITE_INSTANCE_DELETED,
content::Source<SiteInstance>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// Now that no one is referencing us, we can safely remove ourselves from
// the BrowsingInstance. Any future visits to a page from this site
diff --git a/content/browser/ssl/ssl_client_auth_handler.cc b/content/browser/ssl/ssl_client_auth_handler.cc
index 667e3ba..f4bfe3d 100644
--- a/content/browser/ssl/ssl_client_auth_handler.cc
+++ b/content/browser/ssl/ssl_client_auth_handler.cc
@@ -9,8 +9,8 @@
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "content/browser/ssl/ssl_client_auth_notification_details.h"
-#include "content/common/notification_service.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/notification_service.h"
#include "net/base/x509_certificate.h"
#include "net/url_request/url_request.h"
@@ -58,7 +58,8 @@ void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
SSLClientAuthNotificationDetails details(cert_request_info_, cert);
- NotificationService* service = NotificationService::current();
+ content::NotificationService* service =
+ content::NotificationService::current();
service->Notify(content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED,
content::Source<SSLClientAuthHandler>(this),
content::Details<SSLClientAuthNotificationDetails>(&details));
@@ -141,7 +142,7 @@ void SSLClientAuthObserver::StartObserving() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
notification_registrar_.Add(
this, content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
void SSLClientAuthObserver::StopObserving() {
diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc
index 19c0546..f4abf54 100644
--- a/content/browser/ssl/ssl_manager.cc
+++ b/content/browser/ssl/ssl_manager.cc
@@ -18,7 +18,7 @@
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/provisional_load_details.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "net/base/cert_status_flags.h"
@@ -50,10 +50,10 @@ void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
// static
void SSLManager::NotifySSLInternalStateChanged(
NavigationController* controller) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED,
content::Source<content::BrowserContext>(controller->browser_context()),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
// static
@@ -250,9 +250,9 @@ void SSLManager::UpdateEntry(NavigationEntry* entry) {
policy()->UpdateEntry(entry, controller_->tab_contents());
if (!entry->ssl().Equals(original_ssl_status)) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
content::Source<NavigationController>(controller_),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
}
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc
index 851288ca..3a8568b 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page.cc
@@ -22,7 +22,7 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
#include "content/common/dom_storage_common.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_source.h"
@@ -348,10 +348,10 @@ void InterstitialPage::DidNavigate(
// after the interstitial page was registered with |tab_|, since there will be
// a callback to |tab_| testing if an interstitial page is showing before
// hiding the bookmark bar.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_INTERSTITIAL_ATTACHED,
content::Source<TabContents>(tab_),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
RenderWidgetHostView* rwh_view = tab_->render_view_host()->view();
diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc
index 4e78f36..c2d5185 100644
--- a/content/browser/tab_contents/navigation_controller.cc
+++ b/content/browser/tab_contents/navigation_controller.cc
@@ -21,7 +21,7 @@
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/user_metrics.h"
#include "content/common/content_constants.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/notification_types.h"
#include "net/base/escape.h"
@@ -42,7 +42,7 @@ void NotifyPrunedEntries(NavigationController* nav_controller,
content::PrunedDetails details;
details.from_front = from_front;
details.count = count;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_LIST_PRUNED,
content::Source<NavigationController>(nav_controller),
content::Details<content::PrunedDetails>(&details));
@@ -133,10 +133,10 @@ NavigationController::NavigationController(
NavigationController::~NavigationController() {
DiscardNonCommittedEntriesInternal();
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CLOSED,
content::Source<NavigationController>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void NavigationController::Restore(
@@ -183,10 +183,10 @@ void NavigationController::ReloadInternal(bool check_for_repost,
// The user is asking to reload a page with POST data. Prompt to make sure
// they really want to do this. If they do, the dialog will call us back
// with check_for_repost = false.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_REPOST_WARNING_SHOWN,
content::Source<NavigationController>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
pending_reload_ = reload_type;
tab_contents_->Activate();
@@ -274,7 +274,7 @@ void NavigationController::LoadEntry(NavigationEntry* entry) {
// result in a download or a 'no content' response (e.g., a mailto: URL).
DiscardNonCommittedEntriesInternal();
pending_entry_ = entry;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_PENDING,
content::Source<NavigationController>(this),
content::Details<NavigationEntry>(entry));
@@ -1139,7 +1139,7 @@ void NavigationController::NotifyNavigationEntryCommitted(
// notification below instead.
tab_contents_->NotifyNavigationStateChanged(kInvalidateAll);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::Source<NavigationController>(this),
notification_details);
@@ -1171,7 +1171,7 @@ void NavigationController::NotifyEntryChanged(const NavigationEntry* entry,
content::EntryChangedDetails det;
det.changed_entry = entry;
det.index = index;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_CHANGED,
content::Source<NavigationController>(this),
content::Details<content::EntryChangedDetails>(&det));
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc
index 977d749..2627862 100644
--- a/content/browser/tab_contents/render_view_host_manager.cc
+++ b/content/browser/tab_contents/render_view_host_manager.cc
@@ -16,7 +16,7 @@
#include "content/browser/tab_contents/tab_contents_view.h"
#include "content/browser/webui/web_ui.h"
#include "content/browser/webui/web_ui_factory.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_types.h"
@@ -69,7 +69,7 @@ void RenderViewHostManager::Init(content::BrowserContext* browser_context,
// Keep track of renderer processes as they start to shut down.
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING,
- NotificationService::AllSources());
+ content::NotificationService::AllSources());
}
RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const {
@@ -112,7 +112,7 @@ RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) {
RenderViewHostSwitchedDetails details;
details.new_host = render_view_host_;
details.old_host = NULL;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<NavigationController>(
&delegate_->GetControllerForRenderManager()),
@@ -613,7 +613,7 @@ void RenderViewHostManager::CommitPending() {
RenderViewHostSwitchedDetails details;
details.new_host = render_view_host_;
details.old_host = old_render_view_host;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<NavigationController>(
&delegate_->GetControllerForRenderManager()),
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 5b98734..371cf89 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -41,7 +41,7 @@
#include "content/common/content_constants.h"
#include "content/common/content_restriction.h"
#include "content/common/intents_messages.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/navigation_types.h"
@@ -222,10 +222,10 @@ TabContents::~TabContents() {
NotifyDisconnected();
// Notify any observer that have a reference on this tab contents.
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
// TODO(brettw) this should be moved to the view.
#if defined(OS_WIN)
@@ -451,10 +451,10 @@ void TabContents::WasHidden() {
rwhv->WasHidden();
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_HIDDEN,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void TabContents::Activate() {
@@ -983,7 +983,7 @@ void TabContents::OnDidFailProvisionalLoadWithError(
params.frame_id);
details.set_error_code(params.error_code);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
content::Source<NavigationController>(&controller_),
content::Details<ProvisionalLoadDetails>(&details));
@@ -1017,7 +1017,7 @@ void TabContents::OnDidLoadResourceFromMemoryCache(
LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->id(),
cert_id, cert_status);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE,
content::Source<NavigationController>(&controller_),
content::Details<LoadFromMemoryCacheDetails>(&details));
@@ -1090,7 +1090,7 @@ void TabContents::OnUpdateZoomLimits(int minimum_percent,
}
void TabContents::OnFocusedNodeChanged(bool is_editable_node) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<TabContents>(this),
content::Details<const bool>(&is_editable_node));
@@ -1177,10 +1177,10 @@ void TabContents::SetIsLoading(bool is_loading,
int type = is_loading ? content::NOTIFICATION_LOAD_START :
content::NOTIFICATION_LOAD_STOP;
- content::NotificationDetails det = NotificationService::NoDetails();
+ content::NotificationDetails det = content::NotificationService::NoDetails();
if (details)
det = content::Details<LoadNotificationDetails>(details);
- NotificationService::current()->Notify(type,
+ content::NotificationService::current()->Notify(type,
content::Source<NavigationController>(&controller_),
det);
}
@@ -1348,7 +1348,7 @@ bool TabContents::UpdateTitleForEntry(NavigationEntry* entry,
TitleUpdatedDetails details(entry, explicit_set);
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED,
content::Source<TabContents>(this),
content::Details<TitleUpdatedDetails>(&details));
@@ -1361,18 +1361,18 @@ void TabContents::NotifySwapped() {
// notification so that clients that pick up a pointer to |this| can NULL the
// pointer. See Bug 1230284.
notify_disconnection_ = true;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_SWAPPED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void TabContents::NotifyConnected() {
notify_disconnection_ = true;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_CONNECTED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
void TabContents::NotifyDisconnected() {
@@ -1380,10 +1380,10 @@ void TabContents::NotifyDisconnected() {
return;
notify_disconnection_ = false;
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED,
content::Source<TabContents>(this),
- NotificationService::NoDetails());
+ content::NotificationService::NoDetails());
}
RenderViewHostDelegate::View* TabContents::GetViewDelegate() {
@@ -1409,7 +1409,7 @@ content::ViewType TabContents::GetRenderViewType() const {
}
void TabContents::RenderViewCreated(RenderViewHost* render_view_host) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
content::Source<TabContents>(this),
content::Details<RenderViewHost>(render_view_host));
@@ -1678,7 +1678,7 @@ void TabContents::DidChangeLoadProgress(double progress) {
void TabContents::DocumentOnLoadCompletedInMainFrame(
RenderViewHost* render_view_host,
int32 page_id) {
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::Source<TabContents>(this),
content::Details<int>(&page_id));
diff --git a/content/browser/user_metrics.cc b/content/browser/user_metrics.cc
index 7224b89..d58c666 100644
--- a/content/browser/user_metrics.cc
+++ b/content/browser/user_metrics.cc
@@ -5,7 +5,7 @@
#include "content/browser/user_metrics.h"
#include "content/browser/browser_thread.h"
-#include "content/common/notification_service.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
void UserMetrics::RecordAction(const UserMetricsAction& action) {
@@ -24,9 +24,9 @@ void UserMetrics::Record(const char *action) {
return;
}
- NotificationService::current()->Notify(
+ content::NotificationService::current()->Notify(
content::NOTIFICATION_USER_ACTION,
- NotificationService::AllSources(),
+ content::NotificationService::AllSources(),
content::Details<const char*>(&action));
}