OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/favicon/core/large_icon_service.h" | 5 #include "components/favicon/core/large_icon_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 if (!server_request_url.is_valid() || !trimmed_page_url.is_valid() || | 332 if (!server_request_url.is_valid() || !trimmed_page_url.is_valid() || |
333 !image_fetcher_ || | 333 !image_fetcher_ || |
334 favicon_service_->WasUnableToDownloadFavicon(server_request_url)) { | 334 favicon_service_->WasUnableToDownloadFavicon(server_request_url)) { |
335 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 335 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
336 base::Bind(callback, false)); | 336 base::Bind(callback, false)); |
337 return; | 337 return; |
338 } | 338 } |
339 | 339 |
340 image_fetcher_->SetDataUseServiceName( | 340 image_fetcher_->SetDataUseServiceName( |
341 data_use_measurement::DataUseUserData::LARGE_ICON_SERVICE); | 341 data_use_measurement::DataUseUserData::LARGE_ICON_SERVICE); |
| 342 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 343 net::DefineNetworkTrafficAnnotation("...", R"( |
| 344 semantics { |
| 345 sender: "..." |
| 346 description: "..." |
| 347 trigger: "..." |
| 348 data: "..." |
| 349 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER/LOCAL |
| 350 } |
| 351 policy { |
| 352 cookies_allowed: false/true |
| 353 cookies_store: "..." |
| 354 setting: "..." |
| 355 chrome_policy { |
| 356 [POLICY_NAME] { |
| 357 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} |
| 358 [POLICY_NAME]: ... //(value to disable it) |
| 359 } |
| 360 } |
| 361 policy_exception_justification: "..." |
| 362 })"); |
342 image_fetcher_->StartOrQueueNetworkRequest( | 363 image_fetcher_->StartOrQueueNetworkRequest( |
343 server_request_url.spec(), server_request_url, | 364 server_request_url.spec(), server_request_url, |
344 base::Bind(&OnFetchIconFromGoogleServerComplete, favicon_service_, | 365 base::Bind(&OnFetchIconFromGoogleServerComplete, favicon_service_, |
345 page_url, callback)); | 366 page_url, callback), |
| 367 traffic_annotation); |
346 } | 368 } |
347 | 369 |
348 base::CancelableTaskTracker::TaskId | 370 base::CancelableTaskTracker::TaskId |
349 LargeIconService::GetLargeIconOrFallbackStyleImpl( | 371 LargeIconService::GetLargeIconOrFallbackStyleImpl( |
350 const GURL& page_url, | 372 const GURL& page_url, |
351 int min_source_size_in_pixel, | 373 int min_source_size_in_pixel, |
352 int desired_size_in_pixel, | 374 int desired_size_in_pixel, |
353 const favicon_base::LargeIconCallback& raw_bitmap_callback, | 375 const favicon_base::LargeIconCallback& raw_bitmap_callback, |
354 const favicon_base::LargeIconImageCallback& image_callback, | 376 const favicon_base::LargeIconImageCallback& image_callback, |
355 base::CancelableTaskTracker* tracker) { | 377 base::CancelableTaskTracker* tracker) { |
356 DCHECK_LE(1, min_source_size_in_pixel); | 378 DCHECK_LE(1, min_source_size_in_pixel); |
357 DCHECK_LE(0, desired_size_in_pixel); | 379 DCHECK_LE(0, desired_size_in_pixel); |
358 | 380 |
359 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker( | 381 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker( |
360 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback, | 382 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback, |
361 image_callback, background_task_runner_, tracker); | 383 image_callback, background_task_runner_, tracker); |
362 | 384 |
363 // TODO(beaudoin): For now this is just a wrapper around | 385 // TODO(beaudoin): For now this is just a wrapper around |
364 // GetLargestRawFaviconForPageURL. Add the logic required to select the best | 386 // GetLargestRawFaviconForPageURL. Add the logic required to select the best |
365 // possible large icon. Also add logic to fetch-on-demand when the URL of | 387 // possible large icon. Also add logic to fetch-on-demand when the URL of |
366 // a large icon is known but its bitmap is not available. | 388 // a large icon is known but its bitmap is not available. |
367 return favicon_service_->GetLargestRawFaviconForPageURL( | 389 return favicon_service_->GetLargestRawFaviconForPageURL( |
368 page_url, large_icon_types_, min_source_size_in_pixel, | 390 page_url, large_icon_types_, min_source_size_in_pixel, |
369 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker); | 391 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker); |
370 } | 392 } |
371 | 393 |
372 } // namespace favicon | 394 } // namespace favicon |
OLD | NEW |