OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/common/image_decoder.mojom.h" |
12 #include "content/public/browser/utility_process_host_client.h" | 13 #include "content/public/browser/utility_process_host_client.h" |
13 #include "net/url_request/url_fetcher_delegate.h" | 14 #include "net/url_request/url_fetcher_delegate.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
17 class SkBitmap; | |
18 | |
19 namespace base { | 18 namespace base { |
20 class DictionaryValue; | 19 class DictionaryValue; |
21 class ListValue; | 20 class ListValue; |
22 } | 21 } |
23 | 22 |
24 namespace content { | 23 namespace content { |
25 class UtilityProcessHost; | 24 class UtilityProcessHost; |
26 } | 25 } |
27 | 26 |
28 namespace net { | 27 namespace net { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void ReportResultsIfComplete(); | 82 void ReportResultsIfComplete(); |
84 void ReportResultFromUIThread(); | 83 void ReportResultFromUIThread(); |
85 | 84 |
86 // Implementing the net::URLFetcherDelegate interface. | 85 // Implementing the net::URLFetcherDelegate interface. |
87 void OnURLFetchComplete(const net::URLFetcher* source) override; | 86 void OnURLFetchComplete(const net::URLFetcher* source) override; |
88 | 87 |
89 // Implementing pieces of the UtilityProcessHostClient interface. | 88 // Implementing pieces of the UtilityProcessHostClient interface. |
90 bool OnMessageReceived(const IPC::Message& message) override; | 89 bool OnMessageReceived(const IPC::Message& message) override; |
91 | 90 |
92 // Message handlers. | 91 // Message handlers. |
93 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); | 92 void OnDecodeImageDone(bool success, content::ImageDataPtr image); |
94 void OnDecodeImageFailed(); | |
95 void OnJSONParseSucceeded(const base::ListValue& wrapper); | 93 void OnJSONParseSucceeded(const base::ListValue& wrapper); |
96 void OnJSONParseFailed(const std::string& error_message); | 94 void OnJSONParseFailed(const std::string& error_message); |
97 | 95 |
98 // The client who we'll report results back to. | 96 // The client who we'll report results back to. |
99 Delegate* delegate_; | 97 Delegate* delegate_; |
100 | 98 |
101 // The extension id of the manifest we're parsing. | 99 // The extension id of the manifest we're parsing. |
102 std::string id_; | 100 std::string id_; |
103 | 101 |
104 // The manifest to parse. | 102 // The manifest to parse. |
105 std::string manifest_; | 103 std::string manifest_; |
106 | 104 |
107 // Only one of these should be non-empty. If |icon_base64_data_| is non-emtpy, | 105 // Only one of these should be non-empty. If |icon_base64_data_| is non-emtpy, |
108 // it's a base64-encoded string that needs to be parsed into an SkBitmap. If | 106 // it's a base64-encoded string that needs to be parsed into an SkBitmap. If |
109 // |icon_url_| is non-empty, it needs to be fetched and decoded into an | 107 // |icon_url_| is non-empty, it needs to be fetched and decoded into an |
110 // SkBitmap. | 108 // SkBitmap. |
111 std::string icon_base64_data_; | 109 std::string icon_base64_data_; |
112 GURL icon_url_; | 110 GURL icon_url_; |
113 std::vector<unsigned char> fetched_icon_data_; | 111 std::vector<unsigned char> fetched_icon_data_; |
114 | 112 |
115 // For fetching the icon, if needed. | 113 // For fetching the icon, if needed. |
116 scoped_ptr<net::URLFetcher> url_fetcher_; | 114 scoped_ptr<net::URLFetcher> url_fetcher_; |
117 net::URLRequestContextGetter* context_getter_; // Only usable on UI thread. | 115 net::URLRequestContextGetter* context_getter_; // Only usable on UI thread. |
118 | 116 |
119 base::WeakPtr<content::UtilityProcessHost> utility_host_; | 117 base::WeakPtr<content::UtilityProcessHost> utility_host_; |
| 118 content::ImageDecoderPtr image_decoder_; |
120 | 119 |
121 // Flags for whether we're done doing icon decoding and manifest parsing. | 120 // Flags for whether we're done doing icon decoding and manifest parsing. |
122 bool icon_decode_complete_; | 121 bool icon_decode_complete_; |
123 bool manifest_parse_complete_; | 122 bool manifest_parse_complete_; |
124 | 123 |
125 // The results of succesful decoding/parsing. | 124 // The results of succesful decoding/parsing. |
126 SkBitmap icon_; | 125 SkBitmap icon_; |
127 scoped_ptr<base::DictionaryValue> parsed_manifest_; | 126 scoped_ptr<base::DictionaryValue> parsed_manifest_; |
128 | 127 |
129 // A details string for keeping track of any errors. | 128 // A details string for keeping track of any errors. |
130 std::string error_; | 129 std::string error_; |
131 | 130 |
132 // A code to distinguish between an error with the icon, and an error with the | 131 // A code to distinguish between an error with the icon, and an error with the |
133 // manifest. | 132 // manifest. |
134 Delegate::InstallHelperResultCode parse_error_; | 133 Delegate::InstallHelperResultCode parse_error_; |
135 }; | 134 }; |
136 | 135 |
137 } // namespace extensions | 136 } // namespace extensions |
138 | 137 |
139 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ | 138 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ |
OLD | NEW |