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

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

Issue 2017113002: [Extensions] DCHECK that ExtensionFunctions respond (and only once) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 EXTENSION_FUNCTION_VALIDATE(params); 455 EXTENSION_FUNCTION_VALIDATE(params);
456 456
457 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 457 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
458 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); 458 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id);
459 if (!CanBeModified(parent_node)) 459 if (!CanBeModified(parent_node))
460 return false; 460 return false;
461 model->SortChildren(parent_node); 461 model->SortChildren(parent_node);
462 return true; 462 return true;
463 } 463 }
464 464
465 bool BookmarkManagerPrivateGetStringsFunction::RunAsync() { 465 ExtensionFunction::ResponseAction
466 BookmarkManagerPrivateGetStringsFunction::Run() {
466 std::unique_ptr<base::DictionaryValue> localized_strings( 467 std::unique_ptr<base::DictionaryValue> localized_strings(
467 new base::DictionaryValue()); 468 new base::DictionaryValue());
468 469
469 localized_strings->SetString("title", 470 localized_strings->SetString("title",
470 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_TITLE)); 471 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_TITLE));
471 localized_strings->SetString("search_button", 472 localized_strings->SetString("search_button",
472 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH_BUTTON)); 473 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH_BUTTON));
473 localized_strings->SetString("folders_menu", 474 localized_strings->SetString("folders_menu",
474 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_FOLDERS_MENU)); 475 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_FOLDERS_MENU));
475 localized_strings->SetString("organize_menu", 476 localized_strings->SetString("organize_menu",
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 localized_strings->SetString("search", 530 localized_strings->SetString("search",
530 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH)); 531 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH));
531 localized_strings->SetString("save", 532 localized_strings->SetString("save",
532 l10n_util::GetStringUTF16(IDS_SAVE)); 533 l10n_util::GetStringUTF16(IDS_SAVE));
533 localized_strings->SetString("cancel", 534 localized_strings->SetString("cancel",
534 l10n_util::GetStringUTF16(IDS_CANCEL)); 535 l10n_util::GetStringUTF16(IDS_CANCEL));
535 536
536 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 537 const std::string& app_locale = g_browser_process->GetApplicationLocale();
537 webui::SetLoadTimeDataDefaults(app_locale, localized_strings.get()); 538 webui::SetLoadTimeDataDefaults(app_locale, localized_strings.get());
538 539
539 SetResult(std::move(localized_strings)); 540 return RespondNow(OneArgument(std::move(localized_strings)));
540
541 // This is needed because unlike the rest of these functions, this class
542 // inherits from AsyncFunction directly, rather than BookmarkFunction.
543 SendResponse(true);
544
545 return true;
546 } 541 }
547 542
548 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() { 543 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() {
549 if (!EditBookmarksEnabled()) 544 if (!EditBookmarksEnabled())
550 return false; 545 return false;
551 546
552 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { 547 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) {
553 NOTREACHED(); 548 NOTREACHED();
554 return false; 549 return false;
555 } 550 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 850
856 RedoInfo::Results::Result result; 851 RedoInfo::Results::Result result;
857 result.enabled = undo_manager->redo_count() > 0; 852 result.enabled = undo_manager->redo_count() > 0;
858 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); 853 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel());
859 854
860 results_ = RedoInfo::Results::Create(result); 855 results_ = RedoInfo::Results::Create(result);
861 return true; 856 return true;
862 } 857 }
863 858
864 } // namespace extensions 859 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698