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

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

Issue 1991083002: Remove ExtensionFunction::SetResult(T*) overload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU Created 4 years, 7 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
10 #include <memory>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
16 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 20 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 bookmarks::PasteFromClipboard(model, parent_node, highest_index); 424 bookmarks::PasteFromClipboard(model, parent_node, highest_index);
424 return true; 425 return true;
425 } 426 }
426 427
427 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() { 428 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() {
428 std::unique_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); 429 std::unique_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_));
429 EXTENSION_FUNCTION_VALIDATE(params); 430 EXTENSION_FUNCTION_VALIDATE(params);
430 431
431 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); 432 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile());
432 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) { 433 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) {
433 SetResult(new base::FundamentalValue(false)); 434 SetResult(base::MakeUnique<base::FundamentalValue>(false));
434 return true; 435 return true;
435 } 436 }
436 437
437 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 438 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
438 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); 439 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id);
439 if (!parent_node) { 440 if (!parent_node) {
440 error_ = bookmark_keys::kNoParentError; 441 error_ = bookmark_keys::kNoParentError;
441 return false; 442 return false;
442 } 443 }
443 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); 444 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node);
444 SetResult(new base::FundamentalValue(can_paste)); 445 SetResult(base::MakeUnique<base::FundamentalValue>(can_paste));
445 return true; 446 return true;
446 } 447 }
447 448
448 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() { 449 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() {
449 if (!EditBookmarksEnabled()) 450 if (!EditBookmarksEnabled())
450 return false; 451 return false;
451 452
452 std::unique_ptr<SortChildren::Params> params( 453 std::unique_ptr<SortChildren::Params> params(
453 SortChildren::Params::Create(*args_)); 454 SortChildren::Params::Create(*args_));
454 EXTENSION_FUNCTION_VALIDATE(params); 455 EXTENSION_FUNCTION_VALIDATE(params);
455 456
456 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 457 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
457 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); 458 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id);
458 if (!CanBeModified(parent_node)) 459 if (!CanBeModified(parent_node))
459 return false; 460 return false;
460 model->SortChildren(parent_node); 461 model->SortChildren(parent_node);
461 return true; 462 return true;
462 } 463 }
463 464
464 bool BookmarkManagerPrivateGetStringsFunction::RunAsync() { 465 bool BookmarkManagerPrivateGetStringsFunction::RunAsync() {
465 base::DictionaryValue* localized_strings = new base::DictionaryValue(); 466 std::unique_ptr<base::DictionaryValue> localized_strings(
467 new base::DictionaryValue());
466 468
467 localized_strings->SetString("title", 469 localized_strings->SetString("title",
468 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_TITLE)); 470 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_TITLE));
469 localized_strings->SetString("search_button", 471 localized_strings->SetString("search_button",
470 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH_BUTTON)); 472 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH_BUTTON));
471 localized_strings->SetString("folders_menu", 473 localized_strings->SetString("folders_menu",
472 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_FOLDERS_MENU)); 474 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_FOLDERS_MENU));
473 localized_strings->SetString("organize_menu", 475 localized_strings->SetString("organize_menu",
474 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_ORGANIZE_MENU)); 476 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_ORGANIZE_MENU));
475 localized_strings->SetString("show_in_folder", 477 localized_strings->SetString("show_in_folder",
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 localized_strings->SetString("recent", 527 localized_strings->SetString("recent",
526 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_RECENT)); 528 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_RECENT));
527 localized_strings->SetString("search", 529 localized_strings->SetString("search",
528 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH)); 530 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH));
529 localized_strings->SetString("save", 531 localized_strings->SetString("save",
530 l10n_util::GetStringUTF16(IDS_SAVE)); 532 l10n_util::GetStringUTF16(IDS_SAVE));
531 localized_strings->SetString("cancel", 533 localized_strings->SetString("cancel",
532 l10n_util::GetStringUTF16(IDS_CANCEL)); 534 l10n_util::GetStringUTF16(IDS_CANCEL));
533 535
534 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 536 const std::string& app_locale = g_browser_process->GetApplicationLocale();
535 webui::SetLoadTimeDataDefaults(app_locale, localized_strings); 537 webui::SetLoadTimeDataDefaults(app_locale, localized_strings.get());
536 538
537 SetResult(localized_strings); 539 SetResult(std::move(localized_strings));
538 540
539 // This is needed because unlike the rest of these functions, this class 541 // This is needed because unlike the rest of these functions, this class
540 // inherits from AsyncFunction directly, rather than BookmarkFunction. 542 // inherits from AsyncFunction directly, rather than BookmarkFunction.
541 SendResponse(true); 543 SendResponse(true);
542 544
543 return true; 545 return true;
544 } 546 }
545 547
546 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() { 548 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() {
547 if (!EditBookmarksEnabled()) 549 if (!EditBookmarksEnabled())
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 if (params->folders_only) 643 if (params->folders_only)
642 bookmark_api_helpers::AddNodeFoldersOnly(managed, node, &nodes, true); 644 bookmark_api_helpers::AddNodeFoldersOnly(managed, node, &nodes, true);
643 else 645 else
644 bookmark_api_helpers::AddNode(managed, node, &nodes, true); 646 bookmark_api_helpers::AddNode(managed, node, &nodes, true);
645 results_ = GetSubtree::Results::Create(nodes); 647 results_ = GetSubtree::Results::Create(nodes);
646 return true; 648 return true;
647 } 649 }
648 650
649 bool BookmarkManagerPrivateCanEditFunction::RunOnReady() { 651 bool BookmarkManagerPrivateCanEditFunction::RunOnReady() {
650 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); 652 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile());
651 SetResult(new base::FundamentalValue( 653 SetResult(base::MakeUnique<base::FundamentalValue>(
652 prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled))); 654 prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)));
653 return true; 655 return true;
654 } 656 }
655 657
656 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() { 658 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() {
657 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); 659 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER);
658 return true; 660 return true;
659 } 661 }
660 662
661 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { 663 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 new_meta_info.insert(node->GetMetaInfoMap()->begin(), 786 new_meta_info.insert(node->GetMetaInfoMap()->begin(),
785 node->GetMetaInfoMap()->end()); 787 node->GetMetaInfoMap()->end());
786 } 788 }
787 model->SetNodeMetaInfoMap(node, new_meta_info); 789 model->SetNodeMetaInfoMap(node, new_meta_info);
788 790
789 return true; 791 return true;
790 } 792 }
791 793
792 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunOnReady() { 794 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunOnReady() {
793 bool can_open_new_windows = true; 795 bool can_open_new_windows = true;
794 SetResult(new base::FundamentalValue(can_open_new_windows)); 796 SetResult(base::MakeUnique<base::FundamentalValue>(can_open_new_windows));
795 return true; 797 return true;
796 } 798 }
797 799
798 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() { 800 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() {
799 if (!EditBookmarksEnabled()) 801 if (!EditBookmarksEnabled())
800 return false; 802 return false;
801 803
802 std::unique_ptr<RemoveTrees::Params> params( 804 std::unique_ptr<RemoveTrees::Params> params(
803 RemoveTrees::Params::Create(*args_)); 805 RemoveTrees::Params::Create(*args_));
804 EXTENSION_FUNCTION_VALIDATE(params); 806 EXTENSION_FUNCTION_VALIDATE(params);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 855
854 RedoInfo::Results::Result result; 856 RedoInfo::Results::Result result;
855 result.enabled = undo_manager->redo_count() > 0; 857 result.enabled = undo_manager->redo_count() > 0;
856 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); 858 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel());
857 859
858 results_ = RedoInfo::Results::Create(result); 860 results_ = RedoInfo::Results::Create(result);
859 return true; 861 return true;
860 } 862 }
861 863
862 } // namespace extensions 864 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698