| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/android/webapps/add_to_homescreen_data_fetcher.h" | 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 MockWebContents* mock_web_contents = | 218 MockWebContents* mock_web_contents = |
| 219 static_cast<MockWebContents*>(web_contents()); | 219 static_cast<MockWebContents*>(web_contents()); |
| 220 mock_web_contents->SetManifest(manifest_url, manifest, fetch_delay_ms); | 220 mock_web_contents->SetManifest(manifest_url, manifest, fetch_delay_ms); |
| 221 } | 221 } |
| 222 | 222 |
| 223 // Registers service worker at |url|. Blocks till the service worker is | 223 // Registers service worker at |url|. Blocks till the service worker is |
| 224 // registered. | 224 // registered. |
| 225 void RegisterServiceWorker(const GURL& url) { | 225 void RegisterServiceWorker(const GURL& url) { |
| 226 base::RunLoop run_loop; | 226 base::RunLoop run_loop; |
| 227 embedded_worker_test_helper_->context()->RegisterServiceWorker( | 227 embedded_worker_test_helper_->context()->RegisterServiceWorker( |
| 228 url, GURL(url.spec() + "/service_worker.js"), nullptr, | 228 GURL(url.spec() + "/service_worker.js"), |
| 229 content::ServiceWorkerRegistrationOptions(url), nullptr, |
| 229 base::Bind(&AddToHomescreenDataFetcherTest::OnServiceWorkerRegistered, | 230 base::Bind(&AddToHomescreenDataFetcherTest::OnServiceWorkerRegistered, |
| 230 base::Unretained(this), run_loop.QuitClosure())); | 231 base::Unretained(this), run_loop.QuitClosure())); |
| 231 } | 232 } |
| 232 | 233 |
| 233 private: | 234 private: |
| 234 // Callback for RegisterServiceWorker() for when service worker registration | 235 // Callback for RegisterServiceWorker() for when service worker registration |
| 235 // has completed. | 236 // has completed. |
| 236 void OnServiceWorkerRegistered(const base::Closure& callback, | 237 void OnServiceWorkerRegistered(const base::Closure& callback, |
| 237 content::ServiceWorkerStatusCode status, | 238 content::ServiceWorkerStatusCode status, |
| 238 const std::string& status_message, | 239 const std::string& status_message, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 363 } |
| 363 // This callback enables the text field in the add-to-homescreen dialog. | 364 // This callback enables the text field in the add-to-homescreen dialog. |
| 364 EXPECT_TRUE(waiter.title_available()); | 365 EXPECT_TRUE(waiter.title_available()); |
| 365 | 366 |
| 366 fetcher->set_weak_observer(nullptr); | 367 fetcher->set_weak_observer(nullptr); |
| 367 } | 368 } |
| 368 | 369 |
| 369 INSTANTIATE_TEST_CASE_P(CheckWebApkCompatibility, | 370 INSTANTIATE_TEST_CASE_P(CheckWebApkCompatibility, |
| 370 AddToHomescreenDataFetcherTestCommon, | 371 AddToHomescreenDataFetcherTestCommon, |
| 371 ::testing::Values(false, true)); | 372 ::testing::Values(false, true)); |
| OLD | NEW |