| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_ANDROID_BOOKMARKS_PARTNER_BOOKMARKS_SHIM_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_BOOKMARKS_PARTNER_BOOKMARKS_SHIM_H_ |
| 6 #define CHROME_BROWSER_ANDROID_BOOKMARKS_PARTNER_BOOKMARKS_SHIM_H_ | 6 #define CHROME_BROWSER_ANDROID_BOOKMARKS_PARTNER_BOOKMARKS_SHIM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class PrefRegistrySyncable; | 26 class PrefRegistrySyncable; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // A shim that lives on top of a BookmarkModel that allows the injection of | 29 // A shim that lives on top of a BookmarkModel that allows the injection of |
| 30 // partner bookmarks without submitting changes to the bookmark model. | 30 // partner bookmarks without submitting changes to the bookmark model. |
| 31 // The shim persists bookmark renames/deletions in a user profile and could be | 31 // The shim persists bookmark renames/deletions in a user profile and could be |
| 32 // queried via shim->GetTitle(node) and shim->IsReachable(node). | 32 // queried via shim->GetTitle(node) and shim->IsReachable(node). |
| 33 // Note that node->GetTitle() returns an original (unmodified) title. | 33 // Note that node->GetTitle() returns an original (unmodified) title. |
| 34 class PartnerBookmarksShim : public base::SupportsUserData::Data { | 34 class PartnerBookmarksShim : public base::SupportsUserData::Data { |
| 35 public: | 35 public: |
| 36 ~PartnerBookmarksShim() override; |
| 37 |
| 36 // Returns an instance of the shim for a given |browser_context|. | 38 // Returns an instance of the shim for a given |browser_context|. |
| 37 static PartnerBookmarksShim* BuildForBrowserContext( | 39 static PartnerBookmarksShim* BuildForBrowserContext( |
| 38 content::BrowserContext* browser_context); | 40 content::BrowserContext* browser_context); |
| 39 | 41 |
| 40 // Registers preferences. | 42 // Registers preferences. |
| 41 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 43 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 42 | 44 |
| 43 // Disables the editing and stops any edits from being applied. | 45 // Disables the editing and stops any edits from being applied. |
| 44 // The user will start to see the original (unedited) partner bookmarks. | 46 // The user will start to see the original (unedited) partner bookmarks. |
| 45 // Edits are stored in the user profile, so once the editing is enabled | 47 // Edits are stored in the user profile, so once the editing is enabled |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 content::BrowserContext* browser_context); | 121 content::BrowserContext* browser_context); |
| 120 | 122 |
| 121 // For testing: clears partner bookmark model data. | 123 // For testing: clears partner bookmark model data. |
| 122 static void ClearPartnerModelForTesting(); | 124 static void ClearPartnerModelForTesting(); |
| 123 | 125 |
| 124 // For testing: re-enables partner bookmarks editing. | 126 // For testing: re-enables partner bookmarks editing. |
| 125 static void EnablePartnerBookmarksEditing(); | 127 static void EnablePartnerBookmarksEditing(); |
| 126 | 128 |
| 127 private: | 129 private: |
| 128 explicit PartnerBookmarksShim(PrefService* prefs); | 130 explicit PartnerBookmarksShim(PrefService* prefs); |
| 129 ~PartnerBookmarksShim() override; | |
| 130 | 131 |
| 131 const bookmarks::BookmarkNode* GetNodeByID( | 132 const bookmarks::BookmarkNode* GetNodeByID( |
| 132 const bookmarks::BookmarkNode* parent, | 133 const bookmarks::BookmarkNode* parent, |
| 133 int64_t id) const; | 134 int64_t id) const; |
| 134 void ReloadNodeMapping(); | 135 void ReloadNodeMapping(); |
| 135 void SaveNodeMapping(); | 136 void SaveNodeMapping(); |
| 136 | 137 |
| 137 std::unique_ptr<bookmarks::BookmarkNode> partner_bookmarks_root_; | 138 std::unique_ptr<bookmarks::BookmarkNode> partner_bookmarks_root_; |
| 138 PrefService* prefs_; | 139 PrefService* prefs_; |
| 139 NodeRenamingMap node_rename_remove_map_; | 140 NodeRenamingMap node_rename_remove_map_; |
| 140 | 141 |
| 141 // The observers. | 142 // The observers. |
| 142 base::ObserverList<Observer> observers_; | 143 base::ObserverList<Observer> observers_; |
| 143 | 144 |
| 144 DISALLOW_COPY_AND_ASSIGN(PartnerBookmarksShim); | 145 DISALLOW_COPY_AND_ASSIGN(PartnerBookmarksShim); |
| 145 }; | 146 }; |
| 146 | 147 |
| 147 #endif // CHROME_BROWSER_ANDROID_BOOKMARKS_PARTNER_BOOKMARKS_SHIM_H_ | 148 #endif // CHROME_BROWSER_ANDROID_BOOKMARKS_PARTNER_BOOKMARKS_SHIM_H_ |
| OLD | NEW |