OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/drive/drive_app_converter.h" | 5 #include "chrome/browser/apps/drive/drive_app_converter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 fetcher_->SetRequestContext(converter_->profile_->GetRequestContext()); | 51 fetcher_->SetRequestContext(converter_->profile_->GetRequestContext()); |
52 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 52 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
53 fetcher_->Start(); | 53 fetcher_->Start(); |
54 } | 54 } |
55 | 55 |
56 const GURL& icon_url() const { return icon_url_; } | 56 const GURL& icon_url() const { return icon_url_; } |
57 const SkBitmap& icon() const { return icon_; } | 57 const SkBitmap& icon() const { return icon_; } |
58 | 58 |
59 private: | 59 private: |
60 // net::URLFetcherDelegate overrides: | 60 // net::URLFetcherDelegate overrides: |
61 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { | 61 virtual void OnURLFetchComplete(const net::URLFetcher* source) override { |
62 CHECK_EQ(fetcher_.get(), source); | 62 CHECK_EQ(fetcher_.get(), source); |
63 scoped_ptr<net::URLFetcher> fetcher(fetcher_.Pass()); | 63 scoped_ptr<net::URLFetcher> fetcher(fetcher_.Pass()); |
64 | 64 |
65 if (!fetcher->GetStatus().is_success() || | 65 if (!fetcher->GetStatus().is_success() || |
66 fetcher->GetResponseCode() != net::HTTP_OK) { | 66 fetcher->GetResponseCode() != net::HTTP_OK) { |
67 converter_->OnIconFetchComplete(this); | 67 converter_->OnIconFetchComplete(this); |
68 return; | 68 return; |
69 } | 69 } |
70 | 70 |
71 std::string unsafe_icon_data; | 71 std::string unsafe_icon_data; |
72 fetcher->GetResponseAsString(&unsafe_icon_data); | 72 fetcher->GetResponseAsString(&unsafe_icon_data); |
73 | 73 |
74 image_decoder_ = | 74 image_decoder_ = |
75 new ImageDecoder(this, unsafe_icon_data, ImageDecoder::DEFAULT_CODEC); | 75 new ImageDecoder(this, unsafe_icon_data, ImageDecoder::DEFAULT_CODEC); |
76 image_decoder_->Start( | 76 image_decoder_->Start( |
77 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)); | 77 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)); |
78 } | 78 } |
79 | 79 |
80 // ImageDecoder::Delegate overrides: | 80 // ImageDecoder::Delegate overrides: |
81 virtual void OnImageDecoded(const ImageDecoder* decoder, | 81 virtual void OnImageDecoded(const ImageDecoder* decoder, |
82 const SkBitmap& decoded_image) OVERRIDE { | 82 const SkBitmap& decoded_image) override { |
83 if (decoded_image.width() == expected_size_) | 83 if (decoded_image.width() == expected_size_) |
84 icon_ = decoded_image; | 84 icon_ = decoded_image; |
85 converter_->OnIconFetchComplete(this); | 85 converter_->OnIconFetchComplete(this); |
86 } | 86 } |
87 | 87 |
88 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE { | 88 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) override { |
89 converter_->OnIconFetchComplete(this); | 89 converter_->OnIconFetchComplete(this); |
90 } | 90 } |
91 | 91 |
92 DriveAppConverter* converter_; | 92 DriveAppConverter* converter_; |
93 const GURL icon_url_; | 93 const GURL icon_url_; |
94 const int expected_size_; | 94 const int expected_size_; |
95 | 95 |
96 scoped_ptr<net::URLFetcher> fetcher_; | 96 scoped_ptr<net::URLFetcher> fetcher_; |
97 scoped_refptr<ImageDecoder> image_decoder_; | 97 scoped_refptr<ImageDecoder> image_decoder_; |
98 SkBitmap icon_; | 98 SkBitmap icon_; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 return; | 204 return; |
205 } | 205 } |
206 | 206 |
207 extension_ = crx_installer_->extension(); | 207 extension_ = crx_installer_->extension(); |
208 is_new_install_ = success && crx_installer_->current_version().empty(); | 208 is_new_install_ = success && crx_installer_->current_version().empty(); |
209 PostInstallCleanUp(); | 209 PostInstallCleanUp(); |
210 | 210 |
211 finished_callback_.Run(this, success); | 211 finished_callback_.Run(this, success); |
212 // |finished_callback_| could delete this. | 212 // |finished_callback_| could delete this. |
213 } | 213 } |
OLD | NEW |