| 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/test/base/testing_profile.h" | 5 #include "chrome/test/base/testing_profile.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 using testing::NiceMock; | 105 using testing::NiceMock; |
| 106 using testing::Return; | 106 using testing::Return; |
| 107 | 107 |
| 108 namespace { | 108 namespace { |
| 109 | 109 |
| 110 // Used to make sure TopSites has finished loading | 110 // Used to make sure TopSites has finished loading |
| 111 class WaitTopSitesLoadedObserver : public history::TopSitesObserver { | 111 class WaitTopSitesLoadedObserver : public history::TopSitesObserver { |
| 112 public: | 112 public: |
| 113 explicit WaitTopSitesLoadedObserver(content::MessageLoopRunner* runner) | 113 explicit WaitTopSitesLoadedObserver(content::MessageLoopRunner* runner) |
| 114 : runner_(runner) {} | 114 : runner_(runner) {} |
| 115 virtual void TopSitesLoaded(history::TopSites* top_sites) override { | 115 void TopSitesLoaded(history::TopSites* top_sites) override { |
| 116 runner_->Quit(); | 116 runner_->Quit(); |
| 117 } | 117 } |
| 118 virtual void TopSitesChanged(history::TopSites* top_sites) override {} | 118 void TopSitesChanged(history::TopSites* top_sites) override {} |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 // weak | 121 // weak |
| 122 content::MessageLoopRunner* runner_; | 122 content::MessageLoopRunner* runner_; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 // Task used to make sure history has finished processing a request. Intended | 125 // Task used to make sure history has finished processing a request. Intended |
| 126 // for use with BlockUntilHistoryProcessesPendingRequests. | 126 // for use with BlockUntilHistoryProcessesPendingRequests. |
| 127 | 127 |
| 128 class QuittingHistoryDBTask : public history::HistoryDBTask { | 128 class QuittingHistoryDBTask : public history::HistoryDBTask { |
| 129 public: | 129 public: |
| 130 QuittingHistoryDBTask() {} | 130 QuittingHistoryDBTask() {} |
| 131 | 131 |
| 132 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 132 bool RunOnDBThread(history::HistoryBackend* backend, |
| 133 history::HistoryDatabase* db) override { | 133 history::HistoryDatabase* db) override { |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 virtual void DoneRunOnMainThread() override { | 137 void DoneRunOnMainThread() override { base::MessageLoop::current()->Quit(); } |
| 138 base::MessageLoop::current()->Quit(); | |
| 139 } | |
| 140 | 138 |
| 141 private: | 139 private: |
| 142 virtual ~QuittingHistoryDBTask() {} | 140 ~QuittingHistoryDBTask() override {} |
| 143 | 141 |
| 144 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask); | 142 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask); |
| 145 }; | 143 }; |
| 146 | 144 |
| 147 class TestExtensionURLRequestContext : public net::URLRequestContext { | 145 class TestExtensionURLRequestContext : public net::URLRequestContext { |
| 148 public: | 146 public: |
| 149 TestExtensionURLRequestContext() { | 147 TestExtensionURLRequestContext() { |
| 150 net::CookieMonster* cookie_monster = | 148 net::CookieMonster* cookie_monster = |
| 151 content::CreateCookieStore(content::CookieStoreConfig())-> | 149 content::CreateCookieStore(content::CookieStoreConfig())-> |
| 152 GetCookieMonster(); | 150 GetCookieMonster(); |
| 153 const char* const schemes[] = {extensions::kExtensionScheme}; | 151 const char* const schemes[] = {extensions::kExtensionScheme}; |
| 154 cookie_monster->SetCookieableSchemes(schemes, arraysize(schemes)); | 152 cookie_monster->SetCookieableSchemes(schemes, arraysize(schemes)); |
| 155 set_cookie_store(cookie_monster); | 153 set_cookie_store(cookie_monster); |
| 156 } | 154 } |
| 157 | 155 |
| 158 virtual ~TestExtensionURLRequestContext() { | 156 ~TestExtensionURLRequestContext() override { AssertNoURLRequests(); } |
| 159 AssertNoURLRequests(); | |
| 160 } | |
| 161 }; | 157 }; |
| 162 | 158 |
| 163 class TestExtensionURLRequestContextGetter | 159 class TestExtensionURLRequestContextGetter |
| 164 : public net::URLRequestContextGetter { | 160 : public net::URLRequestContextGetter { |
| 165 public: | 161 public: |
| 166 virtual net::URLRequestContext* GetURLRequestContext() override { | 162 net::URLRequestContext* GetURLRequestContext() override { |
| 167 if (!context_.get()) | 163 if (!context_.get()) |
| 168 context_.reset(new TestExtensionURLRequestContext()); | 164 context_.reset(new TestExtensionURLRequestContext()); |
| 169 return context_.get(); | 165 return context_.get(); |
| 170 } | 166 } |
| 171 virtual scoped_refptr<base::SingleThreadTaskRunner> | 167 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| 172 GetNetworkTaskRunner() const override { | 168 const override { |
| 173 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 169 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 174 } | 170 } |
| 175 | 171 |
| 176 protected: | 172 protected: |
| 177 virtual ~TestExtensionURLRequestContextGetter() {} | 173 ~TestExtensionURLRequestContextGetter() override {} |
| 178 | 174 |
| 179 private: | 175 private: |
| 180 scoped_ptr<net::URLRequestContext> context_; | 176 scoped_ptr<net::URLRequestContext> context_; |
| 181 }; | 177 }; |
| 182 | 178 |
| 183 #if defined(ENABLE_NOTIFICATIONS) | 179 #if defined(ENABLE_NOTIFICATIONS) |
| 184 KeyedService* CreateTestDesktopNotificationService( | 180 KeyedService* CreateTestDesktopNotificationService( |
| 185 content::BrowserContext* profile) { | 181 content::BrowserContext* profile) { |
| 186 return new DesktopNotificationService(static_cast<Profile*>(profile)); | 182 return new DesktopNotificationService(static_cast<Profile*>(profile)); |
| 187 } | 183 } |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 #if defined(ENABLE_EXTENSIONS) | 1029 #if defined(ENABLE_EXTENSIONS) |
| 1034 extension_policy_, | 1030 extension_policy_, |
| 1035 #endif | 1031 #endif |
| 1036 pref_service_.Pass(), | 1032 pref_service_.Pass(), |
| 1037 original_profile, | 1033 original_profile, |
| 1038 guest_session_, | 1034 guest_session_, |
| 1039 supervised_user_id_, | 1035 supervised_user_id_, |
| 1040 policy_service_.Pass(), | 1036 policy_service_.Pass(), |
| 1041 testing_factories_); | 1037 testing_factories_); |
| 1042 } | 1038 } |
| OLD | NEW |