Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: ios/web/web_state/web_state_impl.mm

Issue 2677993002: Use IOSImageDataFetcherWrapper for favicon (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #import "ios/web/web_state/web_state_impl.h" 5 #import "ios/web/web_state/web_state_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 bool WebStateImpl::ShouldAllowResponse(NSURLResponse* response) { 558 bool WebStateImpl::ShouldAllowResponse(NSURLResponse* response) {
559 for (auto& policy_decider : policy_deciders_) { 559 for (auto& policy_decider : policy_deciders_) {
560 if (!policy_decider.ShouldAllowResponse(response)) 560 if (!policy_decider.ShouldAllowResponse(response))
561 return false; 561 return false;
562 } 562 }
563 return true; 563 return true;
564 } 564 }
565 565
566 #pragma mark - RequestTracker management 566 #pragma mark - RequestTracker management
567 567
568 int WebStateImpl::DownloadImage(
569 const GURL& url,
570 bool is_favicon,
571 uint32_t max_bitmap_size,
572 bool bypass_cache,
573 const ImageDownloadCallback& callback) {
574 // |is_favicon| specifies whether the download of the image occurs with
575 // cookies or not. Currently, only downloads without cookies are supported.
576 // |bypass_cache| is ignored since the downloads never go through a cache.
577 DCHECK(is_favicon);
578
579 static int downloaded_image_count = 0;
580 int local_download_id = ++downloaded_image_count;
581 __block web::WebState::ImageDownloadCallback local_image_callback = callback;
582 __block GURL local_url(url);
583 ImageFetchedCallback local_callback =
584 ^(const GURL&, const int response_code, NSData* data) {
585 std::vector<SkBitmap> frames;
586 std::vector<gfx::Size> sizes;
587 if (data) {
588 frames = skia::ImageDataToSkBitmaps(data);
589 for (auto& frame : frames) {
590 sizes.push_back(gfx::Size(frame.width(), frame.height()));
591 }
592 }
593 if (response_code != net::URLFetcher::RESPONSE_CODE_INVALID) {
594 local_image_callback.Run(local_download_id, response_code, local_url,
595 frames, sizes);
596 }
597 };
598 image_fetcher_->StartDownload(url, local_callback);
599 return downloaded_image_count;
600 }
601
602 service_manager::InterfaceRegistry* WebStateImpl::GetMojoInterfaceRegistry() { 568 service_manager::InterfaceRegistry* WebStateImpl::GetMojoInterfaceRegistry() {
603 if (!mojo_interface_registry_) { 569 if (!mojo_interface_registry_) {
604 mojo_interface_registry_ = 570 mojo_interface_registry_ =
605 base::MakeUnique<service_manager::InterfaceRegistry>(std::string()); 571 base::MakeUnique<service_manager::InterfaceRegistry>(std::string());
606 } 572 }
607 return mojo_interface_registry_.get(); 573 return mojo_interface_registry_.get();
608 } 574 }
609 575
610 base::WeakPtr<WebState> WebStateImpl::AsWeakPtr() { 576 base::WeakPtr<WebState> WebStateImpl::AsWeakPtr() {
611 return weak_factory_.GetWeakPtr(); 577 return weak_factory_.GetWeakPtr();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 const LoadCommittedDetails& load_details) { 733 const LoadCommittedDetails& load_details) {
768 for (auto& observer : observers_) 734 for (auto& observer : observers_)
769 observer.NavigationItemCommitted(load_details); 735 observer.NavigationItemCommitted(load_details);
770 } 736 }
771 737
772 WebState* WebStateImpl::GetWebState() { 738 WebState* WebStateImpl::GetWebState() {
773 return this; 739 return this;
774 } 740 }
775 741
776 } // namespace web 742 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698