OLD | NEW |
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_writer.h" | 7 #include "base/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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) { | 147 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) { |
148 if (models_.find(model) == models_.end()) { | 148 if (models_.find(model) == models_.end()) { |
149 model->AddObserver(this); | 149 model->AddObserver(this); |
150 models_.insert(model); | 150 models_.insert(model); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile, | 154 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile, |
155 const char* event_name, | 155 const char* event_name, |
156 const std::string json_args) { | 156 const std::string json_args) { |
157 ExtensionMessageService::GetInstance(profile->GetRequestContext())-> | 157 if (profile->GetExtensionMessageService()) { |
158 DispatchEventToRenderers(event_name, json_args); | 158 profile->GetExtensionMessageService()-> |
| 159 DispatchEventToRenderers(event_name, json_args); |
| 160 } |
159 } | 161 } |
160 | 162 |
161 void ExtensionBookmarkEventRouter::Loaded(BookmarkModel* model) { | 163 void ExtensionBookmarkEventRouter::Loaded(BookmarkModel* model) { |
162 // TODO(erikkay): Perhaps we should send this event down to the extension | 164 // TODO(erikkay): Perhaps we should send this event down to the extension |
163 // so they know when it's safe to use the API? | 165 // so they know when it's safe to use the API? |
164 } | 166 } |
165 | 167 |
166 void ExtensionBookmarkEventRouter::BookmarkNodeMoved( | 168 void ExtensionBookmarkEventRouter::BookmarkNodeMoved( |
167 BookmarkModel* model, | 169 BookmarkModel* model, |
168 const BookmarkNode* old_parent, | 170 const BookmarkNode* old_parent, |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 } | 528 } |
527 if (node == model->root_node() || | 529 if (node == model->root_node() || |
528 node == model->other_node() || | 530 node == model->other_node() || |
529 node == model->GetBookmarkBarNode()) { | 531 node == model->GetBookmarkBarNode()) { |
530 error_ = keys::kModifySpecialError; | 532 error_ = keys::kModifySpecialError; |
531 return false; | 533 return false; |
532 } | 534 } |
533 model->SetTitle(node, title); | 535 model->SetTitle(node, title); |
534 return true; | 536 return true; |
535 } | 537 } |
OLD | NEW |