OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bookmarks/chrome_bookmark_client.h" | 5 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/metrics/user_metrics.h" | 9 #include "base/metrics/user_metrics.h" |
| 10 #include "base/sys_info.h" |
10 #include "chrome/browser/favicon/favicon_service_factory.h" | 11 #include "chrome/browser/favicon/favicon_service_factory.h" |
11 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
14 #include "components/bookmarks/browser/bookmark_node.h" | 15 #include "components/bookmarks/browser/bookmark_node.h" |
15 #include "components/bookmarks/browser/bookmark_storage.h" | 16 #include "components/bookmarks/browser/bookmark_storage.h" |
16 #include "components/bookmarks/managed/managed_bookmark_service.h" | 17 #include "components/bookmarks/managed/managed_bookmark_service.h" |
17 #include "components/bookmarks/managed/managed_bookmark_util.h" | 18 #include "components/bookmarks/managed/managed_bookmark_util.h" |
18 #include "components/favicon/core/favicon_util.h" | 19 #include "components/favicon/core/favicon_util.h" |
19 #include "components/history/core/browser/history_service.h" | 20 #include "components/history/core/browser/history_service.h" |
20 #include "components/history/core/browser/url_database.h" | 21 #include "components/history/core/browser/url_database.h" |
21 | 22 |
22 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
23 #include "chrome/browser/android/offline_pages/offline_page_bookmark_observer.h" | 24 #include "chrome/browser/android/offline_pages/offline_page_bookmark_observer.h" |
24 #endif | 25 #endif |
25 | 26 |
| 27 namespace { |
| 28 // Optional keys present in MetaInfo maps in bookmark nodes to load in memory. |
| 29 const char* const kOptionalMetakeys[] = {"imageData", "pageData"}; |
| 30 } // namespace |
| 31 |
26 ChromeBookmarkClient::ChromeBookmarkClient( | 32 ChromeBookmarkClient::ChromeBookmarkClient( |
27 Profile* profile, | 33 Profile* profile, |
28 bookmarks::ManagedBookmarkService* managed_bookmark_service) | 34 bookmarks::ManagedBookmarkService* managed_bookmark_service) |
29 : profile_(profile), managed_bookmark_service_(managed_bookmark_service) {} | 35 : profile_(profile), managed_bookmark_service_(managed_bookmark_service) {} |
30 | 36 |
31 ChromeBookmarkClient::~ChromeBookmarkClient() { | 37 ChromeBookmarkClient::~ChromeBookmarkClient() { |
32 } | 38 } |
33 | 39 |
34 void ChromeBookmarkClient::Init(bookmarks::BookmarkModel* model) { | 40 void ChromeBookmarkClient::Init(bookmarks::BookmarkModel* model) { |
35 if (managed_bookmark_service_) | 41 if (managed_bookmark_service_) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 ? true | 126 ? true |
121 : managed_bookmark_service_->CanSyncNode(node); | 127 : managed_bookmark_service_->CanSyncNode(node); |
122 } | 128 } |
123 | 129 |
124 bool ChromeBookmarkClient::CanBeEditedByUser( | 130 bool ChromeBookmarkClient::CanBeEditedByUser( |
125 const bookmarks::BookmarkNode* node) { | 131 const bookmarks::BookmarkNode* node) { |
126 return !managed_bookmark_service_ | 132 return !managed_bookmark_service_ |
127 ? true | 133 ? true |
128 : managed_bookmark_service_->CanBeEditedByUser(node); | 134 : managed_bookmark_service_->CanBeEditedByUser(node); |
129 } | 135 } |
| 136 |
| 137 std::vector<std::string> ChromeBookmarkClient::ExecludedMetaKeys() { |
| 138 std::vector<std::string> optional_keys; |
| 139 // Do not load the image and page data into memory for low-end devices. |
| 140 if (base::SysInfo::IsLowEndDevice()) { |
| 141 optional_keys.insert(optional_keys.end(), std::begin(kOptionalMetakeys), |
| 142 std::end(kOptionalMetakeys)); |
| 143 } |
| 144 return optional_keys; |
| 145 } |
OLD | NEW |