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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 DispatchEvent(model->profile(), | 278 DispatchEvent(model->profile(), |
279 keys::kOnBookmarkImportEnded, | 279 keys::kOnBookmarkImportEnded, |
280 json_args); | 280 json_args); |
281 } | 281 } |
282 | 282 |
283 bool GetBookmarksFunction::RunImpl() { | 283 bool GetBookmarksFunction::RunImpl() { |
284 BookmarkModel* model = profile()->GetBookmarkModel(); | 284 BookmarkModel* model = profile()->GetBookmarkModel(); |
285 scoped_ptr<ListValue> json(new ListValue()); | 285 scoped_ptr<ListValue> json(new ListValue()); |
286 Value* arg0; | 286 Value* arg0; |
287 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &arg0)); | 287 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &arg0)); |
288 if (const ListValue* ids = arg0->AsList()) { | 288 if (arg0->IsType(Value::TYPE_LIST)) { |
| 289 const ListValue* ids = static_cast<const ListValue*>(arg0); |
289 size_t count = ids->GetSize(); | 290 size_t count = ids->GetSize(); |
290 EXTENSION_FUNCTION_VALIDATE(count > 0); | 291 EXTENSION_FUNCTION_VALIDATE(count > 0); |
291 for (size_t i = 0; i < count; ++i) { | 292 for (size_t i = 0; i < count; ++i) { |
292 int64 id; | 293 int64 id; |
293 std::string id_string; | 294 std::string id_string; |
294 EXTENSION_FUNCTION_VALIDATE(ids->GetString(i, &id_string)); | 295 EXTENSION_FUNCTION_VALIDATE(ids->GetString(i, &id_string)); |
295 if (!GetBookmarkIdAsInt64(id_string, &id)) | 296 if (!GetBookmarkIdAsInt64(id_string, &id)) |
296 return false; | 297 return false; |
297 const BookmarkNode* node = model->GetNodeByID(id); | 298 const BookmarkNode* node = model->GetNodeByID(id); |
298 if (!node) { | 299 if (!node) { |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); | 932 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); |
932 return true; | 933 return true; |
933 } | 934 } |
934 | 935 |
935 void ExportBookmarksFunction::FileSelected(const FilePath& path, | 936 void ExportBookmarksFunction::FileSelected(const FilePath& path, |
936 int index, | 937 int index, |
937 void* params) { | 938 void* params) { |
938 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 939 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
939 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 940 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
940 } | 941 } |
OLD | NEW |