| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 SkBitmap FinalizeLauncherIconInBackground(const SkBitmap& icon, | 126 SkBitmap FinalizeLauncherIconInBackground(const SkBitmap& icon, |
| 127 const GURL& url, | 127 const GURL& url, |
| 128 bool* is_generated) override { | 128 bool* is_generated) override { |
| 129 *is_generated = false; | 129 *is_generated = false; |
| 130 return icon; | 130 return icon; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void OnDataAvailable(const ShortcutInfo& info, | 133 void OnDataAvailable(const ShortcutInfo& info, |
| 134 const SkBitmap& icon) override { | 134 const SkBitmap& primary_icon, |
| 135 const SkBitmap& badge_icon) override { |
| 135 data_available_ = true; | 136 data_available_ = true; |
| 136 if (!quit_closure_.is_null()) | 137 if (!quit_closure_.is_null()) |
| 137 quit_closure_.Run(); | 138 quit_closure_.Run(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 bool is_webapk_compatible() const { return is_webapk_compatible_; } | 141 bool is_webapk_compatible() const { return is_webapk_compatible_; } |
| 141 bool determined_webapk_compatibility() const { | 142 bool determined_webapk_compatibility() const { |
| 142 return determined_webapk_compatibility_; | 143 return determined_webapk_compatibility_; |
| 143 } | 144 } |
| 144 bool title_available() const { return title_available_; } | 145 bool title_available() const { return title_available_; } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 197 } |
| 197 | 198 |
| 198 void TearDown() override { | 199 void TearDown() override { |
| 199 embedded_worker_test_helper_.reset(); | 200 embedded_worker_test_helper_.reset(); |
| 200 ChromeRenderViewHostTestHarness::TearDown(); | 201 ChromeRenderViewHostTestHarness::TearDown(); |
| 201 } | 202 } |
| 202 | 203 |
| 203 scoped_refptr<AddToHomescreenDataFetcher> BuildFetcher( | 204 scoped_refptr<AddToHomescreenDataFetcher> BuildFetcher( |
| 204 bool check_webapk_compatible, | 205 bool check_webapk_compatible, |
| 205 AddToHomescreenDataFetcher::Observer* observer) { | 206 AddToHomescreenDataFetcher::Observer* observer) { |
| 206 return new AddToHomescreenDataFetcher(web_contents(), 1, 1, 1, 1, | 207 return new AddToHomescreenDataFetcher(web_contents(), 1, 1, 1, 1, 1, |
| 207 check_webapk_compatible, observer); | 208 check_webapk_compatible, observer); |
| 208 } | 209 } |
| 209 | 210 |
| 210 // Set the manifest to be returned as a result of WebContents::GetManifest(). | 211 // Set the manifest to be returned as a result of WebContents::GetManifest(). |
| 211 void SetManifest(const GURL& manifest_url, | 212 void SetManifest(const GURL& manifest_url, |
| 212 const content::Manifest& manifest, | 213 const content::Manifest& manifest, |
| 213 int fetch_delay_ms) { | 214 int fetch_delay_ms) { |
| 214 MockWebContents* mock_web_contents = | 215 MockWebContents* mock_web_contents = |
| 215 static_cast<MockWebContents*>(web_contents()); | 216 static_cast<MockWebContents*>(web_contents()); |
| 216 mock_web_contents->SetManifest(manifest_url, manifest, fetch_delay_ms); | 217 mock_web_contents->SetManifest(manifest_url, manifest, fetch_delay_ms); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 359 } |
| 359 // This callback enables the text field in the add-to-homescreen dialog. | 360 // This callback enables the text field in the add-to-homescreen dialog. |
| 360 EXPECT_TRUE(waiter.title_available()); | 361 EXPECT_TRUE(waiter.title_available()); |
| 361 | 362 |
| 362 fetcher->set_weak_observer(nullptr); | 363 fetcher->set_weak_observer(nullptr); |
| 363 } | 364 } |
| 364 | 365 |
| 365 INSTANTIATE_TEST_CASE_P(CheckWebApkCompatibility, | 366 INSTANTIATE_TEST_CASE_P(CheckWebApkCompatibility, |
| 366 AddToHomescreenDataFetcherTestCommon, | 367 AddToHomescreenDataFetcherTestCommon, |
| 367 ::testing::Values(false, true)); | 368 ::testing::Values(false, true)); |
| OLD | NEW |