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

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

Issue 412007: Add extensions BookmarkModel observer automatically when manifest has bookmarks permission. (Closed)
Patch Set: remove extraneous event_router->Observe Created 11 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extensions_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/bookmarks/bookmark_codec.h" 9 #include "chrome/browser/bookmarks/bookmark_codec.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 int index = parent->IndexOfChild(node); 93 int index = parent->IndexOfChild(node);
94 model->Remove(parent, index); 94 model->Remove(parent, index);
95 return true; 95 return true;
96 } 96 }
97 97
98 private: 98 private:
99 ExtensionBookmarks(); 99 ExtensionBookmarks();
100 }; 100 };
101 101
102 void BookmarksFunction::Run() { 102 void BookmarksFunction::Run() {
103 // TODO(erikkay) temporary hack until adding an event listener can notify the
104 // browser.
105 BookmarkModel* model = profile()->GetBookmarkModel(); 103 BookmarkModel* model = profile()->GetBookmarkModel();
106 if (!model->IsLoaded()) { 104 if (!model->IsLoaded()) {
107 // Bookmarks are not ready yet. We'll wait. 105 // Bookmarks are not ready yet. We'll wait.
108 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, 106 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED,
109 NotificationService::AllSources()); 107 NotificationService::AllSources());
110 AddRef(); // Balanced in Observe(). 108 AddRef(); // Balanced in Observe().
111 return; 109 return;
112 } 110 }
113 111
114 ExtensionBookmarkEventRouter* event_router =
115 ExtensionBookmarkEventRouter::GetSingleton();
116 event_router->Observe(model);
117 bool success = RunImpl(); 112 bool success = RunImpl();
118 if (success) { 113 if (success) {
119 NotificationService::current()->Notify( 114 NotificationService::current()->Notify(
120 NotificationType::EXTENSION_BOOKMARKS_API_INVOKED, 115 NotificationType::EXTENSION_BOOKMARKS_API_INVOKED,
121 Source<const Extension>(GetExtension()), 116 Source<const Extension>(GetExtension()),
122 Details<const BookmarksFunction>(this)); 117 Details<const BookmarksFunction>(this));
123 } 118 }
124 SendResponse(success); 119 SendResponse(success);
125 } 120 }
126 121
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 error_ = keys::kModifySpecialError; 545 error_ = keys::kModifySpecialError;
551 return false; 546 return false;
552 } 547 }
553 model->SetTitle(node, title); 548 model->SetTitle(node, title);
554 549
555 DictionaryValue* ret = ExtensionBookmarks::GetNodeDictionary(node, false); 550 DictionaryValue* ret = ExtensionBookmarks::GetNodeDictionary(node, false);
556 result_.reset(ret); 551 result_.reset(ret);
557 552
558 return true; 553 return true;
559 } 554 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extensions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698