summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-01 18:16:56 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-01 18:16:56 +0000
commitbfd04a62ce610d7bb61dbb78811dccbed23589b7 (patch)
tree70bb228c0f00ba1c12c584efd569daccf96b4026 /chrome/common
parenta814d863440f0a154a7299f2d8b440f405c7700e (diff)
downloadchromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.zip
chromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.tar.gz
chromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.tar.bz2
Remove most header file dependencies on the notification type list. It is
really painful to add more types, since lots of headers include the notification service to derive from the notification observer. This splits that out, so much less of the project should end up including notification_types.h ---Paths modified but not in any changelist: Review URL: http://codereview.chromium.org/19744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/chrome_plugin_lib.cc2
-rw-r--r--chrome/common/chrome_plugin_util.cc9
-rw-r--r--chrome/common/chrome_plugin_util.h2
-rw-r--r--chrome/common/net/url_request_intercept_job.cc7
-rw-r--r--chrome/common/net/url_request_intercept_job.h2
-rw-r--r--chrome/common/notification_registrar.cc19
-rw-r--r--chrome/common/notification_registrar.h14
-rw-r--r--chrome/common/notification_service.cc59
-rw-r--r--chrome/common/notification_service.h27
-rw-r--r--chrome/common/notification_service_unittest.cc72
-rw-r--r--chrome/common/notification_type.h557
-rw-r--r--chrome/common/notification_types.h525
-rw-r--r--chrome/common/pref_member.cc5
-rw-r--r--chrome/common/pref_member.h3
-rw-r--r--chrome/common/pref_member_unittest.cc3
-rw-r--r--chrome/common/pref_service.cc2
-rw-r--r--chrome/common/pref_service_unittest.cc4
17 files changed, 681 insertions, 631 deletions
diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc
index a462adc..186261f 100644
--- a/chrome/common/chrome_plugin_lib.cc
+++ b/chrome/common/chrome_plugin_lib.cc
@@ -290,7 +290,7 @@ bool ChromePluginLib::Load() {
void ChromePluginLib::Unload() {
NotificationService::current()->Notify(
- NOTIFY_CHROME_PLUGIN_UNLOADED,
+ NotificationType::CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(this),
NotificationService::NoDetails());
diff --git a/chrome/common/chrome_plugin_util.cc b/chrome/common/chrome_plugin_util.cc
index 610c0b9..e7a2ed0 100644
--- a/chrome/common/chrome_plugin_util.cc
+++ b/chrome/common/chrome_plugin_util.cc
@@ -10,6 +10,7 @@
#include "base/string_util.h"
#include "chrome/common/chrome_plugin_lib.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_service.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
@@ -40,7 +41,7 @@ ScopableCPRequest::~ScopableCPRequest() {
// static
void PluginHelper::DestroyAllHelpersForPlugin(ChromePluginLib* plugin) {
NotificationService::current()->Notify(
- NOTIFY_CHROME_PLUGIN_UNLOADED,
+ NotificationType::CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(plugin),
NotificationService::NoDetails());
}
@@ -48,14 +49,14 @@ void PluginHelper::DestroyAllHelpersForPlugin(ChromePluginLib* plugin) {
PluginHelper::PluginHelper(ChromePluginLib* plugin) : plugin_(plugin) {
DCHECK(CalledOnValidThread());
NotificationService::current()->AddObserver(
- this, NOTIFY_CHROME_PLUGIN_UNLOADED,
+ this, NotificationType::CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(plugin_));
}
PluginHelper::~PluginHelper() {
DCHECK(CalledOnValidThread());
NotificationService::current()->RemoveObserver(
- this, NOTIFY_CHROME_PLUGIN_UNLOADED,
+ this, NotificationType::CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(plugin_));
}
@@ -63,7 +64,7 @@ void PluginHelper::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK(CalledOnValidThread());
- DCHECK(type == NOTIFY_CHROME_PLUGIN_UNLOADED);
+ DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED);
DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr());
delete this;
diff --git a/chrome/common/chrome_plugin_util.h b/chrome/common/chrome_plugin_util.h
index 5ca17fc..0c80c8c 100644
--- a/chrome/common/chrome_plugin_util.h
+++ b/chrome/common/chrome_plugin_util.h
@@ -9,7 +9,7 @@
#include "base/non_thread_safe.h"
#include "base/ref_counted.h"
#include "chrome/common/chrome_plugin_api.h"
-#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_observer.h"
class ChromePluginLib;
class MessageLoop;
diff --git a/chrome/common/net/url_request_intercept_job.cc b/chrome/common/net/url_request_intercept_job.cc
index 01f4e29..08da43a 100644
--- a/chrome/common/net/url_request_intercept_job.cc
+++ b/chrome/common/net/url_request_intercept_job.cc
@@ -11,6 +11,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/common/chrome_plugin_lib.h"
+#include "chrome/common/notification_service.h"
#include "net/base/net_errors.h"
using base::Time;
@@ -31,7 +32,7 @@ URLRequestInterceptJob::URLRequestInterceptJob(URLRequest* request,
cprequest_->data = this; // see FromCPRequest().
NotificationService::current()->AddObserver(
- this, NOTIFY_CHROME_PLUGIN_UNLOADED,
+ this, NotificationType::CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(plugin_));
}
@@ -45,7 +46,7 @@ URLRequestInterceptJob::~URLRequestInterceptJob() {
void URLRequestInterceptJob::DetachPlugin() {
NotificationService::current()->RemoveObserver(
- this, NOTIFY_CHROME_PLUGIN_UNLOADED,
+ this, NotificationType::CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(plugin_));
plugin_ = NULL;
}
@@ -205,7 +206,7 @@ void URLRequestInterceptJob::OnReadCompleted(int bytes_read) {
void URLRequestInterceptJob::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type == NOTIFY_CHROME_PLUGIN_UNLOADED);
+ DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED);
DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr());
DetachPlugin();
diff --git a/chrome/common/net/url_request_intercept_job.h b/chrome/common/net/url_request_intercept_job.h
index 1537281..794a418 100644
--- a/chrome/common/net/url_request_intercept_job.h
+++ b/chrome/common/net/url_request_intercept_job.h
@@ -11,7 +11,7 @@
#include "chrome/browser/chrome_plugin_host.h"
#include "chrome/common/chrome_plugin_api.h"
#include "chrome/common/chrome_plugin_util.h"
-#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_observer.h"
class ChromePluginLib;
diff --git a/chrome/common/notification_registrar.cc b/chrome/common/notification_registrar.cc
index aaa5b9e..b9ea3d7 100644
--- a/chrome/common/notification_registrar.cc
+++ b/chrome/common/notification_registrar.cc
@@ -2,9 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/common/notification_registrar.h"
+
#include <algorithm>
-#include "chrome/common/notification_registrar.h"
+#include "base/logging.h"
+#include "chrome/common/notification_service.h"
+
+struct NotificationRegistrar::Record {
+ bool operator==(const Record& other) const;
+
+ NotificationObserver* observer;
+ NotificationType type;
+ NotificationSource source;
+};
+
+bool NotificationRegistrar::Record::operator==(const Record& other) const {
+ return observer == other.observer &&
+ type == other.type &&
+ source == other.source;
+}
NotificationRegistrar::NotificationRegistrar() {
}
diff --git a/chrome/common/notification_registrar.h b/chrome/common/notification_registrar.h
index 25e46b2..c79d732 100644
--- a/chrome/common/notification_registrar.h
+++ b/chrome/common/notification_registrar.h
@@ -8,7 +8,7 @@
#include <vector>
#include "base/basictypes.h"
-#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_observer.h"
// Aids in registering for notifications and ensures that all registered
// notifications are unregistered when the class is destroyed.
@@ -36,17 +36,7 @@ class NotificationRegistrar {
void RemoveAll();
private:
- struct Record {
- bool operator==(const Record& other) const {
- return observer == other.observer &&
- type == other.type &&
- source == other.source;
- }
-
- NotificationObserver* observer;
- NotificationType type;
- NotificationSource source;
- };
+ struct Record;
// We keep registered notifications in a simple vector. This means we'll do
// brute-force searches when removing them individually, but individual
diff --git a/chrome/common/notification_service.cc b/chrome/common/notification_service.cc
index dccadbe..5b732df 100644
--- a/chrome/common/notification_service.cc
+++ b/chrome/common/notification_service.cc
@@ -33,33 +33,34 @@ NotificationService::NotificationService() {
void NotificationService::AddObserver(NotificationObserver* observer,
NotificationType type,
const NotificationSource& source) {
- DCHECK(type < NOTIFICATION_TYPE_COUNT);
+ DCHECK(type.value < NotificationType::NOTIFICATION_TYPE_COUNT);
NotificationObserverList* observer_list;
- if (HasKey(observers_[type], source)) {
- observer_list = observers_[type][source.map_key()];
+ if (HasKey(observers_[type.value], source)) {
+ observer_list = observers_[type.value][source.map_key()];
} else {
observer_list = new NotificationObserverList;
- observers_[type][source.map_key()] = observer_list;
+ observers_[type.value][source.map_key()] = observer_list;
}
observer_list->AddObserver(observer);
#ifndef NDEBUG
- ++observer_counts_[type];
+ ++observer_counts_[type.value];
#endif
}
void NotificationService::RemoveObserver(NotificationObserver* observer,
NotificationType type,
const NotificationSource& source) {
- DCHECK(type < NOTIFICATION_TYPE_COUNT);
- DCHECK(HasKey(observers_[type], source));
+ DCHECK(type.value < NotificationType::NOTIFICATION_TYPE_COUNT);
+ DCHECK(HasKey(observers_[type.value], source));
- NotificationObserverList* observer_list = observers_[type][source.map_key()];
+ NotificationObserverList* observer_list =
+ observers_[type.value][source.map_key()];
if (observer_list) {
observer_list->RemoveObserver(observer);
#ifndef NDEBUG
- --observer_counts_[type];
+ --observer_counts_[type.value];
#endif
}
@@ -69,34 +70,42 @@ void NotificationService::RemoveObserver(NotificationObserver* observer,
void NotificationService::Notify(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type > NOTIFY_ALL); // Allowed for subscription, but not posting.
- DCHECK(type < NOTIFICATION_TYPE_COUNT);
+ DCHECK(type.value > NotificationType::ALL) <<
+ "Allowed for observing, but not posting.";
+ DCHECK(type.value < NotificationType::NOTIFICATION_TYPE_COUNT);
// 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_[NOTIFY_ALL], AllSources()) &&
- source != AllSources())
+ if (HasKey(observers_[NotificationType::ALL], AllSources()) &&
+ source != AllSources()) {
FOR_EACH_OBSERVER(NotificationObserver,
- *observers_[NOTIFY_ALL][AllSources().map_key()],
- Observe(type, source, details));
+ *observers_[NotificationType::ALL][AllSources().map_key()],
+ Observe(type, source, details));
+ }
+
// Notify observers of all types and the given source
- if (HasKey(observers_[NOTIFY_ALL], source))
+ if (HasKey(observers_[NotificationType::ALL], source)) {
FOR_EACH_OBSERVER(NotificationObserver,
- *observers_[NOTIFY_ALL][source.map_key()],
- Observe(type, source, details));
+ *observers_[NotificationType::ALL][source.map_key()],
+ Observe(type, source, details));
+ }
+
// Notify observers of the given type and all sources
- if (HasKey(observers_[type], AllSources()) &&
- source != AllSources())
+ if (HasKey(observers_[type.value], AllSources()) &&
+ source != AllSources()) {
FOR_EACH_OBSERVER(NotificationObserver,
- *observers_[type][AllSources().map_key()],
+ *observers_[type.value][AllSources().map_key()],
Observe(type, source, details));
+ }
+
// Notify observers of the given type and the given source
- if (HasKey(observers_[type], source))
+ if (HasKey(observers_[type.value], source)) {
FOR_EACH_OBSERVER(NotificationObserver,
- *observers_[type][source.map_key()],
+ *observers_[type.value][source.map_key()],
Observe(type, source, details));
+ }
}
@@ -104,7 +113,7 @@ NotificationService::~NotificationService() {
lazy_tls_ptr.Pointer()->Set(NULL);
#ifndef NDEBUG
- for (int i = 0; i < NOTIFICATION_TYPE_COUNT; i++) {
+ for (int i = 0; i < NotificationType::NOTIFICATION_TYPE_COUNT; i++) {
if (observer_counts_[i] > 0) {
LOG(WARNING) << observer_counts_[i] << " notification observer(s) leaked"
<< " of notification type " << i;
@@ -112,7 +121,7 @@ NotificationService::~NotificationService() {
}
#endif
- for (int i = 0; i < NOTIFICATION_TYPE_COUNT; i++) {
+ for (int i = 0; i < NotificationType::NOTIFICATION_TYPE_COUNT; i++) {
NotificationSourceMap omap = observers_[i];
for (NotificationSourceMap::iterator it = omap.begin();
it != omap.end(); ++it) {
diff --git a/chrome/common/notification_service.h b/chrome/common/notification_service.h
index 170baa6..8fb8981 100644
--- a/chrome/common/notification_service.h
+++ b/chrome/common/notification_service.h
@@ -6,16 +6,16 @@
// happen in various parts of the application, and allows users to register
// observers for various classes of events that they're interested in.
-#ifndef CHROME_COMMON_NOTIFICATION_SERVICE_H__
-#define CHROME_COMMON_NOTIFICATION_SERVICE_H__
+#ifndef CHROME_COMMON_NOTIFICATION_SERVICE_H_
+#define CHROME_COMMON_NOTIFICATION_SERVICE_H_
#include <map>
#include "base/observer_list.h"
-#include "base/values.h"
#include "chrome/common/notification_details.h"
+#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_types.h"
+#include "chrome/common/notification_type.h"
class NotificationObserver;
@@ -86,27 +86,16 @@ class NotificationService {
// 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.
- NotificationSourceMap observers_[NOTIFICATION_TYPE_COUNT];
+ NotificationSourceMap observers_[NotificationType::NOTIFICATION_TYPE_COUNT];
#ifndef NDEBUG
// Used to check to see that AddObserver and RemoveObserver calls are
// balanced.
- int observer_counts_[NOTIFICATION_TYPE_COUNT];
+ int observer_counts_[NotificationType::NOTIFICATION_TYPE_COUNT];
#endif
- DISALLOW_EVIL_CONSTRUCTORS(NotificationService);
+ DISALLOW_COPY_AND_ASSIGN(NotificationService);
};
-// This is the base class for notification observers. When a matching
-// notification is posted to the notification service, Observe is called.
-class NotificationObserver {
- public:
- virtual ~NotificationObserver();
-
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) = 0;
-};
-
-#endif // CHROME_COMMON_NOTIFICATION_SERVICE_H__
+#endif // CHROME_COMMON_NOTIFICATION_SERVICE_H_
diff --git a/chrome/common/notification_service_unittest.cc b/chrome/common/notification_service_unittest.cc
index fb79b33..db46356 100644
--- a/chrome/common/notification_service_unittest.cc
+++ b/chrome/common/notification_service_unittest.cc
@@ -50,25 +50,29 @@ TEST(NotificationServiceTest, Basic) {
NotificationService* service = NotificationService::current();
// Make sure it doesn't freak out when there are no observers.
- service->Notify(NOTIFY_IDLE,
+ service->Notify(NotificationType::IDLE,
Source<TestSource>(&test_source),
NotificationService::NoDetails());
- service->AddObserver(
- &all_types_all_sources, NOTIFY_ALL, NotificationService::AllSources());
- service->AddObserver(
- &idle_all_sources, NOTIFY_IDLE, NotificationService::AllSources());
- service->AddObserver(
- &all_types_test_source, NOTIFY_ALL, Source<TestSource>(&test_source));
- service->AddObserver(
- &idle_test_source, NOTIFY_IDLE, Source<TestSource>(&test_source));
+ service->AddObserver(&all_types_all_sources,
+ NotificationType::ALL,
+ NotificationService::AllSources());
+ service->AddObserver(&idle_all_sources,
+ NotificationType::IDLE,
+ NotificationService::AllSources());
+ service->AddObserver(&all_types_test_source,
+ NotificationType::ALL,
+ Source<TestSource>(&test_source));
+ service->AddObserver(&idle_test_source,
+ NotificationType::IDLE,
+ 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(NOTIFY_IDLE,
+ service->Notify(NotificationType::IDLE,
Source<TestSource>(&test_source),
NotificationService::NoDetails());
@@ -77,7 +81,7 @@ TEST(NotificationServiceTest, Basic) {
EXPECT_EQ(1, all_types_test_source.notification_count());
EXPECT_EQ(1, idle_test_source.notification_count());
- service->Notify(NOTIFY_BUSY,
+ service->Notify(NotificationType::BUSY,
Source<TestSource>(&test_source),
NotificationService::NoDetails());
@@ -86,7 +90,7 @@ TEST(NotificationServiceTest, Basic) {
EXPECT_EQ(2, all_types_test_source.notification_count());
EXPECT_EQ(1, idle_test_source.notification_count());
- service->Notify(NOTIFY_IDLE,
+ service->Notify(NotificationType::IDLE,
Source<TestSource>(&other_source),
NotificationService::NoDetails());
@@ -95,7 +99,7 @@ TEST(NotificationServiceTest, Basic) {
EXPECT_EQ(2, all_types_test_source.notification_count());
EXPECT_EQ(1, idle_test_source.notification_count());
- service->Notify(NOTIFY_BUSY,
+ service->Notify(NotificationType::BUSY,
Source<TestSource>(&other_source),
NotificationService::NoDetails());
@@ -105,7 +109,7 @@ TEST(NotificationServiceTest, Basic) {
EXPECT_EQ(1, idle_test_source.notification_count());
// Try send with NULL source.
- service->Notify(NOTIFY_IDLE,
+ service->Notify(NotificationType::IDLE,
NotificationService::AllSources(),
NotificationService::NoDetails());
@@ -114,16 +118,20 @@ TEST(NotificationServiceTest, Basic) {
EXPECT_EQ(2, all_types_test_source.notification_count());
EXPECT_EQ(1, idle_test_source.notification_count());
- service->RemoveObserver(
- &all_types_all_sources, NOTIFY_ALL, NotificationService::AllSources());
- service->RemoveObserver(
- &idle_all_sources, NOTIFY_IDLE, NotificationService::AllSources());
- service->RemoveObserver(
- &all_types_test_source, NOTIFY_ALL, Source<TestSource>(&test_source));
- service->RemoveObserver(
- &idle_test_source, NOTIFY_IDLE, Source<TestSource>(&test_source));
-
- service->Notify(NOTIFY_IDLE,
+ service->RemoveObserver(&all_types_all_sources,
+ NotificationType::ALL,
+ NotificationService::AllSources());
+ service->RemoveObserver(&idle_all_sources,
+ NotificationType::IDLE,
+ NotificationService::AllSources());
+ service->RemoveObserver(&all_types_test_source,
+ NotificationType::ALL,
+ Source<TestSource>(&test_source));
+ service->RemoveObserver(&idle_test_source,
+ NotificationType::IDLE,
+ Source<TestSource>(&test_source));
+
+ service->Notify(NotificationType::IDLE,
Source<TestSource>(&test_source),
NotificationService::NoDetails());
@@ -134,7 +142,7 @@ TEST(NotificationServiceTest, Basic) {
// Removing an observer that isn't there is a no-op, this should be fine.
service->RemoveObserver(
- &all_types_all_sources, NOTIFY_ALL, NotificationService::AllSources());
+ &all_types_all_sources, NotificationType::ALL, NotificationService::AllSources());
}
TEST(NotificationServiceTest, MultipleRegistration) {
@@ -145,27 +153,27 @@ TEST(NotificationServiceTest, MultipleRegistration) {
NotificationService* service = NotificationService::current();
service->AddObserver(
- &idle_test_source, NOTIFY_IDLE, Source<TestSource>(&test_source));
+ &idle_test_source, NotificationType::IDLE, Source<TestSource>(&test_source));
service->AddObserver(
- &idle_test_source, NOTIFY_ALL, Source<TestSource>(&test_source));
+ &idle_test_source, NotificationType::ALL, Source<TestSource>(&test_source));
- service->Notify(NOTIFY_IDLE,
+ service->Notify(NotificationType::IDLE,
Source<TestSource>(&test_source),
NotificationService::NoDetails());
EXPECT_EQ(2, idle_test_source.notification_count());
service->RemoveObserver(
- &idle_test_source, NOTIFY_IDLE, Source<TestSource>(&test_source));
+ &idle_test_source, NotificationType::IDLE, Source<TestSource>(&test_source));
- service->Notify(NOTIFY_IDLE,
+ service->Notify(NotificationType::IDLE,
Source<TestSource>(&test_source),
NotificationService::NoDetails());
EXPECT_EQ(3, idle_test_source.notification_count());
service->RemoveObserver(
- &idle_test_source, NOTIFY_ALL, Source<TestSource>(&test_source));
+ &idle_test_source, NotificationType::ALL, Source<TestSource>(&test_source));
- service->Notify(NOTIFY_IDLE,
+ service->Notify(NotificationType::IDLE,
Source<TestSource>(&test_source),
NotificationService::NoDetails());
EXPECT_EQ(3, idle_test_source.notification_count());
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
new file mode 100644
index 0000000..6894f49
--- /dev/null
+++ b/chrome/common/notification_type.h
@@ -0,0 +1,557 @@
+// Copyright (c) 2006-2008 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 CHROME_COMMON_NOTIFICATION_TYPE_H_
+#define CHROME_COMMON_NOTIFICATION_TYPE_H_
+
+// This file describes various types used to describe and filter notifications
+// that pass through the NotificationService.
+//
+// It is written as an enum inside a class so that it can be forward declared.
+// You're not allowed to forward declare an enum, and we want to forward
+// declare this since it's required by NotificationObserver which is included
+// by a lot of header files.
+//
+// Since this class encapsulates an integral value, it should be passed by
+// value.
+class NotificationType {
+ public:
+ enum Type {
+ // General -----------------------------------------------------------------
+
+ // Special signal value to represent an interest in all notifications.
+ // Not valid when posting a notification.
+ ALL = 0,
+
+ // The app is done processing user actions, now is a good time to do
+ // some background work.
+ IDLE,
+
+ // Means that the app has just started doing something in response to a
+ // user action, and that background processes shouldn't run if avoidable.
+ BUSY,
+
+ // This is sent when the user does a gesture resulting in a noteworthy
+ // action taking place. This is typically used for logging. The source is
+ // the profile, and the details is a wstring identifying the action.
+ USER_ACTION,
+
+ // NavigationController ----------------------------------------------------
+
+ // A new pending navigation has been created. Pending entries are created
+ // when the user requests the navigation. We don't know if it will actually
+ // happen until it does (at this point, it will be "committed." Note that
+ // renderer- initiated navigations such as link clicks will never be
+ // pending.
+ //
+ // This notification is called after the pending entry is created, but
+ // before we actually try to navigate. The source will be the
+ // NavigationController that owns the pending entry, and there are no
+ // details.
+ NAV_ENTRY_PENDING,
+
+ // A new non-pending navigation entry has been created. This will
+ // correspond to one NavigationController entry being created (in the case
+ // of new navigations) or renavigated to (for back/forward navigations).
+ //
+ // The source will be the navigation controller doing the commit. The
+ // details will be NavigationController::LoadCommittedDetails.
+ NAV_ENTRY_COMMITTED,
+
+ // Indicates that the NavigationController given in the Source has
+ // decreased its back/forward list count by removing entries from either
+ // the front or back of its list. This is usually the result of going back
+ // and then doing a new navigation, meaning all the "forward" items are
+ // deleted.
+ //
+ // This normally happens as a result of a new navigation. It will be
+ // followed by a NAV_ENTRY_COMMITTED message for the new page that
+ // caused the pruning. It could also be a result of removing an item from
+ // the list to fix up after interstitials.
+ //
+ // The details are NavigationController::PrunedDetails.
+ NAV_LIST_PRUNED,
+
+ // Indicates that a NavigationEntry has changed. The source will be the
+ // NavigationController that owns the NavigationEntry. The details will be
+ // a NavigationController::EntryChangedDetails struct.
+ //
+ // This will NOT be sent on navigation, interested parties should also
+ // listen for NAV_ENTRY_COMMITTED to handle that case. This will be
+ // sent when the entry is updated outside of navigation (like when a new
+ // title comes).
+ NAV_ENTRY_CHANGED,
+
+ // Other load-related (not from NavigationController) ----------------------
+
+ // A content load is starting. The source will be a
+ // Source<NavigationController> corresponding to the tab in which the load
+ // is occurring. No details are expected for this notification.
+ LOAD_START,
+
+ // A content load has stopped. The source will be a
+ // Source<NavigationController> corresponding to the tab in which the load
+ // is occurring. Details in the form of a LoadNotificationDetails object
+ // are optional.
+ LOAD_STOP,
+
+ // A frame is staring a provisional load. The source is a
+ // Source<NavigationController> corresponding to the tab in which the load
+ // occurs. Details is a bool specifying if the load occurs in the main
+ // frame (or a sub-frame if false).
+ FRAME_PROVISIONAL_LOAD_START,
+
+ // Content was loaded from an in-memory cache. The source will be a
+ // Source<NavigationController> corresponding to the tab in which the load
+ // occurred. Details in the form of a LoadFromMemoryCacheDetails object
+ // are provided.
+ LOAD_FROM_MEMORY_CACHE,
+
+ // A provisional content load has failed with an error. The source will be
+ // a Source<NavigationController> corresponding to the tab in which the
+ // load occurred. Details in the form of a ProvisionalLoadDetails object
+ // are provided.
+ FAIL_PROVISIONAL_LOAD_WITH_ERROR,
+
+ // A response has been received for a resource request. The source will be
+ // a Source<NavigationController> corresponding to the tab in which the
+ // request was issued. Details in the form of a ResourceRequestDetails
+ // object are provided.
+ RESOURCE_RESPONSE_STARTED,
+
+ // The response to a resource request has completed. The source will be a
+ // Source<NavigationController> corresponding to the tab in which the
+ // request was issued. Details in the form of a ResourceRequestDetails
+ // object are provided.
+ RESOURCE_RESPONSE_COMPLETED,
+
+ // A redirect was received while requesting a resource. The source will be
+ // a Source<NavigationController> corresponding to the tab in which the
+ // request was issued. Details in the form of a ResourceRedirectDetails
+ // are provided.
+ RESOURCE_RECEIVED_REDIRECT,
+
+ // The SSL state of a page has changed somehow. For example, if an insecure
+ // resource is loaded on a secure page. Note that a toplevel load commit
+ // will also update the SSL state (since the NavigationEntry is new) and
+ // this message won't always be sent in that case.
+ //
+ // The source will be the navigation controller associated with the load.
+ // There are no details. The entry changed will be the active entry of the
+ // controller.
+ SSL_STATE_CHANGED,
+
+ // Download start and stop notifications. Stop notifications can occur on
+ // both normal completion or via a cancel operation.
+ DOWNLOAD_START, DOWNLOAD_STOP,
+
+ // Views -------------------------------------------------------------------
+
+ // Notification that a view was removed from a view hierarchy. The source
+ // is the view, the details is the parent view.
+ VIEW_REMOVED,
+
+ // Browser-window ----------------------------------------------------------
+
+ // This message is sent after a window has been opened. The source is a
+ // Source<Browser> with a pointer to the new window. No details are
+ // expected.
+ BROWSER_OPENED,
+
+ // This message is sent after a window has been closed. The source is a
+ // Source<Browser> with a pointer to the closed window. Details is a
+ // boolean that if true indicates that the application will be closed as a
+ // result of this browser window closure (i.e. this was the last opened
+ // browser window). Note that the boolean pointed to by Details is only
+ // valid for the duration of this call.
+ BROWSER_CLOSED,
+
+ // This message is sent when the last window considered to be an
+ // "application window" has been closed. Dependent/dialog/utility windows
+ // can use this as a way to know that they should also close. No source or
+ // details are passed.
+ ALL_APPWINDOWS_CLOSED,
+
+ // Indicates that a top window has been closed. The source is the HWND
+ // that was closed, no details are expected.
+ WINDOW_CLOSED,
+
+ // Tabs --------------------------------------------------------------------
+
+ // This notification is sent after a tab has been appended to the
+ // tab_strip. The source is a Source<NavigationController> with a pointer
+ // to controller for the added tab. There are no details.
+ TAB_PARENTED,
+
+ // This message is sent before a tab has been closed. The source is a
+ // Source<NavigationController> with a pointer to the controller for the
+ // closed tab. No details are expected.
+ //
+ // See also TAB_CLOSED.
+ TAB_CLOSING,
+
+ // Notification that a tab has been closed. The source is the
+ // NavigationController with no details.
+ TAB_CLOSED,
+
+ // This notification is sent when a render view host has connected to a
+ // renderer process. The source is a Source<WebContents> with a pointer to
+ // the WebContents. A WEB_CONTENTS_DISCONNECTED notification is
+ // guaranteed before the source pointer becomes junk. No details are
+ // expected.
+ WEB_CONTENTS_CONNECTED,
+
+ // This notification is sent when a WebContents swaps its render view host
+ // with another one, possibly changing processes. The source is a
+ // Source<WebContents> with a pointer to the WebContents. A
+ // WEB_CONTENTS_DISCONNECTED notification is guaranteed before the
+ // source pointer becomes junk. No details are expected.
+ WEB_CONTENTS_SWAPPED,
+
+ // This message is sent after a WebContents is disconnected from the
+ // renderer process. The source is a Source<WebContents> with a pointer to
+ // the WebContents (the pointer is usable). No details are expected.
+ WEB_CONTENTS_DISCONNECTED,
+
+ // This message is sent when a new InfoBar has been added to a TabContents.
+ // The source is a Source<TabContents> with a pointer to the TabContents
+ // the InfoBar was added to. The details is a Details<InfoBarDelegate> with
+ // a pointer to an object implementing the InfoBarDelegate interface for
+ // the InfoBar that was added.
+ TAB_CONTENTS_INFOBAR_ADDED,
+
+ // This message is sent when an InfoBar is about to be removed from a
+ // TabContents. The source is a Source<TabContents> with a pointer to the
+ // TabContents the InfoBar was removed from. The details is a
+ // Details<InfoBarDelegate> with a pointer to an object implementing the
+ // InfoBarDelegate interface for the InfoBar that was removed.
+ TAB_CONTENTS_INFOBAR_REMOVED,
+
+ // This is sent when an externally hosted tab is created. The details
+ // contain the ExternalTabContainer that contains the tab
+ EXTERNAL_TAB_CREATED,
+
+ // This is sent when an externally hosted tab is closed. No details are
+ // expected.
+ EXTERNAL_TAB_CLOSED,
+
+ // Indicates that the new page tab has finished loading. This is used for
+ // performance testing to see how fast we can load it after startup, and is
+ // only called once for the lifetime of the browser. The source is unused.
+ // Details is an integer: the number of milliseconds elapsed between
+ // starting and finishing all painting.
+ INITIAL_NEW_TAB_UI_LOAD,
+
+ // This notification is sent when a TabContents is being hidden, e.g. due
+ // to switching away from this tab. The source is a Source<TabContents>.
+ TAB_CONTENTS_HIDDEN,
+
+ // This notification is sent when a TabContents is being destroyed. Any
+ // object holding a reference to a TabContents can listen to that
+ // notification to properly reset the reference. The source is a
+ // Source<TabContents>.
+ TAB_CONTENTS_DESTROYED,
+
+ // Stuff inside the tabs ---------------------------------------------------
+
+ // This message is sent after a constrained window has been closed. The
+ // source is a Source<ConstrainedWindow> with a pointer to the closed child
+ // window. (The pointer isn't usable, except for identification.) No
+ // details are expected.
+ CWINDOW_CLOSED,
+
+ // Indicates that a render process has terminated. The source will be the
+ // RenderProcessHost that corresponds to the process, and the details is a
+ // bool specifying whether the termination was expected, i.e. if false it
+ // means the process crashed.
+ RENDERER_PROCESS_TERMINATED,
+
+ // Indicates that a render process has become unresponsive for a period of
+ // time. The source will be the RenderWidgetHost that corresponds to the
+ // hung view, and no details are expected.
+ RENDERER_PROCESS_HANG,
+
+ // Indicates that a render process is created in the sandbox. The source
+ // will be the RenderProcessHost that corresponds to the created process
+ // and the detail is a bool telling us if the process got created on the
+ // sandbox desktop or not.
+ RENDERER_PROCESS_IN_SBOX,
+
+ // This is sent to notify that the RenderViewHost displayed in a
+ // WebContents has changed. Source is the WebContents for which the change
+ // happened, details is the previous RenderViewHost (can be NULL when the
+ // first RenderViewHost is set).
+ RENDER_VIEW_HOST_CHANGED,
+
+ // This is sent when a RenderWidgetHost is being destroyed. The source is
+ // the RenderWidgetHost, the details are not used.
+ RENDER_WIDGET_HOST_DESTROYED,
+
+ // Notification from WebContents that we have received a response from the
+ // renderer after using the dom inspector.
+ DOM_INSPECT_ELEMENT_RESPONSE,
+
+ // Notification from WebContents that we have received a response from the
+ // renderer in response to a dom automation controller action.
+ DOM_OPERATION_RESPONSE,
+
+ // Sent when the bookmark bubble hides. The source is the profile, the
+ // details unused.
+ BOOKMARK_BUBBLE_HIDDEN,
+
+ // This notification is sent when the result of a find-in-page search is
+ // available with the browser process. The source is a Source<TabContents>
+ // with a pointer to the WebContents. Details encompass a
+ // FindNotificationDetail object that tells whether the match was found or
+ // not found.
+ FIND_RESULT_AVAILABLE,
+
+ // This is sent when the users preference for when the bookmark bar should
+ // be shown changes. The source is the profile, and the details are
+ // NoDetails.
+ BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
+
+ // Used to monitor web cache usage by notifying whenever the
+ // CacheManagerHost observes new UsageStats. The source will be the
+ // RenderProcessHost that corresponds to the new statistics. Details are a
+ // UsageStats object sent by the renderer, and should be copied - ptr not
+ // guaranteed to be valid after the notification.
+ WEB_CACHE_STATS_OBSERVED,
+
+ // Plugins -----------------------------------------------------------------
+
+ // This notification is sent when a plugin process host has connected to a
+ // plugin process. There is no usable source, since it is sent from an
+ // ephemeral task; register for AllSources() to receive this notification.
+ // The details are in a Details<PluginProcessInfo> with a pointer to a
+ // plug-in process info for the plugin, that is only valid for the time of
+ // the notification (don't keep this pointer around, make a copy of the
+ // object if you need to keep it).
+ PLUGIN_PROCESS_HOST_CONNECTED,
+
+ // This message is sent after a PluginProcessHost is disconnected from the
+ // plugin process. There is no usable source, since it is sent from an
+ // ephemeral task; register for AllSources() to receive this notification.
+ // The details are in a Details<PluginProcessInfo> with a pointer to a
+ // plug-in process info for the plugin, that is only valid for the time of
+ // the notification (don't keep this pointer around, make a copy of the
+ // object if you need to keep it).
+ PLUGIN_PROCESS_HOST_DISCONNECTED,
+
+ // This message is sent when a plugin process disappears unexpectedly.
+ // There is no usable source, since it is sent from an ephemeral task;
+ // register for AllSources() to receive this notification. The details are
+ // in a Details<PluginProcessInfo> with a pointer to a plug-in process info
+ // for the plugin, that is only valid for the time of the notification
+ // (don't keep this pointer around, make a copy of the object if you need
+ // to keep it).
+ PLUGIN_PROCESS_CRASHED,
+
+ // This message indicates that an instance of a particular plugin was
+ // created in a page. (If one page contains several regions rendered by
+ // the same plugin, this notification will occur once for each region
+ // during the page load.)
+ //
+ // There is no usable source, since it is sent from an ephemeral task;
+ // register for AllSources() to receive this notification. The details are
+ // in a Details<PluginProcessInfo> with a pointer to a plug-in process info
+ // for the plugin, that is only valid for the time of the notification
+ // (don't keep this pointer around, make a copy of the object if you need
+ // to keep it).
+ PLUGIN_INSTANCE_CREATED,
+
+ // This is sent when network interception is disabled for a plugin, or the
+ // plugin is unloaded. This should only be sent/received on the browser IO
+ // thread or the plugin thread. The source is the plugin that is disabling
+ // interception. No details are expected.
+ CHROME_PLUGIN_UNLOADED,
+
+ // This is sent when a login prompt is shown. The source is the
+ // Source<NavigationController> for the tab in which the prompt is shown.
+ // Details are a LoginNotificationDetails which provide the LoginHandler
+ // that should be given authentication.
+ AUTH_NEEDED,
+
+ // This is sent when authentication credentials have been supplied (either
+ // by the user or by an automation service), but before we've actually
+ // received another response from the server. The source is the
+ // Source<NavigationController> for the tab in which the prompt was shown.
+ // No details are expected.
+ AUTH_SUPPLIED,
+
+ // History -----------------------------------------------------------------
+
+ // Sent when a history service is created on the main thread. This is sent
+ // after history is created, but before it has finished loading. Use
+ // HISTORY_LOADED is you need to know when loading has completed.
+ // The source is the profile that the history service belongs to, and the
+ // details is the pointer to the newly created HistoryService object.
+ HISTORY_CREATED,
+
+ // Sent when a history service has finished loading. The source is the
+ // profile that the history service belongs to, and the details is the
+ // HistoryService.
+ HISTORY_LOADED,
+
+ // Sent when a URL that has been typed has been added or modified. This is
+ // used by the in-memory URL database (used by autocomplete) to track
+ // changes to the main history system.
+ //
+ // The source is the profile owning the history service that changed, and
+ // the details is history::URLsModifiedDetails that lists the modified or
+ // added URLs.
+ HISTORY_TYPED_URLS_MODIFIED,
+
+ // Sent when the user visits a URL.
+ //
+ // The source is the profile owning the history service that changed, and
+ // the details is history::URLVisitedDetails.
+ HISTORY_URL_VISITED,
+
+ // Sent when one or more URLs are deleted.
+ //
+ // The source is the profile owning the history service that changed, and
+ // the details is history::URLsDeletedDetails that lists the deleted URLs.
+ HISTORY_URLS_DELETED,
+
+ // Sent by history when the favicon of a URL changes. The source is the
+ // profile, and the details is history::FavIconChangeDetails (see
+ // history_notifications.h).
+ FAVICON_CHANGED,
+
+ // Bookmarks ---------------------------------------------------------------
+
+ // Sent when the starred state of a URL changes. A URL is starred if there
+ // is at least one bookmark for it. The source is a Profile and the details
+ // is history::URLsStarredDetails that contains the list of URLs and
+ // whether they were starred or unstarred.
+ URLS_STARRED,
+
+ // Sent when the bookmark bar model finishes loading. This source is the
+ // Profile, and the details aren't used.
+ BOOKMARK_MODEL_LOADED,
+
+ // Sent when the spellchecker object changes. Note that this is not sent
+ // the first time the spellchecker gets initialized. The source is the
+ // profile, the details is SpellcheckerReinitializedDetails defined in
+ // profile.
+ SPELLCHECKER_REINITIALIZED,
+
+ // Sent when the bookmark bubble is shown for a particular URL. The source
+ // is the profile, the details the URL.
+ BOOKMARK_BUBBLE_SHOWN,
+
+ // Non-history storage services --------------------------------------------
+
+ // Notification that the TemplateURLModel has finished loading from the
+ // database. The source is the TemplateURLModel, and the details are
+ // NoDetails.
+ TEMPLATE_URL_MODEL_LOADED,
+
+ // Notification triggered when a web application has been installed or
+ // uninstalled. Any application view should reload its data. The source is
+ // the profile. No details are provided.
+ WEB_APP_INSTALL_CHANGED,
+
+ // This is sent to a pref observer when a pref is changed.
+ PREF_CHANGED,
+
+ // Sent when a default request context has been created, so calling
+ // Profile::GetDefaultRequestContext() will not return NULL. This is sent
+ // on the thread where Profile::GetRequestContext() is first called, which
+ // should be the UI thread.
+ DEFAULT_REQUEST_CONTEXT_AVAILABLE,
+
+ // Autocomplete ------------------------------------------------------------
+
+ // Sent by the autocomplete controller at least once per query, each time
+ // new matches are available, subject to rate-limiting/coalescing to reduce
+ // the number of updates. There are no details.
+ AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED,
+
+ // Sent by the autocomplete controller once per query, immediately after
+ // synchronous matches become available. There are no details.
+ AUTOCOMPLETE_CONTROLLER_SYNCHRONOUS_MATCHES_AVAILABLE,
+
+ // This is sent when an item of the Omnibox popup is selected. The source
+ // is the profile.
+ OMNIBOX_OPENED_URL,
+
+ // Sent by the autocomplete edit when it is destroyed.
+ AUTOCOMPLETE_EDIT_DESTROYED,
+
+ // Sent when the main Google URL has been updated. Some services cache
+ // this value and need to update themselves when it changes. See
+ // google_util::GetGoogleURLAndUpdateIfNecessary().
+ GOOGLE_URL_UPDATED,
+
+ // Printing ----------------------------------------------------------------
+
+ // Notification from a PrintedDocument that it has been updated. It may be
+ // that a printed page has just been generated or that the document's
+ // number of pages has been calculated. Details is the new page or NULL if
+ // only the number of pages in the document has been updated.
+ PRINTED_DOCUMENT_UPDATED,
+
+ // Notification from PrintJob that an event occured. It can be that a page
+ // finished printing or that the print job failed. Details is
+ // PrintJob::EventDetails.
+ PRINT_JOB_EVENT,
+
+ // Shutdown ----------------------------------------------------------------
+
+ // Sent on the browser IO thread when an URLRequestContext is released by
+ // its owning Profile. The source is a pointer to the URLRequestContext.
+ URL_REQUEST_CONTEXT_RELEASED,
+
+ // Sent when WM_ENDSESSION has been received, after the browsers have been
+ // closed but before browser process has been shutdown. The source/details
+ // are all source and no details.
+ SESSION_END,
+
+ // Personalization ---------------------------------------------------------
+
+ PERSONALIZATION,
+ PERSONALIZATION_CREATED,
+
+ // User Scripts ------------------------------------------------------------
+
+ // Sent when there are new user scripts available. The details are a
+ // pointer to SharedMemory containing the new scripts.
+ USER_SCRIPTS_LOADED,
+
+ // Extensions --------------------------------------------------------------
+
+ // Sent when new extensions are loaded. The details are an ExtensionList*.
+ EXTENSIONS_LOADED,
+
+ // Sent when new extensions are installed. The details are a FilePath.
+ EXTENSION_INSTALLED,
+
+ // Count (must be last) ----------------------------------------------------
+ // Used to determine the number of notification types. Not valid as
+ // a type parameter when registering for or posting notifications.
+ NOTIFICATION_TYPE_COUNT
+ };
+
+ NotificationType(Type v) : value(v) {}
+
+ bool operator==(NotificationType t) const { return value == t.value; }
+ bool operator!=(NotificationType t) const { return value != t.value; }
+
+ // Comparison to explicit enum values.
+ bool operator==(Type v) const { return value == v; }
+ bool operator!=(Type v) const { return value != v; }
+
+ Type value;
+};
+
+inline bool operator==(NotificationType::Type a, NotificationType b) {
+ return a == b.value;
+}
+inline bool operator!=(NotificationType::Type a, NotificationType b) {
+ return a != b.value;
+}
+
+#endif // CHROME_COMMON_NOTIFICATION_TYPE_H_
diff --git a/chrome/common/notification_types.h b/chrome/common/notification_types.h
deleted file mode 100644
index 788ba17..0000000
--- a/chrome/common/notification_types.h
+++ /dev/null
@@ -1,525 +0,0 @@
-// Copyright (c) 2006-2008 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.
-
-// This file describes various types used to describe and filter notifications
-// that pass through the NotificationService.
-
-#ifndef CHROME_COMMON_NOTIFICATION_TYPES_H__
-#define CHROME_COMMON_NOTIFICATION_TYPES_H__
-
-enum NotificationType {
- // General -------------------------------------------------------------------
-
- // Special signal value to represent an interest in all notifications.
- // Not valid when posting a notification.
- NOTIFY_ALL = 0,
-
- // The app is done processing user actions, now is a good time to do
- // some background work.
- NOTIFY_IDLE,
-
- // Means that the app has just started doing something in response
- // to a user action, and that background processes shouldn't run if avoidable.
- NOTIFY_BUSY,
-
- // This is sent when the user does a gesture resulting in a noteworthy
- // action taking place. This is typically used for logging. The
- // source is the profile, and the details is a wstring identifying the action.
- NOTIFY_USER_ACTION,
-
- // NavigationController ------------------------------------------------------
-
- // A new pending navigation has been created. Pending entries are created when
- // the user requests the navigation. We don't know if it will actually happen
- // until it does (at this point, it will be "committed." Note that renderer-
- // initiated navigations such as link clicks will never be pending.
- //
- // This notification is called after the pending entry is created, but before
- // we actually try to navigate. The source will be the NavigationController
- // that owns the pending entry, and there are no details.
- NOTIFY_NAV_ENTRY_PENDING,
-
- // A new non-pending navigation entry has been created. This will correspond
- // to one NavigationController entry being created (in the case of new
- // navigations) or renavigated to (for back/forward navigations).
- //
- // The source will be the navigation controller doing the commit. The details
- // will be NavigationController::LoadCommittedDetails.
- NOTIFY_NAV_ENTRY_COMMITTED,
-
- // Indicates that the NavigationController given in the Source has decreased
- // its back/forward list count by removing entries from either the front or
- // back of its list. This is usually the result of going back and then doing a
- // new navigation, meaning all the "forward" items are deleted.
- //
- // This normally happens as a result of a new navigation. It will be followed
- // by a NOTIFY_NAV_ENTRY_COMMITTED message for the new page that caused the
- // pruning. It could also be a result of removing an item from the list to fix
- // up after interstitials.
- //
- // The details are NavigationController::PrunedDetails.
- NOTIFY_NAV_LIST_PRUNED,
-
- // Indicates that a NavigationEntry has changed. The source will be the
- // NavigationController that owns the NavigationEntry. The details will be
- // a NavigationController::EntryChangedDetails struct.
- //
- // This will NOT be sent on navigation, interested parties should also listen
- // for NOTIFY_NAV_ENTRY_COMMITTED to handle that case. This will be sent when
- // the entry is updated outside of navigation (like when a new title comes).
- NOTIFY_NAV_ENTRY_CHANGED,
-
- // Other load-related (not from NavigationController) ------------------------
-
- // A content load is starting. The source will be a
- // Source<NavigationController> corresponding to the tab
- // in which the load is occurring. No details are
- // expected for this notification.
- NOTIFY_LOAD_START,
-
- // A content load has stopped. The source will be a
- // Source<NavigationController> corresponding to the tab
- // in which the load is occurring. Details in the form of a
- // LoadNotificationDetails object are optional.
- NOTIFY_LOAD_STOP,
-
- // A frame is staring a provisional load. The source is a
- // Source<NavigationController> corresponding to the tab in which the load
- // occurs. Details is a bool specifying if the load occurs in the main
- // frame (or a sub-frame if false).
- NOTIFY_FRAME_PROVISIONAL_LOAD_START,
-
- // Content was loaded from an in-memory cache. The source will be a
- // Source<NavigationController> corresponding to the tab
- // in which the load occurred. Details in the form of a
- // LoadFromMemoryCacheDetails object are provided.
- NOTIFY_LOAD_FROM_MEMORY_CACHE,
-
- // A provisional content load has failed with an error. The source will be a
- // Source<NavigationController> corresponding to the tab
- // in which the load occurred. Details in the form of a
- // ProvisionalLoadDetails object are provided.
- NOTIFY_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
-
- // A response has been received for a resource request. The source will be a
- // Source<NavigationController> corresponding to the tab in which the request
- // was issued. Details in the form of a ResourceRequestDetails object are
- // provided.
- NOTIFY_RESOURCE_RESPONSE_STARTED,
-
- // The response to a resource request has completed. The source will be a
- // Source<NavigationController> corresponding to the tab in which the request
- // was issued. Details in the form of a ResourceRequestDetails object are
- // provided.
- NOTIFY_RESOURCE_RESPONSE_COMPLETED,
-
- // A redirect was received while requesting a resource. The source will be a
- // Source<NavigationController> corresponding to the tab in which the request
- // was issued. Details in the form of a ResourceRedirectDetails are provided.
- NOTIFY_RESOURCE_RECEIVED_REDIRECT,
-
- // The SSL state of a page has changed somehow. For example, if an insecure
- // resource is loaded on a secure page. Note that a toplevel load commit
- // will also update the SSL state (since the NavigationEntry is new) and this
- // message won't always be sent in that case.
- //
- // The source will be the navigation controller associated with the load.
- // There are no details. The entry changed will be the active entry of the
- // controller.
- NOTIFY_SSL_STATE_CHANGED,
-
- // Download start and stop notifications. Stop notifications can occur on both
- // normal completion or via a cancel operation.
- NOTIFY_DOWNLOAD_START,
- NOTIFY_DOWNLOAD_STOP,
-
- // Views ---------------------------------------------------------------------
-
- // Notification that a view was removed from a view hierarchy. The source is
- // the view, the details is the parent view.
- NOTIFY_VIEW_REMOVED,
-
- // Browser-window ------------------------------------------------------------
-
- // This message is sent after a window has been opened. The source is
- // a Source<Browser> with a pointer to the new window.
- // No details are expected.
- NOTIFY_BROWSER_OPENED,
-
- // This message is sent after a window has been closed. The source is
- // a Source<Browser> with a pointer to the closed window.
- // Details is a boolean that if true indicates that the application will be
- // closed as a result of this browser window closure (i.e. this was the last
- // opened browser window). Note that the boolean pointed to by Details is
- // only valid for the duration of this call.
- NOTIFY_BROWSER_CLOSED,
-
- // This message is sent when the last window considered to be an "application
- // window" has been closed. Dependent/dialog/utility windows can use this as
- // a way to know that they should also close. No source or details are passed.
- NOTIFY_ALL_APPWINDOWS_CLOSED,
-
- // Indicates that a top window has been closed. The source is the HWND that
- // was closed, no details are expected.
- NOTIFY_WINDOW_CLOSED,
-
- // Tabs ----------------------------------------------------------------------
-
- // This notification is sent after a tab has been appended to the tab_strip.
- // The source is a Source<NavigationController> with a pointer to
- // controller for the added tab. There are no details.
- NOTIFY_TAB_PARENTED,
-
- // This message is sent before a tab has been closed. The source is
- // a Source<NavigationController> with a pointer to the controller for the
- // closed tab.
- // No details are expected.
- //
- // See also NOTIFY_TAB_CLOSED.
- NOTIFY_TAB_CLOSING,
-
- // Notification that a tab has been closed. The source is the
- // NavigationController with no details.
- NOTIFY_TAB_CLOSED,
-
- // This notification is sent when a render view host has connected to a
- // renderer process. The source is a Source<WebContents> with a pointer to
- // the WebContents. A NOTIFY_WEB_CONTENTS_DISCONNECTED notification is
- // guaranteed before the source pointer becomes junk.
- // No details are expected.
- NOTIFY_WEB_CONTENTS_CONNECTED,
-
- // This notification is sent when a WebContents swaps its render view host
- // with another one, possibly changing processes. The source is a
- // Source<WebContents> with a pointer to the WebContents. A
- // NOTIFY_WEB_CONTENTS_DISCONNECTED notification is guaranteed before the
- // source pointer becomes junk.
- // No details are expected.
- NOTIFY_WEB_CONTENTS_SWAPPED,
-
- // This message is sent after a WebContents is disconnected from the
- // renderer process.
- // The source is a Source<WebContents> with a pointer to the WebContents
- // (the pointer is usable).
- // No details are expected.
- NOTIFY_WEB_CONTENTS_DISCONNECTED,
-
- // This message is sent when a new InfoBar has been added to a TabContents.
- // The source is a Source<TabContents> with a pointer to the TabContents the
- // InfoBar was added to. The details is a Details<InfoBarDelegate> with a
- // pointer to an object implementing the InfoBarDelegate interface for the
- // InfoBar that was added.
- NOTIFY_TAB_CONTENTS_INFOBAR_ADDED,
-
- // This message is sent when an InfoBar is about to be removed from a
- // TabContents. The source is a Source<TabContents> with a pointer to the
- // TabContents the InfoBar was removed from. The details is a
- // Details<InfoBarDelegate> with a pointer to an object implementing the
- // InfoBarDelegate interface for the InfoBar that was removed.
- NOTIFY_TAB_CONTENTS_INFOBAR_REMOVED,
-
- // This is sent when an externally hosted tab is created. The details contain
- // the ExternalTabContainer that contains the tab
- NOTIFY_EXTERNAL_TAB_CREATED,
-
- // This is sent when an externally hosted tab is closed.
- // No details are expected.
- NOTIFY_EXTERNAL_TAB_CLOSED,
-
- // Indicates that the new page tab has finished loading. This is
- // used for performance testing to see how fast we can load it after startup,
- // and is only called once for the lifetime of the browser. The source is
- // unused. Details is an integer: the number of milliseconds elapsed between
- // starting and finishing all painting.
- NOTIFY_INITIAL_NEW_TAB_UI_LOAD,
-
- // This notification is sent when a TabContents is being hidden, e.g. due to
- // switching away from this tab. The source is a Source<TabContents>.
- NOTIFY_TAB_CONTENTS_HIDDEN,
-
- // This notification is sent when a TabContents is being destroyed. Any object
- // holding a reference to a TabContents can listen to that notification to
- // properly reset the reference. The source is a Source<TabContents>.
- NOTIFY_TAB_CONTENTS_DESTROYED,
-
- // Stuff inside the tabs -----------------------------------------------------
-
- // This message is sent after a constrained window has been closed. The
- // source is a Source<ConstrainedWindow> with a pointer to the closed child
- // window. (The pointer isn't usable, except for identification.) No details
- // are expected.
- NOTIFY_CWINDOW_CLOSED,
-
- // Indicates that a render process has terminated. The source will be the
- // RenderProcessHost that corresponds to the process, and the details is a
- // bool specifying whether the termination was expected, i.e. if false it
- // means the process crashed.
- NOTIFY_RENDERER_PROCESS_TERMINATED,
-
- // Indicates that a render process has become unresponsive for a period of
- // time. The source will be the RenderWidgetHost that corresponds to the hung
- // view, and no details are expected.
- NOTIFY_RENDERER_PROCESS_HANG,
-
- // Indicates that a render process is created in the sandbox. The source
- // will be the RenderProcessHost that corresponds to the created process
- // and the detail is a bool telling us if the process got created on the
- // sandbox desktop or not.
- NOTIFY_RENDERER_PROCESS_IN_SBOX,
-
- // This is sent to notify that the RenderViewHost displayed in a WebContents
- // has changed. Source is the WebContents for which the change happened,
- // details is the previous RenderViewHost (can be NULL when the first
- // RenderViewHost is set).
- NOTIFY_RENDER_VIEW_HOST_CHANGED,
-
- // This is sent when a RenderWidgetHost is being destroyed. The source
- // is the RenderWidgetHost, the details are not used.
- NOTIFY_RENDER_WIDGET_HOST_DESTROYED,
-
- // Notification from WebContents that we have received a response from
- // the renderer after using the dom inspector.
- NOTIFY_DOM_INSPECT_ELEMENT_RESPONSE,
-
- // Notification from WebContents that we have received a response from
- // the renderer in response to a dom automation controller action.
- NOTIFY_DOM_OPERATION_RESPONSE,
-
- // Sent when the bookmark bubble hides. The source is the profile, the
- // details unused.
- NOTIFY_BOOKMARK_BUBBLE_HIDDEN,
-
- // This notification is sent when the result of a find-in-page search is
- // available with the browser process. The source is a Source<TabContents>
- // with a pointer to the WebContents. Details encompass a
- // FindNotificationDetail object that tells whether the match was
- // found or not found.
- NOTIFY_FIND_RESULT_AVAILABLE,
-
- // This is sent when the users preference for when the bookmark bar should
- // be shown changes. The source is the profile, and the details are
- // NoDetails.
- NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
-
- // Used to monitor web cache usage by notifying whenever the CacheManagerHost
- // observes new UsageStats. The source will be the RenderProcessHost that
- // corresponds to the new statistics. Details are a UsageStats object sent
- // by the renderer, and should be copied - ptr not guaranteed to be valid
- // after the notification.
- NOTIFY_WEB_CACHE_STATS_OBSERVED,
-
- // Plugins -------------------------------------------------------------------
-
- // This notification is sent when a plugin process host has connected to a
- // plugin process. There is no usable source, since it is sent from an
- // ephemeral task; register for AllSources() to receive this notification.
- // The details are in a Details<PluginProcessInfo> with a pointer to
- // a plug-in process info for the plugin, that is only valid for the time of
- // the notification (don't keep this pointer around, make a copy of the object
- // if you need to keep it).
- NOTIFY_PLUGIN_PROCESS_HOST_CONNECTED,
-
- // This message is sent after a PluginProcessHost is disconnected from the
- // plugin process. There is no usable source, since it is sent from an
- // ephemeral task; register for AllSources() to receive this notification.
- // The details are in a Details<PluginProcessInfo> with a pointer to
- // a plug-in process info for the plugin, that is only valid for the time of
- // the notification (don't keep this pointer around, make a copy of the object
- // if you need to keep it).
- NOTIFY_PLUGIN_PROCESS_HOST_DISCONNECTED,
-
- // This message is sent when a plugin process disappears unexpectedly.
- // There is no usable source, since it is sent from an
- // ephemeral task; register for AllSources() to receive this notification.
- // The details are in a Details<PluginProcessInfo> with a pointer to
- // a plug-in process info for the plugin, that is only valid for the time of
- // the notification (don't keep this pointer around, make a copy of the object
- // if you need to keep it).
- NOTIFY_PLUGIN_PROCESS_CRASHED,
-
- // This message indicates that an instance of a particular plugin was
- // created in a page. (If one page contains several regions rendered
- // by the same plugin, this notification will occur once for each region
- // during the page load.)
- // There is no usable source, since it is sent from an
- // ephemeral task; register for AllSources() to receive this notification.
- // The details are in a Details<PluginProcessInfo> with a pointer to
- // a plug-in process info for the plugin, that is only valid for the time of
- // the notification (don't keep this pointer around, make a copy of the object
- // if you need to keep it).
- NOTIFY_PLUGIN_INSTANCE_CREATED,
-
- // This is sent when network interception is disabled for a plugin, or the
- // plugin is unloaded. This should only be sent/received on the browser IO
- // thread or the plugin thread. The source is the plugin that is disabling
- // interception. No details are expected.
- NOTIFY_CHROME_PLUGIN_UNLOADED,
-
- // This is sent when a login prompt is shown. The source is the
- // Source<NavigationController> for the tab in which the prompt is shown.
- // Details are a LoginNotificationDetails which provide the LoginHandler
- // that should be given authentication.
- NOTIFY_AUTH_NEEDED,
-
- // This is sent when authentication credentials have been supplied (either
- // by the user or by an automation service), but before we've actually
- // received another response from the server. The source is the
- // Source<NavigationController> for the tab in which the prompt was shown.
- // No details are expected.
- NOTIFY_AUTH_SUPPLIED,
-
- // History -------------------------------------------------------------------
-
- // Sent when a history service is created on the main thread. This is sent
- // after history is created, but before it has finished loading. Use
- // NOTIFY_HISTORY_LOADED is you need to know when loading has completed. The
- // source is the profile that the history service belongs to, and the details
- // is the pointer to the newly created HistoryService object.
- NOTIFY_HISTORY_CREATED,
-
- // Sent when a history service has finished loading. The source is the profile
- // that the history service belongs to, and the details is the HistoryService.
- NOTIFY_HISTORY_LOADED,
-
- // Sent when a URL that has been typed has been added or modified. This is
- // used by the in-memory URL database (used by autocomplete) to track changes
- // to the main history system.
- //
- // The source is the profile owning the history service that changed, and
- // the details is history::URLsModifiedDetails that lists the modified or
- // added URLs.
- NOTIFY_HISTORY_TYPED_URLS_MODIFIED,
-
- // Sent when the user visits a URL.
- //
- // The source is the profile owning the history service that changed, and
- // the details is history::URLVisitedDetails.
- NOTIFY_HISTORY_URL_VISITED,
-
- // Sent when one or more URLs are deleted.
- //
- // The source is the profile owning the history service that changed, and
- // the details is history::URLsDeletedDetails that lists the deleted URLs.
- NOTIFY_HISTORY_URLS_DELETED,
-
- // Sent by history when the favicon of a URL changes.
- // The source is the profile, and the details is
- // history::FavIconChangeDetails (see history_notifications.h).
- NOTIFY_FAVICON_CHANGED,
-
- // Bookmarks -----------------------------------------------------------------
-
- // Sent when the starred state of a URL changes. A URL is starred if there is
- // at least one bookmark for it. The source is a Profile and the details is
- // history::URLsStarredDetails that contains the list of URLs and whether
- // they were starred or unstarred.
- NOTIFY_URLS_STARRED,
-
- // Sent when the bookmark bar model finishes loading. This source is the
- // Profile, and the details aren't used.
- NOTIFY_BOOKMARK_MODEL_LOADED,
-
- // Sent when the spellchecker object changes. Note that this is not sent the
- // first time the spellchecker gets initialized. The source is the profile,
- // the details is SpellcheckerReinitializedDetails defined in profile.
- NOTIFY_SPELLCHECKER_REINITIALIZED,
-
- // Sent when the bookmark bubble is shown for a particular URL. The source
- // is the profile, the details the URL.
- NOTIFY_BOOKMARK_BUBBLE_SHOWN,
-
- // Non-history storage services ----------------------------------------------
-
- // Notification that the TemplateURLModel has finished loading from the
- // database. The source is the TemplateURLModel, and the details are
- // NoDetails.
- TEMPLATE_URL_MODEL_LOADED,
-
- // Notification triggered when a web application has been installed or
- // uninstalled. Any application view should reload its data.
- // The source is the profile. No details are provided.
- NOTIFY_WEB_APP_INSTALL_CHANGED,
-
- // This is sent to a pref observer when a pref is changed.
- NOTIFY_PREF_CHANGED,
-
- // Sent when a default request context has been created, so calling
- // Profile::GetDefaultRequestContext() will not return NULL. This is sent on
- // the thread where Profile::GetRequestContext() is first called, which should
- // be the UI thread.
- NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE,
-
- // Autocomplete --------------------------------------------------------------
-
- // Sent by the autocomplete controller at least once per query, each time new
- // matches are available, subject to rate-limiting/coalescing to reduce the
- // number of updates. There are no details.
- NOTIFY_AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED,
-
- // Sent by the autocomplete controller once per query, immediately after
- // synchronous matches become available. There are no details.
- NOTIFY_AUTOCOMPLETE_CONTROLLER_SYNCHRONOUS_MATCHES_AVAILABLE,
-
- // This is sent when an item of the Omnibox popup is selected. The source is
- // the profile.
- NOTIFY_OMNIBOX_OPENED_URL,
-
- // Sent by the autocomplete edit when it is destroyed.
- NOTIFY_AUTOCOMPLETE_EDIT_DESTROYED,
-
- // Sent when the main Google URL has been updated. Some services cache this
- // value and need to update themselves when it changes. See
- // google_util::GetGoogleURLAndUpdateIfNecessary().
- NOTIFY_GOOGLE_URL_UPDATED,
-
- // Printing ------------------------------------------------------------------
-
- // Notification from a PrintedDocument that it has been updated. It may be
- // that a printed page has just been generated or that the document's number
- // of pages has been calculated. Details is the new page or NULL if only the
- // number of pages in the document has been updated.
- NOTIFY_PRINTED_DOCUMENT_UPDATED,
-
- // Notification from PrintJob that an event occured. It can be that a page
- // finished printing or that the print job failed. Details is
- // PrintJob::EventDetails.
- NOTIFY_PRINT_JOB_EVENT,
-
- // Shutdown ------------------------------------------------------------------
-
- // Sent on the browser IO thread when an URLRequestContext is released by its
- // owning Profile. The source is a pointer to the URLRequestContext.
- NOTIFY_URL_REQUEST_CONTEXT_RELEASED,
-
- // Sent when WM_ENDSESSION has been received, after the browsers have been
- // closed but before browser process has been shutdown. The source/details
- // are all source and no details.
- NOTIFY_SESSION_END,
-
- // Personalization -----------------------------------------------------------
- NOTIFY_PERSONALIZATION,
- NOTIFY_PERSONALIZATION_CREATED,
-
- // User Scripts --------------------------------------------------------------
-
- // Sent when there are new user scripts available.
- // The details are a pointer to SharedMemory containing the new scripts.
- NOTIFY_USER_SCRIPTS_LOADED,
-
- // Extensions ----------------------------------------------------------------
-
- // Sent when new extensions are loaded. The details are an ExtensionList*.
- NOTIFY_EXTENSIONS_LOADED,
-
- // Sent when new extensions are installed. The details are a FilePath.
- NOTIFY_EXTENSION_INSTALLED,
-
- // Count (must be last) ------------------------------------------------------
- // Used to determine the number of notification types. Not valid as
- // a type parameter when registering for or posting notifications.
- NOTIFICATION_TYPE_COUNT
-};
-
-#endif // CHROME_COMMON_NOTIFICATION_TYPES_H__
-
diff --git a/chrome/common/pref_member.cc b/chrome/common/pref_member.cc
index 9843b7e..8734775 100644
--- a/chrome/common/pref_member.cc
+++ b/chrome/common/pref_member.cc
@@ -5,6 +5,7 @@
#include "chrome/common/pref_member.h"
#include "base/logging.h"
+#include "chrome/common/notification_type.h"
#include "chrome/common/pref_service.h"
namespace subtle {
@@ -23,7 +24,7 @@ PrefMemberBase::~PrefMemberBase() {
void PrefMemberBase::Init(const wchar_t* pref_name, PrefService* prefs,
- NotificationObserver* observer) {
+ NotificationObserver* observer) {
DCHECK(pref_name);
DCHECK(prefs);
DCHECK(pref_name_.empty()); // Check that Init is only called once.
@@ -40,7 +41,7 @@ void PrefMemberBase::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK(!pref_name_.empty());
- DCHECK(NOTIFY_PREF_CHANGED == type);
+ DCHECK(NotificationType::PREF_CHANGED == type);
UpdateValueFromPref();
is_synced_ = true;
if (!setting_value_ && observer_)
diff --git a/chrome/common/pref_member.h b/chrome/common/pref_member.h
index 9b5c70f..65f861a 100644
--- a/chrome/common/pref_member.h
+++ b/chrome/common/pref_member.h
@@ -25,7 +25,8 @@
#include <string>
-#include "chrome/common/notification_service.h"
+#include "base/basictypes.h"
+#include "chrome/common/notification_observer.h"
class PrefService;
diff --git a/chrome/common/pref_member_unittest.cc b/chrome/common/pref_member_unittest.cc
index d016674..1b11948 100644
--- a/chrome/common/pref_member_unittest.cc
+++ b/chrome/common/pref_member_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/common/notification_service.h"
#include "chrome/common/pref_member.h"
#include "chrome/common/pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -29,7 +30,7 @@ class PrefMemberTestClass : public NotificationObserver {
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(NOTIFY_PREF_CHANGED == type);
+ DCHECK(NotificationType::PREF_CHANGED == type);
PrefService* prefs_in = Source<PrefService>(source).ptr();
EXPECT_EQ(prefs_in, prefs_);
std::wstring* pref_name_in = Details<std::wstring>(details).ptr();
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index 870e79e..e9daeba 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -623,7 +623,7 @@ void PrefService::FireObservers(const wchar_t* path) {
NotificationObserverList::Iterator it(*(observer_iterator->second));
NotificationObserver* observer;
while ((observer = it.GetNext()) != NULL) {
- observer->Observe(NOTIFY_PREF_CHANGED,
+ observer->Observe(NotificationType::PREF_CHANGED,
Source<PrefService>(this),
Details<std::wstring>(&path_str));
}
diff --git a/chrome/common/pref_service_unittest.cc b/chrome/common/pref_service_unittest.cc
index e35e44a..a798a84 100644
--- a/chrome/common/pref_service_unittest.cc
+++ b/chrome/common/pref_service_unittest.cc
@@ -7,7 +7,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/json_value_serializer.h"
#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_types.h"
+#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/test/data/resource.h"
@@ -56,7 +56,7 @@ class TestPrefObserver : public NotificationObserver {
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- EXPECT_EQ(type, NOTIFY_PREF_CHANGED);
+ EXPECT_EQ(type.value, NotificationType::PREF_CHANGED);
PrefService* prefs_in = Source<PrefService>(source).ptr();
EXPECT_EQ(prefs_in, prefs_);
std::wstring* pref_name_in = Details<std::wstring>(details).ptr();