| 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 #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/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/utility_process_host.h" |
| 13 #include "content/public/common/url_fetcher.h" | 14 #include "content/public/common/url_fetcher.h" |
| 14 #include "net/url_request/url_request_context_getter.h" | 15 #include "net/url_request/url_request_context_getter.h" |
| 15 #include "net/url_request/url_request_status.h" | 16 #include "net/url_request/url_request_status.h" |
| 16 | 17 |
| 17 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 using content::UtilityProcessHost; |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 const char kImageDecodeError[] = "Image decode failed"; | 23 const char kImageDecodeError[] = "Image decode failed"; |
| 22 | 24 |
| 23 } // namespace | 25 } // namespace |
| 24 | 26 |
| 25 WebstoreInstallHelper::WebstoreInstallHelper( | 27 WebstoreInstallHelper::WebstoreInstallHelper( |
| 26 Delegate* delegate, | 28 Delegate* delegate, |
| 27 const std::string& id, | 29 const std::string& id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 url_fetcher_->SetRequestContext(context_getter_); | 62 url_fetcher_->SetRequestContext(context_getter_); |
| 61 | 63 |
| 62 url_fetcher_->Start(); | 64 url_fetcher_->Start(); |
| 63 // We'll get called back in OnURLFetchComplete. | 65 // We'll get called back in OnURLFetchComplete. |
| 64 } | 66 } |
| 65 } | 67 } |
| 66 | 68 |
| 67 void WebstoreInstallHelper::StartWorkOnIOThread() { | 69 void WebstoreInstallHelper::StartWorkOnIOThread() { |
| 68 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 70 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 69 utility_host_ = | 71 utility_host_ = |
| 70 (new UtilityProcessHost(this, BrowserThread::IO))->AsWeakPtr(); | 72 UtilityProcessHost::Create(this, BrowserThread::IO)->AsWeakPtr(); |
| 71 utility_host_->set_use_linux_zygote(true); | 73 utility_host_->EnableZygote(); |
| 72 utility_host_->StartBatchMode(); | 74 utility_host_->StartBatchMode(); |
| 73 | 75 |
| 74 if (!icon_base64_data_.empty()) | 76 if (!icon_base64_data_.empty()) |
| 75 utility_host_->Send( | 77 utility_host_->Send( |
| 76 new ChromeUtilityMsg_DecodeImageBase64(icon_base64_data_)); | 78 new ChromeUtilityMsg_DecodeImageBase64(icon_base64_data_)); |
| 77 | 79 |
| 78 utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_)); | 80 utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_)); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void WebstoreInstallHelper::OnURLFetchComplete( | 83 void WebstoreInstallHelper::OnURLFetchComplete( |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 base::Bind(&WebstoreInstallHelper::ReportResultFromUIThread, this)); | 185 base::Bind(&WebstoreInstallHelper::ReportResultFromUIThread, this)); |
| 184 } | 186 } |
| 185 | 187 |
| 186 void WebstoreInstallHelper::ReportResultFromUIThread() { | 188 void WebstoreInstallHelper::ReportResultFromUIThread() { |
| 187 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 189 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 188 if (error_.empty() && parsed_manifest_.get()) | 190 if (error_.empty() && parsed_manifest_.get()) |
| 189 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); | 191 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); |
| 190 else | 192 else |
| 191 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); | 193 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); |
| 192 } | 194 } |
| OLD | NEW |