| 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/public/common/url_fetcher_delegate.h" | 10 #include "content/public/common/url_fetcher_delegate.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 public: | 34 public: |
| 35 enum InstallHelperResultCode { | 35 enum InstallHelperResultCode { |
| 36 UNKNOWN_ERROR, | 36 UNKNOWN_ERROR, |
| 37 ICON_ERROR, | 37 ICON_ERROR, |
| 38 MANIFEST_ERROR | 38 MANIFEST_ERROR |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // 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 |
| 42 // in the utility process. Ownership of parsed_manifest is transferred. | 42 // in the utility process. Ownership of parsed_manifest is transferred. |
| 43 virtual void OnWebstoreParseSuccess( | 43 virtual void OnWebstoreParseSuccess( |
| 44 const std::string& id, |
| 44 const SkBitmap& icon, | 45 const SkBitmap& icon, |
| 45 base::DictionaryValue* parsed_manifest) = 0; | 46 base::DictionaryValue* parsed_manifest) = 0; |
| 46 | 47 |
| 47 // Called to indicate a parse failure. The |result_code| parameter should | 48 // Called to indicate a parse failure. The |result_code| parameter should |
| 48 // indicate whether the problem was with the manifest or icon. | 49 // indicate whether the problem was with the manifest or icon. |
| 49 virtual void OnWebstoreParseFailure( | 50 virtual void OnWebstoreParseFailure( |
| 51 const std::string& id, |
| 50 InstallHelperResultCode result_code, | 52 InstallHelperResultCode result_code, |
| 51 const std::string& error_message) = 0; | 53 const std::string& error_message) = 0; |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 // Only one of |icon_data| (based64-encoded icon data) or |icon_url| can be | 56 // Only one of |icon_data| (based64-encoded icon data) or |icon_url| can be |
| 55 // specified, but it is legal for both to be empty. | 57 // specified, but it is legal for both to be empty. |
| 56 WebstoreInstallHelper(Delegate* delegate, | 58 WebstoreInstallHelper(Delegate* delegate, |
| 59 const std::string& id, |
| 57 const std::string& manifest, | 60 const std::string& manifest, |
| 58 const std::string& icon_data, | 61 const std::string& icon_data, |
| 59 const GURL& icon_url, | 62 const GURL& icon_url, |
| 60 net::URLRequestContextGetter* context_getter); | 63 net::URLRequestContextGetter* context_getter); |
| 61 void Start(); | 64 void Start(); |
| 62 | 65 |
| 63 private: | 66 private: |
| 64 virtual ~WebstoreInstallHelper(); | 67 virtual ~WebstoreInstallHelper(); |
| 65 | 68 |
| 66 void StartWorkOnIOThread(); | 69 void StartWorkOnIOThread(); |
| 67 void StartFetchedImageDecode(); | 70 void StartFetchedImageDecode(); |
| 68 void ReportResultsIfComplete(); | 71 void ReportResultsIfComplete(); |
| 69 void ReportResultFromUIThread(); | 72 void ReportResultFromUIThread(); |
| 70 | 73 |
| 71 // Implementing the content::URLFetcherDelegate interface. | 74 // Implementing the content::URLFetcherDelegate interface. |
| 72 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; | 75 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; |
| 73 | 76 |
| 74 // Implementing pieces of the UtilityProcessHost::Client interface. | 77 // Implementing pieces of the UtilityProcessHost::Client interface. |
| 75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 78 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 76 | 79 |
| 77 // Message handlers. | 80 // Message handlers. |
| 78 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); | 81 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); |
| 79 void OnDecodeImageFailed(); | 82 void OnDecodeImageFailed(); |
| 80 void OnJSONParseSucceeded(const base::ListValue& wrapper); | 83 void OnJSONParseSucceeded(const base::ListValue& wrapper); |
| 81 void OnJSONParseFailed(const std::string& error_message); | 84 void OnJSONParseFailed(const std::string& error_message); |
| 82 | 85 |
| 83 // The client who we'll report results back to. | 86 // The client who we'll report results back to. |
| 84 Delegate* delegate_; | 87 Delegate* delegate_; |
| 85 | 88 |
| 89 // The extension id of the manifest we're parsing. |
| 90 std::string id_; |
| 91 |
| 86 // The manifest to parse. | 92 // The manifest to parse. |
| 87 std::string manifest_; | 93 std::string manifest_; |
| 88 | 94 |
| 89 // Only one of these should be non-empty. If |icon_base64_data_| is non-emtpy, | 95 // Only one of these should be non-empty. If |icon_base64_data_| is non-emtpy, |
| 90 // it's a base64-encoded string that needs to be parsed into an SkBitmap. If | 96 // it's a base64-encoded string that needs to be parsed into an SkBitmap. If |
| 91 // |icon_url_| is non-empty, it needs to be fetched and decoded into an | 97 // |icon_url_| is non-empty, it needs to be fetched and decoded into an |
| 92 // SkBitmap. | 98 // SkBitmap. |
| 93 std::string icon_base64_data_; | 99 std::string icon_base64_data_; |
| 94 GURL icon_url_; | 100 GURL icon_url_; |
| 95 std::vector<unsigned char> fetched_icon_data_; | 101 std::vector<unsigned char> fetched_icon_data_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 110 | 116 |
| 111 // A details string for keeping track of any errors. | 117 // A details string for keeping track of any errors. |
| 112 std::string error_; | 118 std::string error_; |
| 113 | 119 |
| 114 // A code to distinguish between an error with the icon, and an error with the | 120 // A code to distinguish between an error with the icon, and an error with the |
| 115 // manifest. | 121 // manifest. |
| 116 Delegate::InstallHelperResultCode parse_error_; | 122 Delegate::InstallHelperResultCode parse_error_; |
| 117 }; | 123 }; |
| 118 | 124 |
| 119 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ | 125 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_ |
| OLD | NEW |