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

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: UTF16ToUTF8 moved to base namespace Created 6 years, 11 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 <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 26 matching lines...) Expand all
48 namespace bookmark_keys = bookmark_api_constants; 49 namespace bookmark_keys = bookmark_api_constants;
49 namespace bookmark_manager_private = api::bookmark_manager_private; 50 namespace bookmark_manager_private = api::bookmark_manager_private;
50 namespace CanPaste = api::bookmark_manager_private::CanPaste; 51 namespace CanPaste = api::bookmark_manager_private::CanPaste;
51 namespace Copy = api::bookmark_manager_private::Copy; 52 namespace Copy = api::bookmark_manager_private::Copy;
52 namespace Cut = api::bookmark_manager_private::Cut; 53 namespace Cut = api::bookmark_manager_private::Cut;
53 namespace Drop = api::bookmark_manager_private::Drop; 54 namespace Drop = api::bookmark_manager_private::Drop;
54 namespace GetSubtree = api::bookmark_manager_private::GetSubtree; 55 namespace GetSubtree = api::bookmark_manager_private::GetSubtree;
55 namespace manager_keys = bookmark_manager_api_constants; 56 namespace manager_keys = bookmark_manager_api_constants;
56 namespace GetMetaInfo = api::bookmark_manager_private::GetMetaInfo; 57 namespace GetMetaInfo = api::bookmark_manager_private::GetMetaInfo;
57 namespace Paste = api::bookmark_manager_private::Paste; 58 namespace Paste = api::bookmark_manager_private::Paste;
59 namespace RedoInfo = api::bookmark_manager_private::GetRedoInfo;
58 namespace RemoveTrees = api::bookmark_manager_private::RemoveTrees; 60 namespace RemoveTrees = api::bookmark_manager_private::RemoveTrees;
59 namespace SetMetaInfo = api::bookmark_manager_private::SetMetaInfo; 61 namespace SetMetaInfo = api::bookmark_manager_private::SetMetaInfo;
60 namespace SortChildren = api::bookmark_manager_private::SortChildren; 62 namespace SortChildren = api::bookmark_manager_private::SortChildren;
61 namespace StartDrag = api::bookmark_manager_private::StartDrag; 63 namespace StartDrag = api::bookmark_manager_private::StartDrag;
64 namespace UndoInfo = api::bookmark_manager_private::GetUndoInfo;
62 65
63 using content::WebContents; 66 using content::WebContents;
64 67
65 namespace { 68 namespace {
66 69
67 // Returns a single bookmark node from the argument ID. 70 // Returns a single bookmark node from the argument ID.
68 // This returns NULL in case of failure. 71 // This returns NULL in case of failure.
69 const BookmarkNode* GetNodeFromString( 72 const BookmarkNode* GetNodeFromString(
70 BookmarkModel* model, const std::string& id_string) { 73 BookmarkModel* model, const std::string& id_string) {
71 int64 id; 74 int64 id;
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 for (size_t i = 0; i < params->id_list.size(); ++i) { 577 for (size_t i = 0; i < params->id_list.size(); ++i) {
575 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) 578 if (!GetBookmarkIdAsInt64(params->id_list[i], &id))
576 return false; 579 return false;
577 if (!bookmark_api_helpers::RemoveNode(model, id, true, &error_)) 580 if (!bookmark_api_helpers::RemoveNode(model, id, true, &error_))
578 return false; 581 return false;
579 } 582 }
580 583
581 return true; 584 return true;
582 } 585 }
583 586
587 bool BookmarkManagerPrivateUndoFunction::RunImpl() {
588 #if !defined(OS_ANDROID)
589 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()->
590 Undo();
591 #endif
592
593 return true;
594 }
595
596 bool BookmarkManagerPrivateRedoFunction::RunImpl() {
597 #if !defined(OS_ANDROID)
598 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()->
599 Redo();
600 #endif
601
602 return true;
603 }
604
605 bool BookmarkManagerPrivateGetUndoInfoFunction::RunImpl() {
606 #if !defined(OS_ANDROID)
607 UndoManager* undo_manager =
608 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager();
609
610 UndoInfo::Results::Result result;
611 result.enabled = undo_manager->undo_count() > 0;
612 result.label = base::UTF16ToUTF8(undo_manager->GetUndoLabel());
613
614 results_ = UndoInfo::Results::Create(result);
615 #endif // !defined(OS_ANDROID)
616
617 return true;
618 }
619
620 bool BookmarkManagerPrivateGetRedoInfoFunction::RunImpl() {
621 #if !defined(OS_ANDROID)
622 UndoManager* undo_manager =
623 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager();
624
625 RedoInfo::Results::Result result;
626 result.enabled = undo_manager->redo_count() > 0;
627 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel());
628
629 results_ = RedoInfo::Results::Create(result);
630 #endif // !defined(OS_ANDROID)
631
632 return true;
633 }
634
584 } // namespace extensions 635 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698