OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "content/browser/utility_process_host.h" | 9 #include "content/browser/utility_process_host.h" |
10 #include "content/common/net/url_fetcher.h" | 10 #include "content/public/common/url_fetcher_delegate.h" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
13 | 13 |
14 class UtilityProcessHost; | 14 class UtilityProcessHost; |
15 class SkBitmap; | 15 class SkBitmap; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 class ListValue; | 19 class ListValue; |
20 } | 20 } |
21 | 21 |
| 22 namespace net { |
| 23 class URLRequestContextGetter; |
| 24 } |
| 25 |
22 // This is a class to help dealing with webstore-provided data. It manages | 26 // This is a class to help dealing with webstore-provided data. It manages |
23 // sending work to the utility process for parsing manifests and | 27 // sending work to the utility process for parsing manifests and |
24 // fetching/decoding icon data. Clients must implement the | 28 // fetching/decoding icon data. Clients must implement the |
25 // WebstoreInstallHelper::Delegate interface to receive the parsed data. | 29 // WebstoreInstallHelper::Delegate interface to receive the parsed data. |
26 class WebstoreInstallHelper : public UtilityProcessHost::Client, | 30 class WebstoreInstallHelper : public UtilityProcessHost::Client, |
27 public URLFetcher::Delegate { | 31 public content::URLFetcherDelegate { |
28 public: | 32 public: |
29 class Delegate { | 33 class Delegate { |
30 public: | 34 public: |
31 enum InstallHelperResultCode { | 35 enum InstallHelperResultCode { |
32 UNKNOWN_ERROR, | 36 UNKNOWN_ERROR, |
33 ICON_ERROR, | 37 ICON_ERROR, |
34 MANIFEST_ERROR | 38 MANIFEST_ERROR |
35 }; | 39 }; |
36 | 40 |
37 // Called when we've successfully parsed the manifest and decoded the icon | 41 // Called when we've successfully parsed the manifest and decoded the icon |
(...skipping 19 matching lines...) Expand all Loading... |
57 void Start(); | 61 void Start(); |
58 | 62 |
59 private: | 63 private: |
60 virtual ~WebstoreInstallHelper(); | 64 virtual ~WebstoreInstallHelper(); |
61 | 65 |
62 void StartWorkOnIOThread(); | 66 void StartWorkOnIOThread(); |
63 void StartFetchedImageDecode(); | 67 void StartFetchedImageDecode(); |
64 void ReportResultsIfComplete(); | 68 void ReportResultsIfComplete(); |
65 void ReportResultFromUIThread(); | 69 void ReportResultFromUIThread(); |
66 | 70 |
67 // Implementing the URLFetcher::Delegate interface. | 71 // Implementing the content::URLFetcherDelegate interface. |
68 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; | 72 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; |
69 | 73 |
70 // Implementing pieces of the UtilityProcessHost::Client interface. | 74 // Implementing pieces of the UtilityProcessHost::Client interface. |
71 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
72 | 76 |
73 // Message handlers. | 77 // Message handlers. |
74 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); | 78 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); |
75 void OnDecodeImageFailed(); | 79 void OnDecodeImageFailed(); |
76 void OnJSONParseSucceeded(const base::ListValue& wrapper); | 80 void OnJSONParseSucceeded(const base::ListValue& wrapper); |
77 void OnJSONParseFailed(const std::string& error_message); | 81 void OnJSONParseFailed(const std::string& error_message); |
(...skipping 28 matching lines...) Expand all Loading... |
106 | 110 |
107 // A details string for keeping track of any errors. | 111 // A details string for keeping track of any errors. |
108 std::string error_; | 112 std::string error_; |
109 | 113 |
110 // A code to distinguish between an error with the icon, and an error with the | 114 // A code to distinguish between an error with the icon, and an error with the |
111 // manifest. | 115 // manifest. |
112 Delegate::InstallHelperResultCode parse_error_; | 116 Delegate::InstallHelperResultCode parse_error_; |
113 }; | 117 }; |
114 | 118 |
115 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ | 119 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ |
OLD | NEW |