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

Side by Side Diff: content/browser/payments/payment_instrument_icon_fetcher.h

Issue 2925063003: [Payments] Implement payment instrument icons (Closed)
Patch Set: resolve url based on execution context Created 3 years, 6 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "components/payments/mojom/payment_app.mojom.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "net/url_request/url_fetcher.h"
15 #include "net/url_request/url_fetcher_delegate.h"
16 #include "net/url_request/url_request_context_getter.h"
17 #include "third_party/skia/include/core/SkBitmap.h"
18
19 namespace content {
20
21 class PaymentInstrumentIconFetcher : private net::URLFetcherDelegate {
22 public:
23 using PaymentInstrumentIconFetcherCallback =
24 base::OnceCallback<void(const std::string&)>;
25
26 PaymentInstrumentIconFetcher();
27 ~PaymentInstrumentIconFetcher() override;
28
29 // Starts fetching and decoding payment instrument icon from online. The
30 // result will be send back through |callback|.
31 // TODO(gogerald): Right now, we return the first fetchable and decodable icon
32 // with smallest available size. We may add more logic to choose appropriate
33 // icon according to icon size and our usage.
34 void Start(const std::vector<payments::mojom::ImageObjectPtr>& image_objects,
35 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
36 PaymentInstrumentIconFetcherCallback callback);
37
38 private:
39 void StartFromUIThread(
40 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
41 void PostCallbackToIOThread(const std::string& decoded_data);
42
43 // data_decoder::mojom::ImageDecoder::DecodeImageCallback.
44 void DecodeImageCallback(const SkBitmap& bitmap);
45
46 // Override net::URLFetcherDelegate.
47 void OnURLFetchComplete(const net::URLFetcher* source) override;
48
49 void FetchIcon();
50
51 // Declared set of image objects of the payment instrument.
52 std::vector<payments::mojom::ImageObjectPtr> image_objects_;
53
54 // The index of the currently checking image object in image_objects_.
55 size_t checking_image_object_index_;
56
57 // The callback to notify after complete.
58 PaymentInstrumentIconFetcherCallback callback_;
59
60 // The url request context getter for fetching icon from online.
61 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
62
63 // The url fetcher to fetch raw icon from online.
64 std::unique_ptr<net::URLFetcher> fetcher_;
65
66 DISALLOW_COPY_AND_ASSIGN(PaymentInstrumentIconFetcher);
67 };
68
69 } // namespace content
70
71 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698