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

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: more poor const_casts 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 (const ListValue* ids = arg0->AsList()) {
289 const ListValue* ids = static_cast<const ListValue*>(arg0);
290 size_t count = ids->GetSize(); 289 size_t count = ids->GetSize();
291 EXTENSION_FUNCTION_VALIDATE(count > 0); 290 EXTENSION_FUNCTION_VALIDATE(count > 0);
292 for (size_t i = 0; i < count; ++i) { 291 for (size_t i = 0; i < count; ++i) {
293 int64 id; 292 int64 id;
294 std::string id_string; 293 std::string id_string;
295 EXTENSION_FUNCTION_VALIDATE(ids->GetString(i, &id_string)); 294 EXTENSION_FUNCTION_VALIDATE(ids->GetString(i, &id_string));
296 if (!GetBookmarkIdAsInt64(id_string, &id)) 295 if (!GetBookmarkIdAsInt64(id_string, &id))
297 return false; 296 return false;
298 const BookmarkNode* node = model->GetNodeByID(id); 297 const BookmarkNode* node = model->GetNodeByID(id);
299 if (!node) { 298 if (!node) {
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); 931 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE);
933 return true; 932 return true;
934 } 933 }
935 934
936 void ExportBookmarksFunction::FileSelected(const FilePath& path, 935 void ExportBookmarksFunction::FileSelected(const FilePath& path,
937 int index, 936 int index,
938 void* params) { 937 void* params) {
939 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 938 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
940 Release(); // Balanced in BookmarksIOFunction::SelectFile() 939 Release(); // Balanced in BookmarksIOFunction::SelectFile()
941 } 940 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698