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

Side by Side Diff: chrome/browser/extensions/extension_bookmarks_module.cc

Issue 6961027: Change event routers from singletons to being owned by the ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asargent and dmazzoni's comments Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_bookmarks_module.h" 5 #include "chrome/browser/extensions/extension_bookmarks_module.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/i18n/file_util_icu.h" 8 #include "base/i18n/file_util_icu.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 void BookmarksFunction::Observe(NotificationType type, 111 void BookmarksFunction::Observe(NotificationType type,
112 const NotificationSource& source, 112 const NotificationSource& source,
113 const NotificationDetails& details) { 113 const NotificationDetails& details) {
114 DCHECK(type == NotificationType::BOOKMARK_MODEL_LOADED); 114 DCHECK(type == NotificationType::BOOKMARK_MODEL_LOADED);
115 DCHECK(profile()->GetBookmarkModel()->IsLoaded()); 115 DCHECK(profile()->GetBookmarkModel()->IsLoaded());
116 Run(); 116 Run();
117 Release(); // Balanced in Run(). 117 Release(); // Balanced in Run().
118 } 118 }
119 119
120 // static
121 ExtensionBookmarkEventRouter* ExtensionBookmarkEventRouter::GetInstance() {
122 return Singleton<ExtensionBookmarkEventRouter>::get();
123 }
124
125 ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter() {
126 }
127
128 ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() {
129 }
130
131 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) { 120 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) {
132 if (models_.find(model) == models_.end()) { 121 model->AddObserver(this);
133 model->AddObserver(this); 122 model_ = model;
134 models_.insert(model);
135 }
136 } 123 }
137 124
138 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile, 125 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile,
139 const char* event_name, 126 const char* event_name,
140 const std::string& json_args) { 127 const std::string& json_args) {
141 if (profile->GetExtensionEventRouter()) { 128 if (profile->GetExtensionEventRouter()) {
142 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 129 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
143 event_name, json_args, NULL, GURL()); 130 event_name, json_args, NULL, GURL());
144 } 131 }
145 } 132 }
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); 895 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE);
909 return true; 896 return true;
910 } 897 }
911 898
912 void ExportBookmarksFunction::FileSelected(const FilePath& path, 899 void ExportBookmarksFunction::FileSelected(const FilePath& path,
913 int index, 900 int index,
914 void* params) { 901 void* params) {
915 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 902 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
916 Release(); // Balanced in BookmarksIOFunction::SelectFile() 903 Release(); // Balanced in BookmarksIOFunction::SelectFile()
917 } 904 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698