| OLD | NEW |
| 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/history/android/android_provider_backend.h" | 5 #include "chrome/browser/history/android/android_provider_backend.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model.h" | 15 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_service.h" | 17 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 18 #include "chrome/browser/favicon/favicon_changed_details.h" |
| 18 #include "chrome/browser/history/android/android_time.h" | 19 #include "chrome/browser/history/android/android_time.h" |
| 19 #include "chrome/browser/history/history_backend.h" | 20 #include "chrome/browser/history/history_backend.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 25 #include "chrome/test/base/testing_profile_manager.h" | 26 #include "chrome/test/base/testing_profile_manager.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 sql::InitStatus init_status) OVERRIDE {} | 61 sql::InitStatus init_status) OVERRIDE {} |
| 61 virtual void SetInMemoryBackend(int backend_id, | 62 virtual void SetInMemoryBackend(int backend_id, |
| 62 InMemoryHistoryBackend* backend) OVERRIDE {} | 63 InMemoryHistoryBackend* backend) OVERRIDE {} |
| 63 virtual void BroadcastNotifications(int type, | 64 virtual void BroadcastNotifications(int type, |
| 64 HistoryDetails* details) OVERRIDE { | 65 HistoryDetails* details) OVERRIDE { |
| 65 switch (type) { | 66 switch (type) { |
| 66 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: | 67 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: |
| 67 deleted_details_.reset(static_cast<URLsDeletedDetails*>(details)); | 68 deleted_details_.reset(static_cast<URLsDeletedDetails*>(details)); |
| 68 break; | 69 break; |
| 69 case chrome::NOTIFICATION_FAVICON_CHANGED: | 70 case chrome::NOTIFICATION_FAVICON_CHANGED: |
| 70 favicon_details_.reset(static_cast<FaviconChangeDetails*>(details)); | 71 favicon_details_.reset(static_cast<FaviconChangedDetails*>(details)); |
| 71 break; | 72 break; |
| 72 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: | 73 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: |
| 73 modified_details_.reset(static_cast<URLsModifiedDetails*>(details)); | 74 modified_details_.reset(static_cast<URLsModifiedDetails*>(details)); |
| 74 break; | 75 break; |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 virtual void DBLoaded(int backend_id) OVERRIDE {} | 78 virtual void DBLoaded(int backend_id) OVERRIDE {} |
| 78 virtual void StartTopSitesMigration(int backend_id) OVERRIDE {} | 79 virtual void StartTopSitesMigration(int backend_id) OVERRIDE {} |
| 79 virtual void NotifyVisitDBObserversOnAddVisit( | 80 virtual void NotifyVisitDBObserversOnAddVisit( |
| 80 const history::BriefVisitInfo& info) OVERRIDE {} | 81 const history::BriefVisitInfo& info) OVERRIDE {} |
| 81 | 82 |
| 82 URLsDeletedDetails* deleted_details() const { | 83 URLsDeletedDetails* deleted_details() const { |
| 83 return deleted_details_.get(); | 84 return deleted_details_.get(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 URLsModifiedDetails* modified_details() const { | 87 URLsModifiedDetails* modified_details() const { |
| 87 return modified_details_.get(); | 88 return modified_details_.get(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 FaviconChangeDetails* favicon_details() const { | 91 FaviconChangedDetails* favicon_details() const { |
| 91 return favicon_details_.get(); | 92 return favicon_details_.get(); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void ResetDetails() { | 95 void ResetDetails() { |
| 95 deleted_details_.reset(); | 96 deleted_details_.reset(); |
| 96 modified_details_.reset(); | 97 modified_details_.reset(); |
| 97 favicon_details_.reset(); | 98 favicon_details_.reset(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 private: | 101 private: |
| 101 scoped_ptr<URLsDeletedDetails> deleted_details_; | 102 scoped_ptr<URLsDeletedDetails> deleted_details_; |
| 102 scoped_ptr<URLsModifiedDetails> modified_details_; | 103 scoped_ptr<URLsModifiedDetails> modified_details_; |
| 103 scoped_ptr<FaviconChangeDetails> favicon_details_; | 104 scoped_ptr<FaviconChangedDetails> favicon_details_; |
| 104 | 105 |
| 105 DISALLOW_COPY_AND_ASSIGN(AndroidProviderBackendDelegate); | 106 DISALLOW_COPY_AND_ASSIGN(AndroidProviderBackendDelegate); |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 class AndroidProviderBackendTest : public testing::Test { | 109 class AndroidProviderBackendTest : public testing::Test { |
| 109 public: | 110 public: |
| 110 AndroidProviderBackendTest() | 111 AndroidProviderBackendTest() |
| 111 : profile_manager_( | 112 : profile_manager_( |
| 112 TestingBrowserProcess::GetGlobal()), | 113 TestingBrowserProcess::GetGlobal()), |
| 113 bookmark_model_(NULL), | 114 bookmark_model_(NULL), |
| (...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 update_args, &update_count)); | 2071 update_args, &update_count)); |
| 2071 // Verify notifications. | 2072 // Verify notifications. |
| 2072 EXPECT_FALSE(delegate_.deleted_details()); | 2073 EXPECT_FALSE(delegate_.deleted_details()); |
| 2073 ASSERT_TRUE(delegate_.modified_details()); | 2074 ASSERT_TRUE(delegate_.modified_details()); |
| 2074 ASSERT_EQ(1u, delegate_.modified_details()->changed_urls.size()); | 2075 ASSERT_EQ(1u, delegate_.modified_details()->changed_urls.size()); |
| 2075 // No favicon will be updated as thumbnail database is missing. | 2076 // No favicon will be updated as thumbnail database is missing. |
| 2076 EXPECT_FALSE(delegate_.favicon_details()); | 2077 EXPECT_FALSE(delegate_.favicon_details()); |
| 2077 } | 2078 } |
| 2078 | 2079 |
| 2079 } // namespace history | 2080 } // namespace history |
| OLD | NEW |