| 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 "build/build_config.h" | 9 #include "build/build_config.h" |
| 9 #include "chrome/browser/favicon/favicon_service_factory.h" | 10 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 10 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "components/bookmarks/browser/bookmark_model.h" |
| 12 #include "components/bookmarks/browser/bookmark_node.h" | 14 #include "components/bookmarks/browser/bookmark_node.h" |
| 13 #include "components/bookmarks/browser/bookmark_storage.h" | 15 #include "components/bookmarks/browser/bookmark_storage.h" |
| 14 #include "components/bookmarks/managed/managed_bookmark_service.h" | 16 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 15 #include "components/bookmarks/managed/managed_bookmark_util.h" | 17 #include "components/bookmarks/managed/managed_bookmark_util.h" |
| 16 #include "components/favicon/core/favicon_util.h" | 18 #include "components/favicon/core/favicon_util.h" |
| 17 #include "components/history/core/browser/history_service.h" | 19 #include "components/history/core/browser/history_service.h" |
| 18 #include "components/history/core/browser/url_database.h" | 20 #include "components/history/core/browser/url_database.h" |
| 19 #include "content/public/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
| 20 | 22 |
| 23 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 24 #include "chrome/browser/android/offline_pages/offline_page_bookmark_observer.h" |
| 25 #endif |
| 26 |
| 21 ChromeBookmarkClient::ChromeBookmarkClient( | 27 ChromeBookmarkClient::ChromeBookmarkClient( |
| 22 Profile* profile, | 28 Profile* profile, |
| 23 bookmarks::ManagedBookmarkService* managed_bookmark_service) | 29 bookmarks::ManagedBookmarkService* managed_bookmark_service) |
| 24 : profile_(profile), managed_bookmark_service_(managed_bookmark_service) {} | 30 : profile_(profile), managed_bookmark_service_(managed_bookmark_service) {} |
| 25 | 31 |
| 26 ChromeBookmarkClient::~ChromeBookmarkClient() { | 32 ChromeBookmarkClient::~ChromeBookmarkClient() { |
| 27 } | 33 } |
| 28 | 34 |
| 29 void ChromeBookmarkClient::Init(bookmarks::BookmarkModel* model) { | 35 void ChromeBookmarkClient::Init(bookmarks::BookmarkModel* model) { |
| 30 if (managed_bookmark_service_) | 36 if (managed_bookmark_service_) |
| 31 managed_bookmark_service_->BookmarkModelCreated(model); | 37 managed_bookmark_service_->BookmarkModelCreated(model); |
| 38 |
| 39 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 40 offline_page_observer_ = |
| 41 base::MakeUnique<offline_pages::OfflinePageBookmarkObserver>(profile_); |
| 42 model->AddObserver(offline_page_observer_.get()); |
| 43 #endif |
| 32 } | 44 } |
| 33 | 45 |
| 34 bool ChromeBookmarkClient::PreferTouchIcon() { | 46 bool ChromeBookmarkClient::PreferTouchIcon() { |
| 35 return false; | 47 return false; |
| 36 } | 48 } |
| 37 | 49 |
| 38 base::CancelableTaskTracker::TaskId | 50 base::CancelableTaskTracker::TaskId |
| 39 ChromeBookmarkClient::GetFaviconImageForPageURL( | 51 ChromeBookmarkClient::GetFaviconImageForPageURL( |
| 40 const GURL& page_url, | 52 const GURL& page_url, |
| 41 favicon_base::IconType type, | 53 favicon_base::IconType type, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ? true | 122 ? true |
| 111 : managed_bookmark_service_->CanSyncNode(node); | 123 : managed_bookmark_service_->CanSyncNode(node); |
| 112 } | 124 } |
| 113 | 125 |
| 114 bool ChromeBookmarkClient::CanBeEditedByUser( | 126 bool ChromeBookmarkClient::CanBeEditedByUser( |
| 115 const bookmarks::BookmarkNode* node) { | 127 const bookmarks::BookmarkNode* node) { |
| 116 return !managed_bookmark_service_ | 128 return !managed_bookmark_service_ |
| 117 ? true | 129 ? true |
| 118 : managed_bookmark_service_->CanBeEditedByUser(node); | 130 : managed_bookmark_service_->CanBeEditedByUser(node); |
| 119 } | 131 } |
| OLD | NEW |