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

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

Issue 7558003: Profiles: Bookmark notifications should listen to only a specific profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return default_path.Append(filename); 72 return default_path.Append(filename);
73 } 73 }
74 74
75 } // namespace 75 } // namespace
76 76
77 void BookmarksFunction::Run() { 77 void BookmarksFunction::Run() {
78 BookmarkModel* model = profile()->GetBookmarkModel(); 78 BookmarkModel* model = profile()->GetBookmarkModel();
79 if (!model->IsLoaded()) { 79 if (!model->IsLoaded()) {
80 // Bookmarks are not ready yet. We'll wait. 80 // Bookmarks are not ready yet. We'll wait.
81 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, 81 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
82 NotificationService::AllSources()); 82 Source<Profile>(profile()));
83 AddRef(); // Balanced in Observe(). 83 AddRef(); // Balanced in Observe().
84 return; 84 return;
85 } 85 }
86 86
87 bool success = RunImpl(); 87 bool success = RunImpl();
88 if (success) { 88 if (success) {
89 NotificationService::current()->Notify( 89 NotificationService::current()->Notify(
90 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, 90 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED,
91 Source<const Extension>(GetExtension()), 91 Source<const Extension>(GetExtension()),
92 Details<const BookmarksFunction>(this)); 92 Details<const BookmarksFunction>(this));
(...skipping 13 matching lines...) Expand all
106 bool BookmarksFunction::EditBookmarksEnabled() { 106 bool BookmarksFunction::EditBookmarksEnabled() {
107 if (profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled)) 107 if (profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled))
108 return true; 108 return true;
109 error_ = keys::kEditBookmarksDisabled; 109 error_ = keys::kEditBookmarksDisabled;
110 return false; 110 return false;
111 } 111 }
112 112
113 void BookmarksFunction::Observe(int type, 113 void BookmarksFunction::Observe(int type,
114 const NotificationSource& source, 114 const NotificationSource& source,
115 const NotificationDetails& details) { 115 const NotificationDetails& details) {
116 DCHECK(type == chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED); 116 DCHECK_EQ(type, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED);
Peter Kasting 2011/08/08 18:47:37 Nit: (expected, actual) (2 places)
117 DCHECK_EQ(Source<Profile>(source).ptr(), profile());
117 DCHECK(profile()->GetBookmarkModel()->IsLoaded()); 118 DCHECK(profile()->GetBookmarkModel()->IsLoaded());
118 Run(); 119 Run();
119 Release(); // Balanced in Run(). 120 Release(); // Balanced in Run().
120 } 121 }
121 122
122 ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter( 123 ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter(
123 BookmarkModel* model) : model_(model) { 124 BookmarkModel* model) : model_(model) {
124 } 125 }
125 126
126 ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() { 127 ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() {
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); 929 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE);
929 return true; 930 return true;
930 } 931 }
931 932
932 void ExportBookmarksFunction::FileSelected(const FilePath& path, 933 void ExportBookmarksFunction::FileSelected(const FilePath& path,
933 int index, 934 int index,
934 void* params) { 935 void* params) {
935 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 936 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
936 Release(); // Balanced in BookmarksIOFunction::SelectFile() 937 Release(); // Balanced in BookmarksIOFunction::SelectFile()
937 } 938 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_service.cc » ('j') | chrome/browser/ui/bookmarks/bookmark_tab_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698