Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: chrome/browser/extensions/extension_bookmarks_module.cc

Issue 7714004: base: Add AsList() function to Value API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OVERRIDE Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 (arg0->IsType(Value::TYPE_LIST)) { 288 if (arg0->AsList()) {
289 const ListValue* ids = static_cast<const ListValue*>(arg0); 289 const ListValue* ids = static_cast<const ListValue*>(arg0);
290 size_t count = ids->GetSize(); 290 size_t count = ids->GetSize();
291 EXTENSION_FUNCTION_VALIDATE(count > 0); 291 EXTENSION_FUNCTION_VALIDATE(count > 0);
292 for (size_t i = 0; i < count; ++i) { 292 for (size_t i = 0; i < count; ++i) {
293 int64 id; 293 int64 id;
294 std::string id_string; 294 std::string id_string;
295 EXTENSION_FUNCTION_VALIDATE(ids->GetString(i, &id_string)); 295 EXTENSION_FUNCTION_VALIDATE(ids->GetString(i, &id_string));
296 if (!GetBookmarkIdAsInt64(id_string, &id)) 296 if (!GetBookmarkIdAsInt64(id_string, &id))
297 return false; 297 return false;
298 const BookmarkNode* node = model->GetNodeByID(id); 298 const BookmarkNode* node = model->GetNodeByID(id);
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); 932 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE);
933 return true; 933 return true;
934 } 934 }
935 935
936 void ExportBookmarksFunction::FileSelected(const FilePath& path, 936 void ExportBookmarksFunction::FileSelected(const FilePath& path,
937 int index, 937 int index,
938 void* params) { 938 void* params) {
939 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 939 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
940 Release(); // Balanced in BookmarksIOFunction::SelectFile() 940 Release(); // Balanced in BookmarksIOFunction::SelectFile()
941 } 941 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698