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/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 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 27 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
28 #include "chrome/browser/extensions/extensions_quota_service.h" | 28 #include "chrome/browser/extensions/extensions_quota_service.h" |
29 #include "chrome/browser/importer/importer_data_types.h" | 29 #include "chrome/browser/importer/importer_data_types.h" |
30 #include "chrome/browser/importer/importer_host.h" | 30 #include "chrome/browser/importer/importer_host.h" |
31 #include "chrome/browser/prefs/pref_service.h" | 31 #include "chrome/browser/prefs/pref_service.h" |
32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
34 #include "chrome/common/chrome_notification_types.h" | 34 #include "chrome/common/chrome_notification_types.h" |
35 #include "chrome/common/chrome_paths.h" | 35 #include "chrome/common/chrome_paths.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "content/common/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
38 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
40 | 40 |
41 namespace keys = extension_bookmarks_module_constants; | 41 namespace keys = extension_bookmarks_module_constants; |
42 | 42 |
43 using base::TimeDelta; | 43 using base::TimeDelta; |
44 typedef QuotaLimitHeuristic::Bucket Bucket; | 44 typedef QuotaLimitHeuristic::Bucket Bucket; |
45 typedef QuotaLimitHeuristic::Config Config; | 45 typedef QuotaLimitHeuristic::Config Config; |
46 typedef QuotaLimitHeuristic::BucketList BucketList; | 46 typedef QuotaLimitHeuristic::BucketList BucketList; |
47 typedef ExtensionsQuotaService::TimedLimit TimedLimit; | 47 typedef ExtensionsQuotaService::TimedLimit TimedLimit; |
(...skipping 24 matching lines...) Expand all Loading... |
72 PathService::Get(chrome::DIR_USER_DOCUMENTS, &default_path); | 72 PathService::Get(chrome::DIR_USER_DOCUMENTS, &default_path); |
73 return default_path.Append(filename); | 73 return default_path.Append(filename); |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 void BookmarksFunction::Run() { | 78 void BookmarksFunction::Run() { |
79 BookmarkModel* model = profile()->GetBookmarkModel(); | 79 BookmarkModel* model = profile()->GetBookmarkModel(); |
80 if (!model->IsLoaded()) { | 80 if (!model->IsLoaded()) { |
81 // Bookmarks are not ready yet. We'll wait. | 81 // Bookmarks are not ready yet. We'll wait. |
82 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, | 82 registrar_.Add( |
83 NotificationService::AllBrowserContextsAndSources()); | 83 this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, |
| 84 content::NotificationService::AllBrowserContextsAndSources()); |
84 AddRef(); // Balanced in Observe(). | 85 AddRef(); // Balanced in Observe(). |
85 return; | 86 return; |
86 } | 87 } |
87 | 88 |
88 bool success = RunImpl(); | 89 bool success = RunImpl(); |
89 if (success) { | 90 if (success) { |
90 NotificationService::current()->Notify( | 91 content::NotificationService::current()->Notify( |
91 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, | 92 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, |
92 content::Source<const Extension>(GetExtension()), | 93 content::Source<const Extension>(GetExtension()), |
93 content::Details<const BookmarksFunction>(this)); | 94 content::Details<const BookmarksFunction>(this)); |
94 } | 95 } |
95 SendResponse(success); | 96 SendResponse(success); |
96 } | 97 } |
97 | 98 |
98 bool BookmarksFunction::GetBookmarkIdAsInt64( | 99 bool BookmarksFunction::GetBookmarkIdAsInt64( |
99 const std::string& id_string, int64* id) { | 100 const std::string& id_string, int64* id) { |
100 if (base::StringToInt64(id_string, id)) | 101 if (base::StringToInt64(id_string, id)) |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); | 934 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); |
934 return true; | 935 return true; |
935 } | 936 } |
936 | 937 |
937 void ExportBookmarksFunction::FileSelected(const FilePath& path, | 938 void ExportBookmarksFunction::FileSelected(const FilePath& path, |
938 int index, | 939 int index, |
939 void* params) { | 940 void* params) { |
940 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 941 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
941 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 942 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
942 } | 943 } |
OLD | NEW |