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

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmarks_api.cc

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/bookmarks/bookmarks_api.h" 5 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 303 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
304 } 304 }
305 305
306 bool BookmarksGetTreeFunction::RunImpl() { 306 bool BookmarksGetTreeFunction::RunImpl() {
307 scoped_ptr<bookmarks::Get::Params> params( 307 scoped_ptr<bookmarks::Get::Params> params(
308 bookmarks::Get::Params::Create(*args_)); 308 bookmarks::Get::Params::Create(*args_));
309 EXTENSION_FUNCTION_VALIDATE(params.get()); 309 EXTENSION_FUNCTION_VALIDATE(params.get());
310 310
311 std::vector<linked_ptr<BookmarkTreeNode> > nodes; 311 std::vector<linked_ptr<BookmarkTreeNode> > nodes;
312 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); 312 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
313 if (params->id_or_id_list_type == 313 if (params->id_or_id_list.as_array) {
314 bookmarks::Get::Params::ID_OR_ID_LIST_ARRAY) { 314 std::vector<std::string>* ids = params->id_or_id_list.as_array.get();
315 std::vector<std::string>* ids = params->id_or_id_list_array.get();
316 size_t count = ids->size(); 315 size_t count = ids->size();
317 EXTENSION_FUNCTION_VALIDATE(count > 0); 316 EXTENSION_FUNCTION_VALIDATE(count > 0);
318 for (size_t i = 0; i < count; ++i) { 317 for (size_t i = 0; i < count; ++i) {
319 int64 id; 318 int64 id;
320 if (!GetBookmarkIdAsInt64(ids->at(i), &id)) 319 if (!GetBookmarkIdAsInt64(ids->at(i), &id))
321 return false; 320 return false;
322 const BookmarkNode* node = model->GetNodeByID(id); 321 const BookmarkNode* node = model->GetNodeByID(id);
323 if (!node) { 322 if (!node) {
324 error_ = keys::kNoNodeError; 323 error_ = keys::kNoNodeError;
325 return false; 324 return false;
326 } else { 325 } else {
327 bookmark_api_helpers::AddNode(node, &nodes, false); 326 bookmark_api_helpers::AddNode(node, &nodes, false);
328 } 327 }
329 } 328 }
330 } else { 329 } else {
331 int64 id; 330 int64 id;
332 if (!GetBookmarkIdAsInt64(*params->id_or_id_list_string, &id)) 331 if (!GetBookmarkIdAsInt64(*params->id_or_id_list.as_string, &id))
333 return false; 332 return false;
334 const BookmarkNode* node = model->GetNodeByID(id); 333 const BookmarkNode* node = model->GetNodeByID(id);
335 if (!node) { 334 if (!node) {
336 error_ = keys::kNoNodeError; 335 error_ = keys::kNoNodeError;
337 return false; 336 return false;
338 } 337 }
339 bookmark_api_helpers::AddNode(node, &nodes, false); 338 bookmark_api_helpers::AddNode(node, &nodes, false);
340 } 339 }
341 340
342 results_ = bookmarks::Get::Results::Create(nodes); 341 results_ = bookmarks::Get::Results::Create(nodes);
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 #if !defined(OS_ANDROID) 986 #if !defined(OS_ANDROID)
988 // Android does not have support for the standard exporter. 987 // Android does not have support for the standard exporter.
989 // TODO(jgreenwald): remove ifdef once extensions are no longer built on 988 // TODO(jgreenwald): remove ifdef once extensions are no longer built on
990 // Android. 989 // Android.
991 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 990 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
992 #endif 991 #endif
993 Release(); // Balanced in BookmarksIOFunction::SelectFile() 992 Release(); // Balanced in BookmarksIOFunction::SelectFile()
994 } 993 }
995 994
996 } // namespace extensions 995 } // namespace extensions
OLDNEW
« no previous file with comments | « build/json_schema_compile.gypi ('k') | chrome/browser/extensions/api/content_settings/content_settings_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698