| 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 #include "chrome/browser/extensions/webstore_install_helper.h" | 5 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/common/chrome_utility_messages.h" | 11 #include "chrome/common/chrome_utility_messages.h" |
| 12 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
| 13 #include "content/common/net/url_fetcher.h" | 13 #include "content/common/net/url_fetcher.h" |
| 14 #include "net/url_request/url_request_context_getter.h" | 14 #include "net/url_request/url_request_context_getter.h" |
| 15 #include "net/url_request/url_request_status.h" | 15 #include "net/url_request/url_request_status.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const char kImageDecodeError[] = "Image decode failed"; | 19 const char kImageDecodeError[] = "Image decode failed"; |
| 20 | 20 |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 WebstoreInstallHelper::WebstoreInstallHelper( | 23 WebstoreInstallHelper::WebstoreInstallHelper( |
| 24 Delegate* delegate, | 24 Delegate* delegate, |
| 25 const std::string& id, |
| 25 const std::string& manifest, | 26 const std::string& manifest, |
| 26 const std::string& icon_data, | 27 const std::string& icon_data, |
| 27 const GURL& icon_url, | 28 const GURL& icon_url, |
| 28 net::URLRequestContextGetter* context_getter) | 29 net::URLRequestContextGetter* context_getter) |
| 29 : delegate_(delegate), | 30 : delegate_(delegate), |
| 31 id_(id), |
| 30 manifest_(manifest), | 32 manifest_(manifest), |
| 31 icon_base64_data_(icon_data), | 33 icon_base64_data_(icon_data), |
| 32 icon_url_(icon_url), | 34 icon_url_(icon_url), |
| 33 context_getter_(context_getter), | 35 context_getter_(context_getter), |
| 34 utility_host_(NULL), | 36 utility_host_(NULL), |
| 35 icon_decode_complete_(false), | 37 icon_decode_complete_(false), |
| 36 manifest_parse_complete_(false), | 38 manifest_parse_complete_(false), |
| 37 parse_error_(Delegate::UNKNOWN_ERROR) {} | 39 parse_error_(Delegate::UNKNOWN_ERROR) {} |
| 38 | 40 |
| 39 WebstoreInstallHelper::~WebstoreInstallHelper() {} | 41 WebstoreInstallHelper::~WebstoreInstallHelper() {} |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 172 |
| 171 BrowserThread::PostTask( | 173 BrowserThread::PostTask( |
| 172 BrowserThread::UI, | 174 BrowserThread::UI, |
| 173 FROM_HERE, | 175 FROM_HERE, |
| 174 base::Bind(&WebstoreInstallHelper::ReportResultFromUIThread, this)); | 176 base::Bind(&WebstoreInstallHelper::ReportResultFromUIThread, this)); |
| 175 } | 177 } |
| 176 | 178 |
| 177 void WebstoreInstallHelper::ReportResultFromUIThread() { | 179 void WebstoreInstallHelper::ReportResultFromUIThread() { |
| 178 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 180 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 179 if (error_.empty() && parsed_manifest_.get()) | 181 if (error_.empty() && parsed_manifest_.get()) |
| 180 delegate_->OnWebstoreParseSuccess(icon_, parsed_manifest_.release()); | 182 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); |
| 181 else | 183 else |
| 182 delegate_->OnWebstoreParseFailure(parse_error_, error_); | 184 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); |
| 183 } | 185 } |
| OLD | NEW |