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/browser/bitmap_fetcher/bitmap_fetcher.h" | 11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
12 #include "chrome/common/chrome_utility_messages.h" | 12 #include "chrome/common/chrome_utility_messages.h" |
13 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 13 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
| 14 #include "chrome/grit/generated_resources.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/utility_process_host.h" | 16 #include "content/public/browser/utility_process_host.h" |
16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 19 #include "ui/base/l10n/l10n_util.h" |
18 | 20 |
19 using content::BrowserThread; | 21 using content::BrowserThread; |
20 using content::UtilityProcessHost; | 22 using content::UtilityProcessHost; |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 const char kImageDecodeError[] = "Image decode failed"; | 26 const char kImageDecodeError[] = "Image decode failed"; |
25 | 27 |
26 } // namespace | 28 } // namespace |
27 | 29 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
62 BrowserThread::IO, | 64 BrowserThread::IO, |
63 FROM_HERE, | 65 FROM_HERE, |
64 base::Bind(&WebstoreInstallHelper::StartWorkOnIOThread, this)); | 66 base::Bind(&WebstoreInstallHelper::StartWorkOnIOThread, this)); |
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_ = UtilityProcessHost::Create( | 71 utility_host_ = UtilityProcessHost::Create( |
70 this, base::MessageLoopProxy::current().get())->AsWeakPtr(); | 72 this, base::MessageLoopProxy::current().get())->AsWeakPtr(); |
| 73 utility_host_->SetName(l10n_util::GetStringUTF16( |
| 74 IDS_UTILITY_PROCESS_JSON_PARSER_NAME)); |
71 utility_host_->StartBatchMode(); | 75 utility_host_->StartBatchMode(); |
72 | 76 |
73 utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_)); | 77 utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_)); |
74 } | 78 } |
75 | 79 |
76 bool WebstoreInstallHelper::OnMessageReceived(const IPC::Message& message) { | 80 bool WebstoreInstallHelper::OnMessageReceived(const IPC::Message& message) { |
77 bool handled = true; | 81 bool handled = true; |
78 IPC_BEGIN_MESSAGE_MAP(WebstoreInstallHelper, message) | 82 IPC_BEGIN_MESSAGE_MAP(WebstoreInstallHelper, message) |
79 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, | 83 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseJSON_Succeeded, |
80 OnJSONParseSucceeded) | 84 OnJSONParseSucceeded) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 150 |
147 void WebstoreInstallHelper::ReportResultFromUIThread() { | 151 void WebstoreInstallHelper::ReportResultFromUIThread() { |
148 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 152 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 if (error_.empty() && parsed_manifest_) | 153 if (error_.empty() && parsed_manifest_) |
150 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); | 154 delegate_->OnWebstoreParseSuccess(id_, icon_, parsed_manifest_.release()); |
151 else | 155 else |
152 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); | 156 delegate_->OnWebstoreParseFailure(id_, parse_error_, error_); |
153 } | 157 } |
154 | 158 |
155 } // namespace extensions | 159 } // namespace extensions |
OLD | NEW |