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

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

Issue 119233004: Add multi-level undo/redo functions to Bookmark Manager Private API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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 <vector> 7 #include <vector>
8 8
9 #include "base/memory/linked_ptr.h" 9 #include "base/memory/linked_ptr.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/bookmarks/bookmark_model.h" 14 #include "chrome/browser/bookmarks/bookmark_model.h"
14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
15 #include "chrome/browser/bookmarks/bookmark_node_data.h" 16 #include "chrome/browser/bookmarks/bookmark_node_data.h"
16 #include "chrome/browser/bookmarks/bookmark_stats.h" 17 #include "chrome/browser/bookmarks/bookmark_stats.h"
17 #include "chrome/browser/bookmarks/bookmark_utils.h" 18 #include "chrome/browser/bookmarks/bookmark_utils.h"
18 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api_constants.h" 19 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api_constants.h"
19 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h" 20 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h"
20 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h" 21 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h"
21 #include "chrome/browser/extensions/extension_function_dispatcher.h" 22 #include "chrome/browser/extensions/extension_function_dispatcher.h"
(...skipping 23 matching lines...) Expand all
45 namespace bookmark_keys = bookmark_api_constants; 46 namespace bookmark_keys = bookmark_api_constants;
46 namespace bookmark_manager_private = api::bookmark_manager_private; 47 namespace bookmark_manager_private = api::bookmark_manager_private;
47 namespace CanPaste = api::bookmark_manager_private::CanPaste; 48 namespace CanPaste = api::bookmark_manager_private::CanPaste;
48 namespace Copy = api::bookmark_manager_private::Copy; 49 namespace Copy = api::bookmark_manager_private::Copy;
49 namespace Cut = api::bookmark_manager_private::Cut; 50 namespace Cut = api::bookmark_manager_private::Cut;
50 namespace Drop = api::bookmark_manager_private::Drop; 51 namespace Drop = api::bookmark_manager_private::Drop;
51 namespace GetSubtree = api::bookmark_manager_private::GetSubtree; 52 namespace GetSubtree = api::bookmark_manager_private::GetSubtree;
52 namespace manager_keys = bookmark_manager_api_constants; 53 namespace manager_keys = bookmark_manager_api_constants;
53 namespace GetMetaInfo = api::bookmark_manager_private::GetMetaInfo; 54 namespace GetMetaInfo = api::bookmark_manager_private::GetMetaInfo;
54 namespace Paste = api::bookmark_manager_private::Paste; 55 namespace Paste = api::bookmark_manager_private::Paste;
56 namespace RedoInfo = api::bookmark_manager_private::GetRedoInfo;
55 namespace RemoveTrees = api::bookmark_manager_private::RemoveTrees; 57 namespace RemoveTrees = api::bookmark_manager_private::RemoveTrees;
56 namespace SetMetaInfo = api::bookmark_manager_private::SetMetaInfo; 58 namespace SetMetaInfo = api::bookmark_manager_private::SetMetaInfo;
57 namespace SortChildren = api::bookmark_manager_private::SortChildren; 59 namespace SortChildren = api::bookmark_manager_private::SortChildren;
58 namespace StartDrag = api::bookmark_manager_private::StartDrag; 60 namespace StartDrag = api::bookmark_manager_private::StartDrag;
61 namespace UndoInfo = api::bookmark_manager_private::GetUndoInfo;
59 62
60 using content::WebContents; 63 using content::WebContents;
61 64
62 namespace { 65 namespace {
63 66
64 // Returns a single bookmark node from the argument ID. 67 // Returns a single bookmark node from the argument ID.
65 // This returns NULL in case of failure. 68 // This returns NULL in case of failure.
66 const BookmarkNode* GetNodeFromString( 69 const BookmarkNode* GetNodeFromString(
67 BookmarkModel* model, const std::string& id_string) { 70 BookmarkModel* model, const std::string& id_string) {
68 int64 id; 71 int64 id;
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 for (size_t i = 0; i < params->id_list.size(); ++i) { 570 for (size_t i = 0; i < params->id_list.size(); ++i) {
568 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) 571 if (!GetBookmarkIdAsInt64(params->id_list[i], &id))
569 return false; 572 return false;
570 if (!bookmark_api_helpers::RemoveNode(model, id, true, &error_)) 573 if (!bookmark_api_helpers::RemoveNode(model, id, true, &error_))
571 return false; 574 return false;
572 } 575 }
573 576
574 return true; 577 return true;
575 } 578 }
576 579
580 bool BookmarkManagerPrivateUndoFunction::RunImpl() {
581 #if !defined(OS_ANDROID)
582 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()->
583 Undo();
584 #endif
585
586 return true;
587 }
588
589 bool BookmarkManagerPrivateRedoFunction::RunImpl() {
590 #if !defined(OS_ANDROID)
591 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()->
592 Redo();
arv (Not doing code reviews) 2014/01/06 15:26:45 wrong indentation
Tom Cassiotis 2014/01/06 23:28:21 Done.
593 #endif
594
595 return true;
596 }
597
598 bool BookmarkManagerPrivateGetUndoInfoFunction::RunImpl() {
599 #if !defined(OS_ANDROID)
600 UndoManager* undo_manager =
601 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager();
602
603 UndoInfo::Results::Result result;
604 result.enabled = undo_manager->undo_count() > 0;
605 result.label = UTF16ToUTF8(undo_manager->GetUndoLabel());
606
607 results_ = UndoInfo::Results::Create(result);
608 #endif // !defined(OS_ANDROID)
609
610 return true;
611 }
612
613 bool BookmarkManagerPrivateGetRedoInfoFunction::RunImpl() {
614 #if !defined(OS_ANDROID)
615 UndoManager* undo_manager =
616 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager();
arv (Not doing code reviews) 2014/01/06 15:26:45 indentation
Tom Cassiotis 2014/01/06 23:28:21 Done.
617
618 RedoInfo::Results::Result result;
619 result.enabled = undo_manager->redo_count() > 0;
620 result.label = UTF16ToUTF8(undo_manager->GetRedoLabel());
621
622 results_ = RedoInfo::Results::Create(result);
623 #endif // !defined(OS_ANDROID)
624
625 return true;
626 }
627
577 } // namespace extensions 628 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698