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

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

Issue 7243012: Change many extension event routers to not be singletons and to be more profile-aware. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 void BookmarksFunction::Observe(NotificationType type, 112 void BookmarksFunction::Observe(NotificationType type,
113 const NotificationSource& source, 113 const NotificationSource& source,
114 const NotificationDetails& details) { 114 const NotificationDetails& details) {
115 DCHECK(type == NotificationType::BOOKMARK_MODEL_LOADED); 115 DCHECK(type == NotificationType::BOOKMARK_MODEL_LOADED);
116 DCHECK(profile()->GetBookmarkModel()->IsLoaded()); 116 DCHECK(profile()->GetBookmarkModel()->IsLoaded());
117 Run(); 117 Run();
118 Release(); // Balanced in Run(). 118 Release(); // Balanced in Run().
119 } 119 }
120 120
121 // static
122 ExtensionBookmarkEventRouter* ExtensionBookmarkEventRouter::GetInstance() {
123 return Singleton<ExtensionBookmarkEventRouter>::get();
124 }
125
126 ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter() { 121 ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter() {
127 } 122 }
128 123
129 ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() { 124 ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() {
130 } 125 }
131 126
132 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) { 127 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) {
133 if (models_.find(model) == models_.end()) { 128 model->AddObserver(this);
asargent_no_longer_on_chrome 2011/06/23 22:18:38 Is there a matching call to RemoveObserver somewhe
Yoyo Zhou 2011/06/24 17:21:38 There wasn't before... we should probably have one
asargent_no_longer_on_chrome 2011/06/24 18:56:39 Looks like BookmarkModelObserver's get their Bookm
Yoyo Zhou 2011/06/24 22:10:33 We don't keep a pointer to the model anymore; I gu
134 model->AddObserver(this);
135 models_.insert(model);
136 }
137 } 129 }
138 130
139 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile, 131 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile,
140 const char* event_name, 132 const char* event_name,
141 const std::string& json_args) { 133 const std::string& json_args) {
142 if (profile->GetExtensionEventRouter()) { 134 if (profile->GetExtensionEventRouter()) {
143 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 135 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
144 event_name, json_args, NULL, GURL()); 136 event_name, json_args, NULL, GURL());
145 } 137 }
146 } 138 }
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); 917 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE);
926 return true; 918 return true;
927 } 919 }
928 920
929 void ExportBookmarksFunction::FileSelected(const FilePath& path, 921 void ExportBookmarksFunction::FileSelected(const FilePath& path,
930 int index, 922 int index,
931 void* params) { 923 void* params) {
932 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 924 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
933 Release(); // Balanced in BookmarksIOFunction::SelectFile() 925 Release(); // Balanced in BookmarksIOFunction::SelectFile()
934 } 926 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698