| OLD | NEW |
| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 void BookmarksFunction::Observe(NotificationType type, | 111 void BookmarksFunction::Observe(NotificationType type, |
| 112 const NotificationSource& source, | 112 const NotificationSource& source, |
| 113 const NotificationDetails& details) { | 113 const NotificationDetails& details) { |
| 114 DCHECK(type == NotificationType::BOOKMARK_MODEL_LOADED); | 114 DCHECK(type == NotificationType::BOOKMARK_MODEL_LOADED); |
| 115 DCHECK(profile()->GetBookmarkModel()->IsLoaded()); | 115 DCHECK(profile()->GetBookmarkModel()->IsLoaded()); |
| 116 Run(); | 116 Run(); |
| 117 Release(); // Balanced in Run(). | 117 Release(); // Balanced in Run(). |
| 118 } | 118 } |
| 119 | 119 |
| 120 // static | 120 ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter() {} |
| 121 ExtensionBookmarkEventRouter* ExtensionBookmarkEventRouter::GetInstance() { | |
| 122 return Singleton<ExtensionBookmarkEventRouter>::get(); | |
| 123 } | |
| 124 | 121 |
| 125 ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter() { | 122 ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() {} |
| 126 } | |
| 127 | |
| 128 ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() { | |
| 129 } | |
| 130 | 123 |
| 131 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) { | 124 void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) { |
| 132 if (models_.find(model) == models_.end()) { | 125 model->AddObserver(this); |
| 133 model->AddObserver(this); | 126 model_ = model; |
| 134 models_.insert(model); | |
| 135 } | |
| 136 } | 127 } |
| 137 | 128 |
| 138 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile, | 129 void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile, |
| 139 const char* event_name, | 130 const char* event_name, |
| 140 const std::string& json_args) { | 131 const std::string& json_args) { |
| 141 if (profile->GetExtensionEventRouter()) { | 132 if (profile->GetExtensionEventRouter()) { |
| 142 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 133 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 143 event_name, json_args, NULL, GURL()); | 134 event_name, json_args, NULL, GURL()); |
| 144 } | 135 } |
| 145 } | 136 } |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); | 899 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); |
| 909 return true; | 900 return true; |
| 910 } | 901 } |
| 911 | 902 |
| 912 void ExportBookmarksFunction::FileSelected(const FilePath& path, | 903 void ExportBookmarksFunction::FileSelected(const FilePath& path, |
| 913 int index, | 904 int index, |
| 914 void* params) { | 905 void* params) { |
| 915 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 906 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
| 916 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 907 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
| 917 } | 908 } |
| OLD | NEW |