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

Side by Side Diff: chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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/bookmark_manager_private/bookmark_manage r_private_api.h" 5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9
9 #include <utility> 10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
13 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 18 #include "base/values.h"
17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
18 #include "chrome/browser/bookmarks/bookmark_stats.h" 20 #include "chrome/browser/bookmarks/bookmark_stats.h"
19 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h" 22 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h"
21 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h" 23 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h"
22 #include "chrome/browser/extensions/extension_web_ui.h" 24 #include "chrome/browser/extensions/extension_web_ui.h"
23 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 180 }
179 181
180 BookmarkManagerPrivateEventRouter::~BookmarkManagerPrivateEventRouter() { 182 BookmarkManagerPrivateEventRouter::~BookmarkManagerPrivateEventRouter() {
181 if (bookmark_model_) 183 if (bookmark_model_)
182 bookmark_model_->RemoveObserver(this); 184 bookmark_model_->RemoveObserver(this);
183 } 185 }
184 186
185 void BookmarkManagerPrivateEventRouter::DispatchEvent( 187 void BookmarkManagerPrivateEventRouter::DispatchEvent(
186 events::HistogramValue histogram_value, 188 events::HistogramValue histogram_value,
187 const std::string& event_name, 189 const std::string& event_name,
188 scoped_ptr<base::ListValue> event_args) { 190 std::unique_ptr<base::ListValue> event_args) {
189 EventRouter::Get(browser_context_) 191 EventRouter::Get(browser_context_)
190 ->BroadcastEvent(make_scoped_ptr( 192 ->BroadcastEvent(base::WrapUnique(
191 new Event(histogram_value, event_name, std::move(event_args)))); 193 new Event(histogram_value, event_name, std::move(event_args))));
192 } 194 }
193 195
194 void BookmarkManagerPrivateEventRouter::BookmarkModelChanged() {} 196 void BookmarkManagerPrivateEventRouter::BookmarkModelChanged() {}
195 197
196 void BookmarkManagerPrivateEventRouter::BookmarkModelBeingDeleted( 198 void BookmarkManagerPrivateEventRouter::BookmarkModelBeingDeleted(
197 BookmarkModel* model) { 199 BookmarkModel* model) {
198 bookmark_model_ = NULL; 200 bookmark_model_ = NULL;
199 } 201 }
200 202
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 ~BookmarkManagerPrivateDragEventRouter() { 296 ~BookmarkManagerPrivateDragEventRouter() {
295 BookmarkTabHelper* bookmark_tab_helper = 297 BookmarkTabHelper* bookmark_tab_helper =
296 BookmarkTabHelper::FromWebContents(web_contents_); 298 BookmarkTabHelper::FromWebContents(web_contents_);
297 if (bookmark_tab_helper->bookmark_drag_delegate() == this) 299 if (bookmark_tab_helper->bookmark_drag_delegate() == this)
298 bookmark_tab_helper->set_bookmark_drag_delegate(NULL); 300 bookmark_tab_helper->set_bookmark_drag_delegate(NULL);
299 } 301 }
300 302
301 void BookmarkManagerPrivateDragEventRouter::DispatchEvent( 303 void BookmarkManagerPrivateDragEventRouter::DispatchEvent(
302 events::HistogramValue histogram_value, 304 events::HistogramValue histogram_value,
303 const std::string& event_name, 305 const std::string& event_name,
304 scoped_ptr<base::ListValue> args) { 306 std::unique_ptr<base::ListValue> args) {
305 EventRouter* event_router = EventRouter::Get(profile_); 307 EventRouter* event_router = EventRouter::Get(profile_);
306 if (!event_router) 308 if (!event_router)
307 return; 309 return;
308 310
309 scoped_ptr<Event> event( 311 std::unique_ptr<Event> event(
310 new Event(histogram_value, event_name, std::move(args))); 312 new Event(histogram_value, event_name, std::move(args)));
311 event_router->BroadcastEvent(std::move(event)); 313 event_router->BroadcastEvent(std::move(event));
312 } 314 }
313 315
314 void BookmarkManagerPrivateDragEventRouter::OnDragEnter( 316 void BookmarkManagerPrivateDragEventRouter::OnDragEnter(
315 const BookmarkNodeData& data) { 317 const BookmarkNodeData& data) {
316 if (!data.is_valid()) 318 if (!data.is_valid())
317 return; 319 return;
318 DispatchEvent(events::BOOKMARK_MANAGER_PRIVATE_ON_DRAG_ENTER, 320 DispatchEvent(events::BOOKMARK_MANAGER_PRIVATE_ON_DRAG_ENTER,
319 bookmark_manager_private::OnDragEnter::kEventName, 321 bookmark_manager_private::OnDragEnter::kEventName,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 EXTENSION_FUNCTION_VALIDATE(GetNodesFromVector(model, id_list, &nodes)); 372 EXTENSION_FUNCTION_VALIDATE(GetNodesFromVector(model, id_list, &nodes));
371 if (cut && bookmarks::HasDescendantsOf(nodes, managed->managed_node())) { 373 if (cut && bookmarks::HasDescendantsOf(nodes, managed->managed_node())) {
372 error_ = bookmark_keys::kModifyManagedError; 374 error_ = bookmark_keys::kModifyManagedError;
373 return false; 375 return false;
374 } 376 }
375 bookmarks::CopyToClipboard(model, nodes, cut); 377 bookmarks::CopyToClipboard(model, nodes, cut);
376 return true; 378 return true;
377 } 379 }
378 380
379 bool BookmarkManagerPrivateCopyFunction::RunOnReady() { 381 bool BookmarkManagerPrivateCopyFunction::RunOnReady() {
380 scoped_ptr<Copy::Params> params(Copy::Params::Create(*args_)); 382 std::unique_ptr<Copy::Params> params(Copy::Params::Create(*args_));
381 EXTENSION_FUNCTION_VALIDATE(params); 383 EXTENSION_FUNCTION_VALIDATE(params);
382 return CopyOrCut(false, params->id_list); 384 return CopyOrCut(false, params->id_list);
383 } 385 }
384 386
385 bool BookmarkManagerPrivateCutFunction::RunOnReady() { 387 bool BookmarkManagerPrivateCutFunction::RunOnReady() {
386 if (!EditBookmarksEnabled()) 388 if (!EditBookmarksEnabled())
387 return false; 389 return false;
388 390
389 scoped_ptr<Cut::Params> params(Cut::Params::Create(*args_)); 391 std::unique_ptr<Cut::Params> params(Cut::Params::Create(*args_));
390 EXTENSION_FUNCTION_VALIDATE(params); 392 EXTENSION_FUNCTION_VALIDATE(params);
391 return CopyOrCut(true, params->id_list); 393 return CopyOrCut(true, params->id_list);
392 } 394 }
393 395
394 bool BookmarkManagerPrivatePasteFunction::RunOnReady() { 396 bool BookmarkManagerPrivatePasteFunction::RunOnReady() {
395 if (!EditBookmarksEnabled()) 397 if (!EditBookmarksEnabled())
396 return false; 398 return false;
397 399
398 scoped_ptr<Paste::Params> params(Paste::Params::Create(*args_)); 400 std::unique_ptr<Paste::Params> params(Paste::Params::Create(*args_));
399 EXTENSION_FUNCTION_VALIDATE(params); 401 EXTENSION_FUNCTION_VALIDATE(params);
400 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 402 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
401 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); 403 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id);
402 if (!CanBeModified(parent_node)) 404 if (!CanBeModified(parent_node))
403 return false; 405 return false;
404 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); 406 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node);
405 if (!can_paste) 407 if (!can_paste)
406 return false; 408 return false;
407 409
408 // We want to use the highest index of the selected nodes as a destination. 410 // We want to use the highest index of the selected nodes as a destination.
409 std::vector<const BookmarkNode*> nodes; 411 std::vector<const BookmarkNode*> nodes;
410 // No need to test return value, if we got an empty list, we insert at end. 412 // No need to test return value, if we got an empty list, we insert at end.
411 if (params->selected_id_list) 413 if (params->selected_id_list)
412 GetNodesFromVector(model, *params->selected_id_list, &nodes); 414 GetNodesFromVector(model, *params->selected_id_list, &nodes);
413 int highest_index = -1; // -1 means insert at end of list. 415 int highest_index = -1; // -1 means insert at end of list.
414 for (size_t i = 0; i < nodes.size(); ++i) { 416 for (size_t i = 0; i < nodes.size(); ++i) {
415 // + 1 so that we insert after the selection. 417 // + 1 so that we insert after the selection.
416 int index = parent_node->GetIndexOf(nodes[i]) + 1; 418 int index = parent_node->GetIndexOf(nodes[i]) + 1;
417 if (index > highest_index) 419 if (index > highest_index)
418 highest_index = index; 420 highest_index = index;
419 } 421 }
420 422
421 bookmarks::PasteFromClipboard(model, parent_node, highest_index); 423 bookmarks::PasteFromClipboard(model, parent_node, highest_index);
422 return true; 424 return true;
423 } 425 }
424 426
425 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() { 427 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() {
426 scoped_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); 428 std::unique_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_));
427 EXTENSION_FUNCTION_VALIDATE(params); 429 EXTENSION_FUNCTION_VALIDATE(params);
428 430
429 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); 431 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile());
430 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) { 432 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) {
431 SetResult(new base::FundamentalValue(false)); 433 SetResult(new base::FundamentalValue(false));
432 return true; 434 return true;
433 } 435 }
434 436
435 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 437 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
436 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); 438 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id);
437 if (!parent_node) { 439 if (!parent_node) {
438 error_ = bookmark_keys::kNoParentError; 440 error_ = bookmark_keys::kNoParentError;
439 return false; 441 return false;
440 } 442 }
441 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); 443 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node);
442 SetResult(new base::FundamentalValue(can_paste)); 444 SetResult(new base::FundamentalValue(can_paste));
443 return true; 445 return true;
444 } 446 }
445 447
446 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() { 448 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() {
447 if (!EditBookmarksEnabled()) 449 if (!EditBookmarksEnabled())
448 return false; 450 return false;
449 451
450 scoped_ptr<SortChildren::Params> params(SortChildren::Params::Create(*args_)); 452 std::unique_ptr<SortChildren::Params> params(
453 SortChildren::Params::Create(*args_));
451 EXTENSION_FUNCTION_VALIDATE(params); 454 EXTENSION_FUNCTION_VALIDATE(params);
452 455
453 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 456 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
454 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); 457 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id);
455 if (!CanBeModified(parent_node)) 458 if (!CanBeModified(parent_node))
456 return false; 459 return false;
457 model->SortChildren(parent_node); 460 model->SortChildren(parent_node);
458 return true; 461 return true;
459 } 462 }
460 463
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 545
543 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() { 546 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() {
544 if (!EditBookmarksEnabled()) 547 if (!EditBookmarksEnabled())
545 return false; 548 return false;
546 549
547 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { 550 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) {
548 NOTREACHED(); 551 NOTREACHED();
549 return false; 552 return false;
550 } 553 }
551 554
552 scoped_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_)); 555 std::unique_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_));
553 EXTENSION_FUNCTION_VALIDATE(params); 556 EXTENSION_FUNCTION_VALIDATE(params);
554 557
555 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 558 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
556 std::vector<const BookmarkNode*> nodes; 559 std::vector<const BookmarkNode*> nodes;
557 EXTENSION_FUNCTION_VALIDATE( 560 EXTENSION_FUNCTION_VALIDATE(
558 GetNodesFromVector(model, params->id_list, &nodes)); 561 GetNodesFromVector(model, params->id_list, &nodes));
559 562
560 content::WebContents* web_contents = GetAssociatedWebContents(); 563 content::WebContents* web_contents = GetAssociatedWebContents();
561 CHECK(web_contents); 564 CHECK(web_contents);
562 565
563 ui::DragDropTypes::DragEventSource source = 566 ui::DragDropTypes::DragEventSource source =
564 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; 567 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE;
565 if (params->is_from_touch) 568 if (params->is_from_touch)
566 source = ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; 569 source = ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH;
567 570
568 chrome::DragBookmarks( 571 chrome::DragBookmarks(
569 GetProfile(), nodes, web_contents->GetNativeView(), source); 572 GetProfile(), nodes, web_contents->GetNativeView(), source);
570 573
571 return true; 574 return true;
572 } 575 }
573 576
574 bool BookmarkManagerPrivateDropFunction::RunOnReady() { 577 bool BookmarkManagerPrivateDropFunction::RunOnReady() {
575 if (!EditBookmarksEnabled()) 578 if (!EditBookmarksEnabled())
576 return false; 579 return false;
577 580
578 scoped_ptr<Drop::Params> params(Drop::Params::Create(*args_)); 581 std::unique_ptr<Drop::Params> params(Drop::Params::Create(*args_));
579 EXTENSION_FUNCTION_VALIDATE(params); 582 EXTENSION_FUNCTION_VALIDATE(params);
580 583
581 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 584 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
582 585
583 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id); 586 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id);
584 if (!CanBeModified(drop_parent)) 587 if (!CanBeModified(drop_parent))
585 return false; 588 return false;
586 589
587 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { 590 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) {
588 NOTREACHED(); 591 NOTREACHED();
(...skipping 22 matching lines...) Expand all
611 } 614 }
612 const bool copy = false; 615 const bool copy = false;
613 chrome::DropBookmarks( 616 chrome::DropBookmarks(
614 GetProfile(), *drag_data, drop_parent, drop_index, copy); 617 GetProfile(), *drag_data, drop_parent, drop_index, copy);
615 618
616 router->ClearBookmarkNodeData(); 619 router->ClearBookmarkNodeData();
617 return true; 620 return true;
618 } 621 }
619 622
620 bool BookmarkManagerPrivateGetSubtreeFunction::RunOnReady() { 623 bool BookmarkManagerPrivateGetSubtreeFunction::RunOnReady() {
621 scoped_ptr<GetSubtree::Params> params(GetSubtree::Params::Create(*args_)); 624 std::unique_ptr<GetSubtree::Params> params(
625 GetSubtree::Params::Create(*args_));
622 EXTENSION_FUNCTION_VALIDATE(params); 626 EXTENSION_FUNCTION_VALIDATE(params);
623 627
624 const BookmarkNode* node = NULL; 628 const BookmarkNode* node = NULL;
625 629
626 if (params->id.empty()) { 630 if (params->id.empty()) {
627 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 631 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
628 node = model->root_node(); 632 node = model->root_node();
629 } else { 633 } else {
630 node = GetBookmarkNodeFromId(params->id); 634 node = GetBookmarkNodeFromId(params->id);
631 if (!node) 635 if (!node)
(...skipping 19 matching lines...) Expand all
651 655
652 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() { 656 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() {
653 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); 657 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER);
654 return true; 658 return true;
655 } 659 }
656 660
657 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { 661 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() {
658 if (!EditBookmarksEnabled()) 662 if (!EditBookmarksEnabled())
659 return false; 663 return false;
660 664
661 scoped_ptr<CreateWithMetaInfo::Params> params( 665 std::unique_ptr<CreateWithMetaInfo::Params> params(
662 CreateWithMetaInfo::Params::Create(*args_)); 666 CreateWithMetaInfo::Params::Create(*args_));
663 EXTENSION_FUNCTION_VALIDATE(params); 667 EXTENSION_FUNCTION_VALIDATE(params);
664 668
665 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 669 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
666 const BookmarkNode* node = CreateBookmarkNode( 670 const BookmarkNode* node = CreateBookmarkNode(
667 model, params->bookmark, &params->meta_info.additional_properties); 671 model, params->bookmark, &params->meta_info.additional_properties);
668 if (!node) 672 if (!node)
669 return false; 673 return false;
670 674
671 api::bookmarks::BookmarkTreeNode result_node = 675 api::bookmarks::BookmarkTreeNode result_node =
672 bookmark_api_helpers::GetBookmarkTreeNode(GetManagedBookmarkService(), 676 bookmark_api_helpers::GetBookmarkTreeNode(GetManagedBookmarkService(),
673 node, false, false); 677 node, false, false);
674 results_ = CreateWithMetaInfo::Results::Create(result_node); 678 results_ = CreateWithMetaInfo::Results::Create(result_node);
675 679
676 return true; 680 return true;
677 } 681 }
678 682
679 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { 683 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() {
680 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); 684 std::unique_ptr<GetMetaInfo::Params> params(
685 GetMetaInfo::Params::Create(*args_));
681 EXTENSION_FUNCTION_VALIDATE(params); 686 EXTENSION_FUNCTION_VALIDATE(params);
682 687
683 if (params->id) { 688 if (params->id) {
684 const BookmarkNode* node = GetBookmarkNodeFromId(*params->id); 689 const BookmarkNode* node = GetBookmarkNodeFromId(*params->id);
685 if (!node) 690 if (!node)
686 return false; 691 return false;
687 692
688 if (params->key) { 693 if (params->key) {
689 std::string value; 694 std::string value;
690 if (node->GetMetaInfo(*params->key, &value)) { 695 if (node->GetMetaInfo(*params->key, &value)) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 results_ = GetMetaInfo::Results::Create(result); 729 results_ = GetMetaInfo::Results::Create(result);
725 } 730 }
726 731
727 return true; 732 return true;
728 } 733 }
729 734
730 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { 735 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() {
731 if (!EditBookmarksEnabled()) 736 if (!EditBookmarksEnabled())
732 return false; 737 return false;
733 738
734 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); 739 std::unique_ptr<SetMetaInfo::Params> params(
740 SetMetaInfo::Params::Create(*args_));
735 EXTENSION_FUNCTION_VALIDATE(params); 741 EXTENSION_FUNCTION_VALIDATE(params);
736 742
737 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); 743 const BookmarkNode* node = GetBookmarkNodeFromId(params->id);
738 if (!node) 744 if (!node)
739 return false; 745 return false;
740 746
741 if (!CanBeModified(node)) 747 if (!CanBeModified(node))
742 return false; 748 return false;
743 749
744 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 750 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
745 if (model->is_permanent_node(node)) { 751 if (model->is_permanent_node(node)) {
746 error_ = bookmark_keys::kModifySpecialError; 752 error_ = bookmark_keys::kModifySpecialError;
747 return false; 753 return false;
748 } 754 }
749 755
750 model->SetNodeMetaInfo(node, params->key, params->value); 756 model->SetNodeMetaInfo(node, params->key, params->value);
751 return true; 757 return true;
752 } 758 }
753 759
754 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() { 760 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() {
755 if (!EditBookmarksEnabled()) 761 if (!EditBookmarksEnabled())
756 return false; 762 return false;
757 763
758 scoped_ptr<UpdateMetaInfo::Params> params( 764 std::unique_ptr<UpdateMetaInfo::Params> params(
759 UpdateMetaInfo::Params::Create(*args_)); 765 UpdateMetaInfo::Params::Create(*args_));
760 EXTENSION_FUNCTION_VALIDATE(params); 766 EXTENSION_FUNCTION_VALIDATE(params);
761 767
762 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); 768 const BookmarkNode* node = GetBookmarkNodeFromId(params->id);
763 if (!node) 769 if (!node)
764 return false; 770 return false;
765 771
766 if (!CanBeModified(node)) 772 if (!CanBeModified(node))
767 return false; 773 return false;
768 774
(...skipping 17 matching lines...) Expand all
786 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunOnReady() { 792 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunOnReady() {
787 bool can_open_new_windows = true; 793 bool can_open_new_windows = true;
788 SetResult(new base::FundamentalValue(can_open_new_windows)); 794 SetResult(new base::FundamentalValue(can_open_new_windows));
789 return true; 795 return true;
790 } 796 }
791 797
792 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() { 798 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() {
793 if (!EditBookmarksEnabled()) 799 if (!EditBookmarksEnabled())
794 return false; 800 return false;
795 801
796 scoped_ptr<RemoveTrees::Params> params(RemoveTrees::Params::Create(*args_)); 802 std::unique_ptr<RemoveTrees::Params> params(
803 RemoveTrees::Params::Create(*args_));
797 EXTENSION_FUNCTION_VALIDATE(params); 804 EXTENSION_FUNCTION_VALIDATE(params);
798 805
799 BookmarkModel* model = GetBookmarkModel(); 806 BookmarkModel* model = GetBookmarkModel();
800 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService(); 807 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService();
801 bookmarks::ScopedGroupBookmarkActions group_deletes(model); 808 bookmarks::ScopedGroupBookmarkActions group_deletes(model);
802 int64_t id; 809 int64_t id;
803 for (size_t i = 0; i < params->id_list.size(); ++i) { 810 for (size_t i = 0; i < params->id_list.size(); ++i) {
804 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) 811 if (!GetBookmarkIdAsInt64(params->id_list[i], &id))
805 return false; 812 return false;
806 if (!bookmark_api_helpers::RemoveNode(model, managed, id, true, &error_)) 813 if (!bookmark_api_helpers::RemoveNode(model, managed, id, true, &error_))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 853
847 RedoInfo::Results::Result result; 854 RedoInfo::Results::Result result;
848 result.enabled = undo_manager->redo_count() > 0; 855 result.enabled = undo_manager->redo_count() > 0;
849 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); 856 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel());
850 857
851 results_ = RedoInfo::Results::Create(result); 858 results_ = RedoInfo::Results::Create(result);
852 return true; 859 return true;
853 } 860 }
854 861
855 } // namespace extensions 862 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698