| 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/extension_webstore_private_api.h" | 5 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/extensions/crx_installer.h" | 14 #include "chrome/browser/extensions/crx_installer.h" |
| 15 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 15 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 16 #include "chrome/browser/extensions/extension_install_dialog.h" | 16 #include "chrome/browser/extensions/extension_install_dialog.h" |
| 17 #include "chrome/browser/extensions/extension_prefs.h" | 17 #include "chrome/browser/extensions/extension_prefs.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/net/gaia/token_service.h" | 19 #include "chrome/browser/net/gaia/token_service.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/sync/profile_sync_service.h" | 21 #include "chrome/browser/sync/profile_sync_service.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/chrome_utility_messages.h" |
| 23 #include "chrome/common/extensions/extension_constants.h" | 24 #include "chrome/common/extensions/extension_constants.h" |
| 24 #include "chrome/common/extensions/extension_error_utils.h" | 25 #include "chrome/common/extensions/extension_error_utils.h" |
| 25 #include "chrome/common/extensions/extension_l10n_util.h" | 26 #include "chrome/common/extensions/extension_l10n_util.h" |
| 26 #include "chrome/common/net/gaia/gaia_constants.h" | 27 #include "chrome/common/net/gaia/gaia_constants.h" |
| 27 #include "content/browser/tab_contents/tab_contents.h" | 28 #include "content/browser/tab_contents/tab_contents.h" |
| 28 #include "content/common/notification_details.h" | 29 #include "content/common/notification_details.h" |
| 29 #include "content/common/notification_source.h" | 30 #include "content/common/notification_source.h" |
| 30 #include "content/common/notification_type.h" | 31 #include "content/common/notification_type.h" |
| 31 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
| 32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 &SafeBeginInstallHelper::StartWorkOnIOThread)); | 175 &SafeBeginInstallHelper::StartWorkOnIOThread)); |
| 175 } | 176 } |
| 176 | 177 |
| 177 void StartWorkOnIOThread() { | 178 void StartWorkOnIOThread() { |
| 178 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 179 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 179 utility_host_ = new UtilityProcessHost(this, BrowserThread::IO); | 180 utility_host_ = new UtilityProcessHost(this, BrowserThread::IO); |
| 180 utility_host_->StartBatchMode(); | 181 utility_host_->StartBatchMode(); |
| 181 if (icon_data_.empty()) | 182 if (icon_data_.empty()) |
| 182 icon_decode_complete_ = true; | 183 icon_decode_complete_ = true; |
| 183 else | 184 else |
| 184 utility_host_->StartImageDecodingBase64(icon_data_); | 185 utility_host_->Send(new UtilityMsg_DecodeImageBase64(icon_data_)); |
| 185 utility_host_->StartJSONParsing(manifest_); | 186 utility_host_->Send(new UtilityMsg_ParseJSON(manifest_)); |
| 186 } | 187 } |
| 187 | 188 |
| 188 // Implementing pieces of the UtilityProcessHost::Client interface. | 189 // Implementing pieces of the UtilityProcessHost::Client interface. |
| 189 virtual void OnDecodeImageSucceeded(const SkBitmap& decoded_image) { | 190 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 191 bool handled = true; |
| 192 IPC_BEGIN_MESSAGE_MAP(SafeBeginInstallHelper, message) |
| 193 IPC_MESSAGE_HANDLER(UtilityHostMsg_DecodeImage_Succeeded, |
| 194 OnDecodeImageSucceeded) |
| 195 IPC_MESSAGE_HANDLER(UtilityHostMsg_DecodeImage_Failed, |
| 196 OnDecodeImageFailed) |
| 197 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseJSON_Succeeded, |
| 198 OnJSONParseSucceeded) |
| 199 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseJSON_Failed, OnJSONParseFailed) |
| 200 IPC_MESSAGE_UNHANDLED(handled = false) |
| 201 IPC_END_MESSAGE_MAP_EX() |
| 202 return handled; |
| 203 } |
| 204 |
| 205 void OnDecodeImageSucceeded(const SkBitmap& decoded_image) { |
| 190 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 206 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 191 icon_ = decoded_image; | 207 icon_ = decoded_image; |
| 192 icon_decode_complete_ = true; | 208 icon_decode_complete_ = true; |
| 193 ReportResultsIfComplete(); | 209 ReportResultsIfComplete(); |
| 194 } | 210 } |
| 195 virtual void OnDecodeImageFailed() { | 211 |
| 212 void OnDecodeImageFailed() { |
| 196 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 213 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 197 icon_decode_complete_ = true; | 214 icon_decode_complete_ = true; |
| 198 error_ = std::string(kImageDecodeError); | 215 error_ = std::string(kImageDecodeError); |
| 199 parse_error_ = BeginInstallWithManifestFunction::ICON_ERROR; | 216 parse_error_ = BeginInstallWithManifestFunction::ICON_ERROR; |
| 200 ReportResultsIfComplete(); | 217 ReportResultsIfComplete(); |
| 201 } | 218 } |
| 202 virtual void OnJSONParseSucceeded(const ListValue& wrapper) { | 219 |
| 220 void OnJSONParseSucceeded(const ListValue& wrapper) { |
| 203 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 221 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 204 manifest_parse_complete_ = true; | 222 manifest_parse_complete_ = true; |
| 205 Value* value = NULL; | 223 Value* value = NULL; |
| 206 CHECK(wrapper.Get(0, &value)); | 224 CHECK(wrapper.Get(0, &value)); |
| 207 if (value->IsType(Value::TYPE_DICTIONARY)) { | 225 if (value->IsType(Value::TYPE_DICTIONARY)) { |
| 208 parsed_manifest_.reset( | 226 parsed_manifest_.reset( |
| 209 static_cast<DictionaryValue*>(value)->DeepCopy()); | 227 static_cast<DictionaryValue*>(value)->DeepCopy()); |
| 210 } else { | 228 } else { |
| 211 parse_error_ = BeginInstallWithManifestFunction::MANIFEST_ERROR; | 229 parse_error_ = BeginInstallWithManifestFunction::MANIFEST_ERROR; |
| 212 } | 230 } |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 646 } |
| 629 | 647 |
| 630 DCHECK(waiting_for_token_); | 648 DCHECK(waiting_for_token_); |
| 631 | 649 |
| 632 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); | 650 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); |
| 633 SendResponse(true); | 651 SendResponse(true); |
| 634 | 652 |
| 635 // Matches the AddRef in RunImpl(). | 653 // Matches the AddRef in RunImpl(). |
| 636 Release(); | 654 Release(); |
| 637 } | 655 } |
| OLD | NEW |