OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bookmarks/bookmark_extension_api.h" | 5 #include "chrome/browser/bookmarks/bookmark_extension_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "chrome/browser/bookmarks/bookmark_codec.h" | 22 #include "chrome/browser/bookmarks/bookmark_codec.h" |
23 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" | 23 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" |
24 #include "chrome/browser/bookmarks/bookmark_extension_helpers.h" | 24 #include "chrome/browser/bookmarks/bookmark_extension_helpers.h" |
25 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 25 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
26 #include "chrome/browser/bookmarks/bookmark_model.h" | 26 #include "chrome/browser/bookmarks/bookmark_model.h" |
27 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 27 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
28 #include "chrome/browser/bookmarks/bookmark_utils.h" | 28 #include "chrome/browser/bookmarks/bookmark_utils.h" |
29 #include "chrome/browser/extensions/event_router.h" | 29 #include "chrome/browser/extensions/event_router.h" |
30 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 30 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 31 #include "chrome/browser/extensions/extension_system.h" |
31 #include "chrome/browser/extensions/extensions_quota_service.h" | 32 #include "chrome/browser/extensions/extensions_quota_service.h" |
32 #include "chrome/browser/importer/importer_data_types.h" | 33 #include "chrome/browser/importer/importer_data_types.h" |
33 #include "chrome/browser/importer/importer_host.h" | 34 #include "chrome/browser/importer/importer_host.h" |
34 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
35 #include "chrome/browser/ui/chrome_select_file_policy.h" | 36 #include "chrome/browser/ui/chrome_select_file_policy.h" |
36 #include "chrome/common/chrome_notification_types.h" | 37 #include "chrome/common/chrome_notification_types.h" |
37 #include "chrome/common/chrome_paths.h" | 38 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/extensions/api/bookmarks.h" | 39 #include "chrome/common/extensions/api/bookmarks.h" |
39 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
40 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 146 } |
146 | 147 |
147 void BookmarkExtensionEventRouter::Init() { | 148 void BookmarkExtensionEventRouter::Init() { |
148 model_->AddObserver(this); | 149 model_->AddObserver(this); |
149 } | 150 } |
150 | 151 |
151 void BookmarkExtensionEventRouter::DispatchEvent( | 152 void BookmarkExtensionEventRouter::DispatchEvent( |
152 Profile* profile, | 153 Profile* profile, |
153 const char* event_name, | 154 const char* event_name, |
154 scoped_ptr<ListValue> event_args) { | 155 scoped_ptr<ListValue> event_args) { |
155 if (profile->GetExtensionEventRouter()) { | 156 if (extensions::ExtensionSystem::Get(profile)->event_router()) { |
156 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 157 extensions::ExtensionSystem::Get(profile)->event_router()-> |
157 event_name, event_args.Pass(), NULL, GURL(), | 158 DispatchEventToRenderers(event_name, event_args.Pass(), NULL, GURL(), |
158 extensions::EventFilteringInfo()); | 159 extensions::EventFilteringInfo()); |
159 } | 160 } |
160 } | 161 } |
161 | 162 |
162 void BookmarkExtensionEventRouter::Loaded(BookmarkModel* model, | 163 void BookmarkExtensionEventRouter::Loaded(BookmarkModel* model, |
163 bool ids_reassigned) { | 164 bool ids_reassigned) { |
164 // TODO(erikkay): Perhaps we should send this event down to the extension | 165 // TODO(erikkay): Perhaps we should send this event down to the extension |
165 // so they know when it's safe to use the API? | 166 // so they know when it's safe to use the API? |
166 } | 167 } |
167 | 168 |
168 void BookmarkExtensionEventRouter::BookmarkModelBeingDeleted( | 169 void BookmarkExtensionEventRouter::BookmarkModelBeingDeleted( |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 int index, | 959 int index, |
959 void* params) { | 960 void* params) { |
960 #if !defined(OS_ANDROID) | 961 #if !defined(OS_ANDROID) |
961 // Android does not have support for the standard exporter. | 962 // Android does not have support for the standard exporter. |
962 // TODO(jgreenwald): remove ifdef once extensions are no longer built on | 963 // TODO(jgreenwald): remove ifdef once extensions are no longer built on |
963 // Android. | 964 // Android. |
964 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 965 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
965 #endif | 966 #endif |
966 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 967 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
967 } | 968 } |
OLD | NEW |