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

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

Issue 1203713002: Limit access to ChromeBookmarkClient to bookmarks code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_bookmark_client
Patch Set: Rebase Created 5 years, 6 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
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/files/file_path.h" 8 #include "base/files/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"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/sha1.h" 15 #include "base/sha1.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "chrome/browser/bookmarks/bookmark_html_writer.h" 22 #include "chrome/browser/bookmarks/bookmark_html_writer.h"
23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
24 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
25 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
26 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h" 24 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h"
27 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h" 25 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h"
28 #include "chrome/browser/importer/external_process_importer_host.h" 26 #include "chrome/browser/importer/external_process_importer_host.h"
29 #include "chrome/browser/importer/importer_uma.h" 27 #include "chrome/browser/importer/importer_uma.h"
30 #include "chrome/browser/platform_util.h" 28 #include "chrome/browser/platform_util.h"
31 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/ui/chrome_select_file_policy.h" 30 #include "chrome/browser/ui/chrome_select_file_policy.h"
33 #include "chrome/browser/ui/host_desktop.h" 31 #include "chrome/browser/ui/host_desktop.h"
34 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
35 #include "chrome/common/extensions/api/bookmarks.h" 33 #include "chrome/common/extensions/api/bookmarks.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 100 }
103 101
104 RunAndSendResponse(); 102 RunAndSendResponse();
105 return true; 103 return true;
106 } 104 }
107 105
108 BookmarkModel* BookmarksFunction::GetBookmarkModel() { 106 BookmarkModel* BookmarksFunction::GetBookmarkModel() {
109 return BookmarkModelFactory::GetForProfile(GetProfile()); 107 return BookmarkModelFactory::GetForProfile(GetProfile());
110 } 108 }
111 109
112 ChromeBookmarkClient* BookmarksFunction::GetChromeBookmarkClient() {
113 return ChromeBookmarkClientFactory::GetForProfile(GetProfile());
114 }
115
116 bool BookmarksFunction::GetBookmarkIdAsInt64(const std::string& id_string, 110 bool BookmarksFunction::GetBookmarkIdAsInt64(const std::string& id_string,
117 int64* id) { 111 int64* id) {
118 if (base::StringToInt64(id_string, id)) 112 if (base::StringToInt64(id_string, id))
119 return true; 113 return true;
120 114
121 error_ = keys::kInvalidIdError; 115 error_ = keys::kInvalidIdError;
122 return false; 116 return false;
123 } 117 }
124 118
125 const BookmarkNode* BookmarksFunction::GetBookmarkNodeFromId( 119 const BookmarkNode* BookmarksFunction::GetBookmarkNodeFromId(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 197
204 bool BookmarksFunction::CanBeModified(const BookmarkNode* node) { 198 bool BookmarksFunction::CanBeModified(const BookmarkNode* node) {
205 if (!node) { 199 if (!node) {
206 error_ = keys::kNoParentError; 200 error_ = keys::kNoParentError;
207 return false; 201 return false;
208 } 202 }
209 if (node->is_root()) { 203 if (node->is_root()) {
210 error_ = keys::kModifySpecialError; 204 error_ = keys::kModifySpecialError;
211 return false; 205 return false;
212 } 206 }
213 ChromeBookmarkClient* client = GetChromeBookmarkClient(); 207 BookmarkModel* model = GetBookmarkModel();
214 if (::bookmarks::IsDescendantOf(node, client->managed_node()) || 208 if (::bookmarks::IsDescendantOf(node, model->managed_node()) ||
215 ::bookmarks::IsDescendantOf(node, client->supervised_node())) { 209 ::bookmarks::IsDescendantOf(node, model->supervised_node())) {
216 error_ = keys::kModifyManagedError; 210 error_ = keys::kModifyManagedError;
217 return false; 211 return false;
218 } 212 }
219 return true; 213 return true;
220 } 214 }
221 215
222 void BookmarksFunction::BookmarkModelChanged() { 216 void BookmarksFunction::BookmarkModelChanged() {
223 } 217 }
224 218
225 void BookmarksFunction::BookmarkModelLoaded(BookmarkModel* model, 219 void BookmarksFunction::BookmarkModelLoaded(BookmarkModel* model,
226 bool ids_reassigned) { 220 bool ids_reassigned) {
227 model->RemoveObserver(this); 221 model->RemoveObserver(this);
228 RunAndSendResponse(); 222 RunAndSendResponse();
229 Release(); // Balanced in RunOnReady(). 223 Release(); // Balanced in RunOnReady().
230 } 224 }
231 225
232 void BookmarksFunction::RunAndSendResponse() { 226 void BookmarksFunction::RunAndSendResponse() {
233 bool success = RunOnReady(); 227 bool success = RunOnReady();
234 if (success) { 228 if (success) {
235 content::NotificationService::current()->Notify( 229 content::NotificationService::current()->Notify(
236 extensions::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, 230 extensions::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED,
237 content::Source<const Extension>(extension()), 231 content::Source<const Extension>(extension()),
238 content::Details<const BookmarksFunction>(this)); 232 content::Details<const BookmarksFunction>(this));
239 } 233 }
240 SendResponse(success); 234 SendResponse(success);
241 } 235 }
242 236
243 BookmarkEventRouter::BookmarkEventRouter(Profile* profile) 237 BookmarkEventRouter::BookmarkEventRouter(Profile* profile)
244 : browser_context_(profile), 238 : browser_context_(profile),
245 model_(BookmarkModelFactory::GetForProfile(profile)), 239 model_(BookmarkModelFactory::GetForProfile(profile)) {
246 client_(ChromeBookmarkClientFactory::GetForProfile(profile)) {
247 model_->AddObserver(this); 240 model_->AddObserver(this);
248 } 241 }
249 242
250 BookmarkEventRouter::~BookmarkEventRouter() { 243 BookmarkEventRouter::~BookmarkEventRouter() {
251 if (model_) { 244 if (model_) {
252 model_->RemoveObserver(this); 245 model_->RemoveObserver(this);
253 } 246 }
254 } 247 }
255 248
256 void BookmarkEventRouter::DispatchEvent( 249 void BookmarkEventRouter::DispatchEvent(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 DispatchEvent( 281 DispatchEvent(
289 bookmarks::OnMoved::kEventName, 282 bookmarks::OnMoved::kEventName,
290 bookmarks::OnMoved::Create(base::Int64ToString(node->id()), move_info)); 283 bookmarks::OnMoved::Create(base::Int64ToString(node->id()), move_info));
291 } 284 }
292 285
293 void BookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model, 286 void BookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model,
294 const BookmarkNode* parent, 287 const BookmarkNode* parent,
295 int index) { 288 int index) {
296 const BookmarkNode* node = parent->GetChild(index); 289 const BookmarkNode* node = parent->GetChild(index);
297 scoped_ptr<BookmarkTreeNode> tree_node( 290 scoped_ptr<BookmarkTreeNode> tree_node(
298 bookmark_api_helpers::GetBookmarkTreeNode(client_, node, false, false)); 291 bookmark_api_helpers::GetBookmarkTreeNode(model_, node, false, false));
299 DispatchEvent(bookmarks::OnCreated::kEventName, 292 DispatchEvent(bookmarks::OnCreated::kEventName,
300 bookmarks::OnCreated::Create(base::Int64ToString(node->id()), 293 bookmarks::OnCreated::Create(base::Int64ToString(node->id()),
301 *tree_node)); 294 *tree_node));
302 } 295 }
303 296
304 void BookmarkEventRouter::BookmarkNodeRemoved( 297 void BookmarkEventRouter::BookmarkNodeRemoved(
305 BookmarkModel* model, 298 BookmarkModel* model,
306 const BookmarkNode* parent, 299 const BookmarkNode* parent,
307 int index, 300 int index,
308 const BookmarkNode* node, 301 const BookmarkNode* node,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 new BookmarkEventRouter(Profile::FromBrowserContext(browser_context_))); 400 new BookmarkEventRouter(Profile::FromBrowserContext(browser_context_)));
408 EventRouter::Get(browser_context_)->UnregisterObserver(this); 401 EventRouter::Get(browser_context_)->UnregisterObserver(this);
409 } 402 }
410 403
411 bool BookmarksGetFunction::RunOnReady() { 404 bool BookmarksGetFunction::RunOnReady() {
412 scoped_ptr<bookmarks::Get::Params> params( 405 scoped_ptr<bookmarks::Get::Params> params(
413 bookmarks::Get::Params::Create(*args_)); 406 bookmarks::Get::Params::Create(*args_));
414 EXTENSION_FUNCTION_VALIDATE(params.get()); 407 EXTENSION_FUNCTION_VALIDATE(params.get());
415 408
416 std::vector<linked_ptr<BookmarkTreeNode> > nodes; 409 std::vector<linked_ptr<BookmarkTreeNode> > nodes;
417 ChromeBookmarkClient* client = GetChromeBookmarkClient(); 410 BookmarkModel* model = GetBookmarkModel();
418 if (params->id_or_id_list.as_strings) { 411 if (params->id_or_id_list.as_strings) {
419 std::vector<std::string>& ids = *params->id_or_id_list.as_strings; 412 std::vector<std::string>& ids = *params->id_or_id_list.as_strings;
420 size_t count = ids.size(); 413 size_t count = ids.size();
421 EXTENSION_FUNCTION_VALIDATE(count > 0); 414 EXTENSION_FUNCTION_VALIDATE(count > 0);
422 for (size_t i = 0; i < count; ++i) { 415 for (size_t i = 0; i < count; ++i) {
423 const BookmarkNode* node = GetBookmarkNodeFromId(ids[i]); 416 const BookmarkNode* node = GetBookmarkNodeFromId(ids[i]);
424 if (!node) 417 if (!node)
425 return false; 418 return false;
426 bookmark_api_helpers::AddNode(client, node, &nodes, false); 419 bookmark_api_helpers::AddNode(model, node, &nodes, false);
427 } 420 }
428 } else { 421 } else {
429 const BookmarkNode* node = 422 const BookmarkNode* node =
430 GetBookmarkNodeFromId(*params->id_or_id_list.as_string); 423 GetBookmarkNodeFromId(*params->id_or_id_list.as_string);
431 if (!node) 424 if (!node)
432 return false; 425 return false;
433 bookmark_api_helpers::AddNode(client, node, &nodes, false); 426 bookmark_api_helpers::AddNode(model, node, &nodes, false);
434 } 427 }
435 428
436 results_ = bookmarks::Get::Results::Create(nodes); 429 results_ = bookmarks::Get::Results::Create(nodes);
437 return true; 430 return true;
438 } 431 }
439 432
440 bool BookmarksGetChildrenFunction::RunOnReady() { 433 bool BookmarksGetChildrenFunction::RunOnReady() {
441 scoped_ptr<bookmarks::GetChildren::Params> params( 434 scoped_ptr<bookmarks::GetChildren::Params> params(
442 bookmarks::GetChildren::Params::Create(*args_)); 435 bookmarks::GetChildren::Params::Create(*args_));
443 EXTENSION_FUNCTION_VALIDATE(params.get()); 436 EXTENSION_FUNCTION_VALIDATE(params.get());
444 437
445 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); 438 const BookmarkNode* node = GetBookmarkNodeFromId(params->id);
446 if (!node) 439 if (!node)
447 return false; 440 return false;
448 441
449 std::vector<linked_ptr<BookmarkTreeNode> > nodes; 442 std::vector<linked_ptr<BookmarkTreeNode> > nodes;
450 int child_count = node->child_count(); 443 int child_count = node->child_count();
451 for (int i = 0; i < child_count; ++i) { 444 for (int i = 0; i < child_count; ++i) {
452 const BookmarkNode* child = node->GetChild(i); 445 const BookmarkNode* child = node->GetChild(i);
453 bookmark_api_helpers::AddNode( 446 bookmark_api_helpers::AddNode(GetBookmarkModel(), child, &nodes, false);
454 GetChromeBookmarkClient(), child, &nodes, false);
455 } 447 }
456 448
457 results_ = bookmarks::GetChildren::Results::Create(nodes); 449 results_ = bookmarks::GetChildren::Results::Create(nodes);
458 return true; 450 return true;
459 } 451 }
460 452
461 bool BookmarksGetRecentFunction::RunOnReady() { 453 bool BookmarksGetRecentFunction::RunOnReady() {
462 scoped_ptr<bookmarks::GetRecent::Params> params( 454 scoped_ptr<bookmarks::GetRecent::Params> params(
463 bookmarks::GetRecent::Params::Create(*args_)); 455 bookmarks::GetRecent::Params::Create(*args_));
464 EXTENSION_FUNCTION_VALIDATE(params.get()); 456 EXTENSION_FUNCTION_VALIDATE(params.get());
465 if (params->number_of_items < 1) 457 if (params->number_of_items < 1)
466 return false; 458 return false;
467 459
468 std::vector<const BookmarkNode*> nodes; 460 std::vector<const BookmarkNode*> nodes;
469 ::bookmarks::GetMostRecentlyAddedEntries( 461 ::bookmarks::GetMostRecentlyAddedEntries(
470 BookmarkModelFactory::GetForProfile(GetProfile()), 462 BookmarkModelFactory::GetForProfile(GetProfile()),
471 params->number_of_items, 463 params->number_of_items,
472 &nodes); 464 &nodes);
473 465
474 std::vector<linked_ptr<BookmarkTreeNode> > tree_nodes; 466 std::vector<linked_ptr<BookmarkTreeNode> > tree_nodes;
475 std::vector<const BookmarkNode*>::iterator i = nodes.begin(); 467 std::vector<const BookmarkNode*>::iterator i = nodes.begin();
476 for (; i != nodes.end(); ++i) { 468 for (; i != nodes.end(); ++i) {
477 const BookmarkNode* node = *i; 469 const BookmarkNode* node = *i;
478 bookmark_api_helpers::AddNode( 470 bookmark_api_helpers::AddNode(GetBookmarkModel(), node, &tree_nodes, false);
479 GetChromeBookmarkClient(), node, &tree_nodes, false);
480 } 471 }
481 472
482 results_ = bookmarks::GetRecent::Results::Create(tree_nodes); 473 results_ = bookmarks::GetRecent::Results::Create(tree_nodes);
483 return true; 474 return true;
484 } 475 }
485 476
486 bool BookmarksGetTreeFunction::RunOnReady() { 477 bool BookmarksGetTreeFunction::RunOnReady() {
487 std::vector<linked_ptr<BookmarkTreeNode> > nodes; 478 std::vector<linked_ptr<BookmarkTreeNode> > nodes;
488 const BookmarkNode* node = 479 const BookmarkNode* node =
489 BookmarkModelFactory::GetForProfile(GetProfile())->root_node(); 480 BookmarkModelFactory::GetForProfile(GetProfile())->root_node();
490 bookmark_api_helpers::AddNode(GetChromeBookmarkClient(), node, &nodes, true); 481 bookmark_api_helpers::AddNode(GetBookmarkModel(), node, &nodes, true);
491 results_ = bookmarks::GetTree::Results::Create(nodes); 482 results_ = bookmarks::GetTree::Results::Create(nodes);
492 return true; 483 return true;
493 } 484 }
494 485
495 bool BookmarksGetSubTreeFunction::RunOnReady() { 486 bool BookmarksGetSubTreeFunction::RunOnReady() {
496 scoped_ptr<bookmarks::GetSubTree::Params> params( 487 scoped_ptr<bookmarks::GetSubTree::Params> params(
497 bookmarks::GetSubTree::Params::Create(*args_)); 488 bookmarks::GetSubTree::Params::Create(*args_));
498 EXTENSION_FUNCTION_VALIDATE(params.get()); 489 EXTENSION_FUNCTION_VALIDATE(params.get());
499 490
500 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); 491 const BookmarkNode* node = GetBookmarkNodeFromId(params->id);
501 if (!node) 492 if (!node)
502 return false; 493 return false;
503 494
504 std::vector<linked_ptr<BookmarkTreeNode> > nodes; 495 std::vector<linked_ptr<BookmarkTreeNode> > nodes;
505 bookmark_api_helpers::AddNode(GetChromeBookmarkClient(), node, &nodes, true); 496 bookmark_api_helpers::AddNode(GetBookmarkModel(), node, &nodes, true);
506 results_ = bookmarks::GetSubTree::Results::Create(nodes); 497 results_ = bookmarks::GetSubTree::Results::Create(nodes);
507 return true; 498 return true;
508 } 499 }
509 500
510 bool BookmarksSearchFunction::RunOnReady() { 501 bool BookmarksSearchFunction::RunOnReady() {
511 scoped_ptr<bookmarks::Search::Params> params( 502 scoped_ptr<bookmarks::Search::Params> params(
512 bookmarks::Search::Params::Create(*args_)); 503 bookmarks::Search::Params::Create(*args_));
513 EXTENSION_FUNCTION_VALIDATE(params.get()); 504 EXTENSION_FUNCTION_VALIDATE(params.get());
514 505
515 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); 506 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile());
(...skipping 24 matching lines...) Expand all
540 query.title.reset(new base::string16(base::UTF8ToUTF16(*object.title))); 531 query.title.reset(new base::string16(base::UTF8ToUTF16(*object.title)));
541 ::bookmarks::GetBookmarksMatchingProperties( 532 ::bookmarks::GetBookmarksMatchingProperties(
542 BookmarkModelFactory::GetForProfile(GetProfile()), 533 BookmarkModelFactory::GetForProfile(GetProfile()),
543 query, 534 query,
544 std::numeric_limits<int>::max(), 535 std::numeric_limits<int>::max(),
545 lang, 536 lang,
546 &nodes); 537 &nodes);
547 } 538 }
548 539
549 std::vector<linked_ptr<BookmarkTreeNode> > tree_nodes; 540 std::vector<linked_ptr<BookmarkTreeNode> > tree_nodes;
550 ChromeBookmarkClient* client = GetChromeBookmarkClient(); 541 BookmarkModel* model = GetBookmarkModel();
551 for (std::vector<const BookmarkNode*>::iterator node_iter = nodes.begin(); 542 for (std::vector<const BookmarkNode*>::iterator node_iter = nodes.begin();
552 node_iter != nodes.end(); ++node_iter) { 543 node_iter != nodes.end(); ++node_iter) {
553 bookmark_api_helpers::AddNode(client, *node_iter, &tree_nodes, false); 544 bookmark_api_helpers::AddNode(model, *node_iter, &tree_nodes, false);
554 } 545 }
555 546
556 results_ = bookmarks::Search::Results::Create(tree_nodes); 547 results_ = bookmarks::Search::Results::Create(tree_nodes);
557 return true; 548 return true;
558 } 549 }
559 550
560 // static 551 // static
561 bool BookmarksRemoveFunction::ExtractIds(const base::ListValue* args, 552 bool BookmarksRemoveFunction::ExtractIds(const base::ListValue* args,
562 std::list<int64>* ids, 553 std::list<int64>* ids,
563 bool* invalid_id) { 554 bool* invalid_id) {
(...skipping 18 matching lines...) Expand all
582 573
583 int64 id; 574 int64 id;
584 if (!GetBookmarkIdAsInt64(params->id, &id)) 575 if (!GetBookmarkIdAsInt64(params->id, &id))
585 return false; 576 return false;
586 577
587 bool recursive = false; 578 bool recursive = false;
588 if (name() == BookmarksRemoveTreeFunction::function_name()) 579 if (name() == BookmarksRemoveTreeFunction::function_name())
589 recursive = true; 580 recursive = true;
590 581
591 BookmarkModel* model = GetBookmarkModel(); 582 BookmarkModel* model = GetBookmarkModel();
592 ChromeBookmarkClient* client = GetChromeBookmarkClient(); 583 if (!bookmark_api_helpers::RemoveNode(model, id, recursive, &error_))
593 if (!bookmark_api_helpers::RemoveNode(model, client, id, recursive, &error_))
594 return false; 584 return false;
595 585
596 return true; 586 return true;
597 } 587 }
598 588
599 bool BookmarksCreateFunction::RunOnReady() { 589 bool BookmarksCreateFunction::RunOnReady() {
600 if (!EditBookmarksEnabled()) 590 if (!EditBookmarksEnabled())
601 return false; 591 return false;
602 592
603 scoped_ptr<bookmarks::Create::Params> params( 593 scoped_ptr<bookmarks::Create::Params> params(
604 bookmarks::Create::Params::Create(*args_)); 594 bookmarks::Create::Params::Create(*args_));
605 EXTENSION_FUNCTION_VALIDATE(params.get()); 595 EXTENSION_FUNCTION_VALIDATE(params.get());
606 596
607 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 597 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
608 const BookmarkNode* node = CreateBookmarkNode(model, params->bookmark, NULL); 598 const BookmarkNode* node = CreateBookmarkNode(model, params->bookmark, NULL);
609 if (!node) 599 if (!node)
610 return false; 600 return false;
611 601
612 scoped_ptr<BookmarkTreeNode> ret(bookmark_api_helpers::GetBookmarkTreeNode( 602 scoped_ptr<BookmarkTreeNode> ret(
613 GetChromeBookmarkClient(), node, false, false)); 603 bookmark_api_helpers::GetBookmarkTreeNode(model, node, false, false));
614 results_ = bookmarks::Create::Results::Create(*ret); 604 results_ = bookmarks::Create::Results::Create(*ret);
615 605
616 return true; 606 return true;
617 } 607 }
618 608
619 // static 609 // static
620 bool BookmarksMoveFunction::ExtractIds(const base::ListValue* args, 610 bool BookmarksMoveFunction::ExtractIds(const base::ListValue* args,
621 std::list<int64>* ids, 611 std::list<int64>* ids,
622 bool* invalid_id) { 612 bool* invalid_id) {
623 // For now, Move accepts ID parameters in the same way as an Update. 613 // For now, Move accepts ID parameters in the same way as an Update.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 error_ = keys::kInvalidIndexError; 653 error_ = keys::kInvalidIndexError;
664 return false; 654 return false;
665 } 655 }
666 } else { 656 } else {
667 index = parent->child_count(); 657 index = parent->child_count();
668 } 658 }
669 659
670 model->Move(node, parent, index); 660 model->Move(node, parent, index);
671 661
672 scoped_ptr<BookmarkTreeNode> tree_node( 662 scoped_ptr<BookmarkTreeNode> tree_node(
673 bookmark_api_helpers::GetBookmarkTreeNode( 663 bookmark_api_helpers::GetBookmarkTreeNode(model, node, false, false));
674 GetChromeBookmarkClient(), node, false, false));
675 results_ = bookmarks::Move::Results::Create(*tree_node); 664 results_ = bookmarks::Move::Results::Create(*tree_node);
676 665
677 return true; 666 return true;
678 } 667 }
679 668
680 // static 669 // static
681 bool BookmarksUpdateFunction::ExtractIds(const base::ListValue* args, 670 bool BookmarksUpdateFunction::ExtractIds(const base::ListValue* args,
682 std::list<int64>* ids, 671 std::list<int64>* ids,
683 bool* invalid_id) { 672 bool* invalid_id) {
684 // For now, Update accepts ID parameters in the same way as an Remove. 673 // For now, Update accepts ID parameters in the same way as an Remove.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 if (model->is_permanent_node(node)) { 708 if (model->is_permanent_node(node)) {
720 error_ = keys::kModifySpecialError; 709 error_ = keys::kModifySpecialError;
721 return false; 710 return false;
722 } 711 }
723 if (has_title) 712 if (has_title)
724 model->SetTitle(node, title); 713 model->SetTitle(node, title);
725 if (!url.is_empty()) 714 if (!url.is_empty())
726 model->SetURL(node, url); 715 model->SetURL(node, url);
727 716
728 scoped_ptr<BookmarkTreeNode> tree_node( 717 scoped_ptr<BookmarkTreeNode> tree_node(
729 bookmark_api_helpers::GetBookmarkTreeNode( 718 bookmark_api_helpers::GetBookmarkTreeNode(model, node, false, false));
730 GetChromeBookmarkClient(), node, false, false));
731 results_ = bookmarks::Update::Results::Create(*tree_node); 719 results_ = bookmarks::Update::Results::Create(*tree_node);
732 return true; 720 return true;
733 } 721 }
734 722
735 BookmarksIOFunction::BookmarksIOFunction() {} 723 BookmarksIOFunction::BookmarksIOFunction() {}
736 724
737 BookmarksIOFunction::~BookmarksIOFunction() { 725 BookmarksIOFunction::~BookmarksIOFunction() {
738 // There may be pending file dialogs, we need to tell them that we've gone 726 // There may be pending file dialogs, we need to tell them that we've gone
739 // away so they don't try and call back to us. 727 // away so they don't try and call back to us.
740 if (select_file_dialog_.get()) 728 if (select_file_dialog_.get())
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 831 }
844 832
845 void BookmarksExportFunction::FileSelected(const base::FilePath& path, 833 void BookmarksExportFunction::FileSelected(const base::FilePath& path,
846 int index, 834 int index,
847 void* params) { 835 void* params) {
848 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); 836 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL);
849 Release(); // Balanced in BookmarksIOFunction::SelectFile() 837 Release(); // Balanced in BookmarksIOFunction::SelectFile()
850 } 838 }
851 839
852 } // namespace extensions 840 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698