| OLD | NEW |
| 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 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 bookmark_manager_private::BookmarkNodeData CreateApiBookmarkNodeData( | 151 bookmark_manager_private::BookmarkNodeData CreateApiBookmarkNodeData( |
| 152 Profile* profile, | 152 Profile* profile, |
| 153 const BookmarkNodeData& data) { | 153 const BookmarkNodeData& data) { |
| 154 const base::FilePath& profile_path = profile->GetPath(); | 154 const base::FilePath& profile_path = profile->GetPath(); |
| 155 | 155 |
| 156 bookmark_manager_private::BookmarkNodeData node_data; | 156 bookmark_manager_private::BookmarkNodeData node_data; |
| 157 node_data.same_profile = data.IsFromProfilePath(profile_path); | 157 node_data.same_profile = data.IsFromProfilePath(profile_path); |
| 158 | 158 |
| 159 if (node_data.same_profile) { | 159 if (node_data.same_profile) { |
| 160 std::vector<const BookmarkNode*> nodes = data.GetNodes( | 160 std::vector<const BookmarkNode*> nodes = data.GetNodes( |
| 161 BookmarkModelFactory::GetForProfile(profile), profile_path); | 161 BookmarkModelFactory::GetForBrowserContext(profile), profile_path); |
| 162 for (size_t i = 0; i < nodes.size(); ++i) { | 162 for (size_t i = 0; i < nodes.size(); ++i) { |
| 163 node_data.elements.push_back( | 163 node_data.elements.push_back( |
| 164 CreateNodeDataElementFromBookmarkNode(*nodes[i])); | 164 CreateNodeDataElementFromBookmarkNode(*nodes[i])); |
| 165 } | 165 } |
| 166 } else { | 166 } else { |
| 167 // We do not have a node IDs when the data comes from a different profile. | 167 // We do not have a node IDs when the data comes from a different profile. |
| 168 for (size_t i = 0; i < data.size(); ++i) | 168 for (size_t i = 0; i < data.size(); ++i) |
| 169 node_data.elements.push_back(CreateApiNodeDataElement(data.elements[i])); | 169 node_data.elements.push_back(CreateApiNodeDataElement(data.elements[i])); |
| 170 } | 170 } |
| 171 return node_data; | 171 return node_data; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 BrowserContextKeyedAPIFactory<BookmarkManagerPrivateAPI>* | 273 BrowserContextKeyedAPIFactory<BookmarkManagerPrivateAPI>* |
| 274 BookmarkManagerPrivateAPI::GetFactoryInstance() { | 274 BookmarkManagerPrivateAPI::GetFactoryInstance() { |
| 275 return g_factory.Pointer(); | 275 return g_factory.Pointer(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void BookmarkManagerPrivateAPI::OnListenerAdded( | 278 void BookmarkManagerPrivateAPI::OnListenerAdded( |
| 279 const EventListenerInfo& details) { | 279 const EventListenerInfo& details) { |
| 280 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 280 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 281 event_router_.reset(new BookmarkManagerPrivateEventRouter( | 281 event_router_.reset(new BookmarkManagerPrivateEventRouter( |
| 282 browser_context_, | 282 browser_context_, |
| 283 BookmarkModelFactory::GetForProfile( | 283 BookmarkModelFactory::GetForBrowserContext(browser_context_))); |
| 284 Profile::FromBrowserContext(browser_context_)))); | |
| 285 } | 284 } |
| 286 | 285 |
| 287 BookmarkManagerPrivateDragEventRouter::BookmarkManagerPrivateDragEventRouter( | 286 BookmarkManagerPrivateDragEventRouter::BookmarkManagerPrivateDragEventRouter( |
| 288 Profile* profile, | 287 Profile* profile, |
| 289 content::WebContents* web_contents) | 288 content::WebContents* web_contents) |
| 290 : profile_(profile), web_contents_(web_contents) { | 289 : profile_(profile), web_contents_(web_contents) { |
| 291 BookmarkTabHelper* bookmark_tab_helper = | 290 BookmarkTabHelper* bookmark_tab_helper = |
| 292 BookmarkTabHelper::FromWebContents(web_contents_); | 291 BookmarkTabHelper::FromWebContents(web_contents_); |
| 293 bookmark_tab_helper->set_bookmark_drag_delegate(this); | 292 bookmark_tab_helper->set_bookmark_drag_delegate(this); |
| 294 } | 293 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 EXTENSION_FUNCTION_VALIDATE(params); | 392 EXTENSION_FUNCTION_VALIDATE(params); |
| 394 return CopyOrCut(true, params->id_list); | 393 return CopyOrCut(true, params->id_list); |
| 395 } | 394 } |
| 396 | 395 |
| 397 bool BookmarkManagerPrivatePasteFunction::RunOnReady() { | 396 bool BookmarkManagerPrivatePasteFunction::RunOnReady() { |
| 398 if (!EditBookmarksEnabled()) | 397 if (!EditBookmarksEnabled()) |
| 399 return false; | 398 return false; |
| 400 | 399 |
| 401 std::unique_ptr<Paste::Params> params(Paste::Params::Create(*args_)); | 400 std::unique_ptr<Paste::Params> params(Paste::Params::Create(*args_)); |
| 402 EXTENSION_FUNCTION_VALIDATE(params); | 401 EXTENSION_FUNCTION_VALIDATE(params); |
| 403 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 402 BookmarkModel* model = |
| 403 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 404 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 404 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
| 405 if (!CanBeModified(parent_node)) | 405 if (!CanBeModified(parent_node)) |
| 406 return false; | 406 return false; |
| 407 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); | 407 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); |
| 408 if (!can_paste) | 408 if (!can_paste) |
| 409 return false; | 409 return false; |
| 410 | 410 |
| 411 // We want to use the highest index of the selected nodes as a destination. | 411 // We want to use the highest index of the selected nodes as a destination. |
| 412 std::vector<const BookmarkNode*> nodes; | 412 std::vector<const BookmarkNode*> nodes; |
| 413 // No need to test return value, if we got an empty list, we insert at end. | 413 // No need to test return value, if we got an empty list, we insert at end. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 428 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() { | 428 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() { |
| 429 std::unique_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); | 429 std::unique_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); |
| 430 EXTENSION_FUNCTION_VALIDATE(params); | 430 EXTENSION_FUNCTION_VALIDATE(params); |
| 431 | 431 |
| 432 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); | 432 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); |
| 433 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) { | 433 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) { |
| 434 SetResult(base::MakeUnique<base::FundamentalValue>(false)); | 434 SetResult(base::MakeUnique<base::FundamentalValue>(false)); |
| 435 return true; | 435 return true; |
| 436 } | 436 } |
| 437 | 437 |
| 438 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 438 BookmarkModel* model = |
| 439 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 439 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 440 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
| 440 if (!parent_node) { | 441 if (!parent_node) { |
| 441 error_ = bookmark_keys::kNoParentError; | 442 error_ = bookmark_keys::kNoParentError; |
| 442 return false; | 443 return false; |
| 443 } | 444 } |
| 444 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); | 445 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); |
| 445 SetResult(base::MakeUnique<base::FundamentalValue>(can_paste)); | 446 SetResult(base::MakeUnique<base::FundamentalValue>(can_paste)); |
| 446 return true; | 447 return true; |
| 447 } | 448 } |
| 448 | 449 |
| 449 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() { | 450 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() { |
| 450 if (!EditBookmarksEnabled()) | 451 if (!EditBookmarksEnabled()) |
| 451 return false; | 452 return false; |
| 452 | 453 |
| 453 std::unique_ptr<SortChildren::Params> params( | 454 std::unique_ptr<SortChildren::Params> params( |
| 454 SortChildren::Params::Create(*args_)); | 455 SortChildren::Params::Create(*args_)); |
| 455 EXTENSION_FUNCTION_VALIDATE(params); | 456 EXTENSION_FUNCTION_VALIDATE(params); |
| 456 | 457 |
| 457 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 458 BookmarkModel* model = |
| 459 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 458 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 460 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
| 459 if (!CanBeModified(parent_node)) | 461 if (!CanBeModified(parent_node)) |
| 460 return false; | 462 return false; |
| 461 model->SortChildren(parent_node); | 463 model->SortChildren(parent_node); |
| 462 return true; | 464 return true; |
| 463 } | 465 } |
| 464 | 466 |
| 465 ExtensionFunction::ResponseAction | 467 ExtensionFunction::ResponseAction |
| 466 BookmarkManagerPrivateGetStringsFunction::Run() { | 468 BookmarkManagerPrivateGetStringsFunction::Run() { |
| 467 std::unique_ptr<base::DictionaryValue> localized_strings( | 469 std::unique_ptr<base::DictionaryValue> localized_strings( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 return false; | 547 return false; |
| 546 | 548 |
| 547 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { | 549 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { |
| 548 NOTREACHED(); | 550 NOTREACHED(); |
| 549 return false; | 551 return false; |
| 550 } | 552 } |
| 551 | 553 |
| 552 std::unique_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_)); | 554 std::unique_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_)); |
| 553 EXTENSION_FUNCTION_VALIDATE(params); | 555 EXTENSION_FUNCTION_VALIDATE(params); |
| 554 | 556 |
| 555 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 557 BookmarkModel* model = |
| 558 BookmarkModelFactory::GetForBrowserContext(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 std::unique_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 = |
| 585 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 582 | 586 |
| 583 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id); | 587 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id); |
| 584 if (!CanBeModified(drop_parent)) | 588 if (!CanBeModified(drop_parent)) |
| 585 return false; | 589 return false; |
| 586 | 590 |
| 587 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { | 591 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { |
| 588 NOTREACHED(); | 592 NOTREACHED(); |
| 589 return false; | 593 return false; |
| 590 } | 594 } |
| 591 | 595 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 618 } | 622 } |
| 619 | 623 |
| 620 bool BookmarkManagerPrivateGetSubtreeFunction::RunOnReady() { | 624 bool BookmarkManagerPrivateGetSubtreeFunction::RunOnReady() { |
| 621 std::unique_ptr<GetSubtree::Params> params( | 625 std::unique_ptr<GetSubtree::Params> params( |
| 622 GetSubtree::Params::Create(*args_)); | 626 GetSubtree::Params::Create(*args_)); |
| 623 EXTENSION_FUNCTION_VALIDATE(params); | 627 EXTENSION_FUNCTION_VALIDATE(params); |
| 624 | 628 |
| 625 const BookmarkNode* node = NULL; | 629 const BookmarkNode* node = NULL; |
| 626 | 630 |
| 627 if (params->id.empty()) { | 631 if (params->id.empty()) { |
| 628 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 632 BookmarkModel* model = |
| 633 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 629 node = model->root_node(); | 634 node = model->root_node(); |
| 630 } else { | 635 } else { |
| 631 node = GetBookmarkNodeFromId(params->id); | 636 node = GetBookmarkNodeFromId(params->id); |
| 632 if (!node) | 637 if (!node) |
| 633 return false; | 638 return false; |
| 634 } | 639 } |
| 635 | 640 |
| 636 std::vector<api::bookmarks::BookmarkTreeNode> nodes; | 641 std::vector<api::bookmarks::BookmarkTreeNode> nodes; |
| 637 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService(); | 642 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService(); |
| 638 if (params->folders_only) | 643 if (params->folders_only) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 656 } | 661 } |
| 657 | 662 |
| 658 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { | 663 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { |
| 659 if (!EditBookmarksEnabled()) | 664 if (!EditBookmarksEnabled()) |
| 660 return false; | 665 return false; |
| 661 | 666 |
| 662 std::unique_ptr<CreateWithMetaInfo::Params> params( | 667 std::unique_ptr<CreateWithMetaInfo::Params> params( |
| 663 CreateWithMetaInfo::Params::Create(*args_)); | 668 CreateWithMetaInfo::Params::Create(*args_)); |
| 664 EXTENSION_FUNCTION_VALIDATE(params); | 669 EXTENSION_FUNCTION_VALIDATE(params); |
| 665 | 670 |
| 666 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 671 BookmarkModel* model = |
| 672 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 667 const BookmarkNode* node = CreateBookmarkNode( | 673 const BookmarkNode* node = CreateBookmarkNode( |
| 668 model, params->bookmark, ¶ms->meta_info.additional_properties); | 674 model, params->bookmark, ¶ms->meta_info.additional_properties); |
| 669 if (!node) | 675 if (!node) |
| 670 return false; | 676 return false; |
| 671 | 677 |
| 672 api::bookmarks::BookmarkTreeNode result_node = | 678 api::bookmarks::BookmarkTreeNode result_node = |
| 673 bookmark_api_helpers::GetBookmarkTreeNode(GetManagedBookmarkService(), | 679 bookmark_api_helpers::GetBookmarkTreeNode(GetManagedBookmarkService(), |
| 674 node, false, false); | 680 node, false, false); |
| 675 results_ = CreateWithMetaInfo::Results::Create(result_node); | 681 results_ = CreateWithMetaInfo::Results::Create(result_node); |
| 676 | 682 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 707 } | 713 } |
| 708 } | 714 } |
| 709 results_ = GetMetaInfo::Results::Create(result); | 715 results_ = GetMetaInfo::Results::Create(result); |
| 710 } | 716 } |
| 711 } else { | 717 } else { |
| 712 if (params->key) { | 718 if (params->key) { |
| 713 error_ = bookmark_api_constants::kInvalidParamError; | 719 error_ = bookmark_api_constants::kInvalidParamError; |
| 714 return true; | 720 return true; |
| 715 } | 721 } |
| 716 | 722 |
| 717 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 723 BookmarkModel* model = |
| 724 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 718 const BookmarkNode* node = model->root_node(); | 725 const BookmarkNode* node = model->root_node(); |
| 719 | 726 |
| 720 GetMetaInfo::Results::Value result; | 727 GetMetaInfo::Results::Value result; |
| 721 result.as_object.reset(new GetMetaInfo::Results::Value::Object); | 728 result.as_object.reset(new GetMetaInfo::Results::Value::Object); |
| 722 | 729 |
| 723 bookmark_api_helpers::GetMetaInfo(*node, | 730 bookmark_api_helpers::GetMetaInfo(*node, |
| 724 &result.as_object->additional_properties); | 731 &result.as_object->additional_properties); |
| 725 | 732 |
| 726 results_ = GetMetaInfo::Results::Create(result); | 733 results_ = GetMetaInfo::Results::Create(result); |
| 727 } | 734 } |
| 728 | 735 |
| 729 return true; | 736 return true; |
| 730 } | 737 } |
| 731 | 738 |
| 732 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { | 739 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { |
| 733 if (!EditBookmarksEnabled()) | 740 if (!EditBookmarksEnabled()) |
| 734 return false; | 741 return false; |
| 735 | 742 |
| 736 std::unique_ptr<SetMetaInfo::Params> params( | 743 std::unique_ptr<SetMetaInfo::Params> params( |
| 737 SetMetaInfo::Params::Create(*args_)); | 744 SetMetaInfo::Params::Create(*args_)); |
| 738 EXTENSION_FUNCTION_VALIDATE(params); | 745 EXTENSION_FUNCTION_VALIDATE(params); |
| 739 | 746 |
| 740 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 747 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
| 741 if (!node) | 748 if (!node) |
| 742 return false; | 749 return false; |
| 743 | 750 |
| 744 if (!CanBeModified(node)) | 751 if (!CanBeModified(node)) |
| 745 return false; | 752 return false; |
| 746 | 753 |
| 747 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 754 BookmarkModel* model = |
| 755 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 748 if (model->is_permanent_node(node)) { | 756 if (model->is_permanent_node(node)) { |
| 749 error_ = bookmark_keys::kModifySpecialError; | 757 error_ = bookmark_keys::kModifySpecialError; |
| 750 return false; | 758 return false; |
| 751 } | 759 } |
| 752 | 760 |
| 753 model->SetNodeMetaInfo(node, params->key, params->value); | 761 model->SetNodeMetaInfo(node, params->key, params->value); |
| 754 return true; | 762 return true; |
| 755 } | 763 } |
| 756 | 764 |
| 757 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() { | 765 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() { |
| 758 if (!EditBookmarksEnabled()) | 766 if (!EditBookmarksEnabled()) |
| 759 return false; | 767 return false; |
| 760 | 768 |
| 761 std::unique_ptr<UpdateMetaInfo::Params> params( | 769 std::unique_ptr<UpdateMetaInfo::Params> params( |
| 762 UpdateMetaInfo::Params::Create(*args_)); | 770 UpdateMetaInfo::Params::Create(*args_)); |
| 763 EXTENSION_FUNCTION_VALIDATE(params); | 771 EXTENSION_FUNCTION_VALIDATE(params); |
| 764 | 772 |
| 765 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 773 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
| 766 if (!node) | 774 if (!node) |
| 767 return false; | 775 return false; |
| 768 | 776 |
| 769 if (!CanBeModified(node)) | 777 if (!CanBeModified(node)) |
| 770 return false; | 778 return false; |
| 771 | 779 |
| 772 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 780 BookmarkModel* model = |
| 781 BookmarkModelFactory::GetForBrowserContext(GetProfile()); |
| 773 if (model->is_permanent_node(node)) { | 782 if (model->is_permanent_node(node)) { |
| 774 error_ = bookmark_keys::kModifySpecialError; | 783 error_ = bookmark_keys::kModifySpecialError; |
| 775 return false; | 784 return false; |
| 776 } | 785 } |
| 777 | 786 |
| 778 BookmarkNode::MetaInfoMap new_meta_info( | 787 BookmarkNode::MetaInfoMap new_meta_info( |
| 779 params->meta_info_changes.additional_properties); | 788 params->meta_info_changes.additional_properties); |
| 780 if (node->GetMetaInfoMap()) { | 789 if (node->GetMetaInfoMap()) { |
| 781 new_meta_info.insert(node->GetMetaInfoMap()->begin(), | 790 new_meta_info.insert(node->GetMetaInfoMap()->begin(), |
| 782 node->GetMetaInfoMap()->end()); | 791 node->GetMetaInfoMap()->end()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 859 |
| 851 RedoInfo::Results::Result result; | 860 RedoInfo::Results::Result result; |
| 852 result.enabled = undo_manager->redo_count() > 0; | 861 result.enabled = undo_manager->redo_count() > 0; |
| 853 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 862 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
| 854 | 863 |
| 855 results_ = RedoInfo::Results::Create(result); | 864 results_ = RedoInfo::Results::Create(result); |
| 856 return true; | 865 return true; |
| 857 } | 866 } |
| 858 | 867 |
| 859 } // namespace extensions | 868 } // namespace extensions |
| OLD | NEW |