| 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/ui/intents/web_intent_picker_controller.h" | 5 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/md5.h" | 11 #include "base/md5.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/download/download_util.h" | 15 #include "chrome/browser/download/download_util.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/platform_app_launcher.h" | 18 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 18 #include "chrome/browser/extensions/webstore_installer.h" | 19 #include "chrome/browser/extensions/webstore_installer.h" |
| 19 #include "chrome/browser/intents/cws_intents_registry_factory.h" | 20 #include "chrome/browser/intents/cws_intents_registry_factory.h" |
| 20 #include "chrome/browser/intents/default_web_intent_service.h" | 21 #include "chrome/browser/intents/default_web_intent_service.h" |
| 21 #include "chrome/browser/intents/intent_service_host.h" | 22 #include "chrome/browser/intents/intent_service_host.h" |
| 22 #include "chrome/browser/intents/native_services.h" | 23 #include "chrome/browser/intents/native_services.h" |
| 23 #include "chrome/browser/intents/web_intents_registry_factory.h" | 24 #include "chrome/browser/intents/web_intents_registry_factory.h" |
| 24 #include "chrome/browser/intents/web_intents_reporting.h" | 25 #include "chrome/browser/intents/web_intents_reporting.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/tab_contents/tab_util.h" | 27 #include "chrome/browser/tab_contents/tab_util.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable, | 270 base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable, |
| 270 weak_ptr_factory_.GetWeakPtr())); | 271 weak_ptr_factory_.GetWeakPtr())); |
| 271 } | 272 } |
| 272 | 273 |
| 273 void WebIntentPickerController::OnServiceChosen( | 274 void WebIntentPickerController::OnServiceChosen( |
| 274 const GURL& url, | 275 const GURL& url, |
| 275 webkit_glue::WebIntentServiceData::Disposition disposition, | 276 webkit_glue::WebIntentServiceData::Disposition disposition, |
| 276 DefaultsUsage suppress_defaults) { | 277 DefaultsUsage suppress_defaults) { |
| 277 web_intents::RecordServiceInvoke(uma_bucket_); | 278 web_intents::RecordServiceInvoke(uma_bucket_); |
| 278 uma_reporter_->ResetServiceActiveTimer(); | 279 uma_reporter_->ResetServiceActiveTimer(); |
| 279 ExtensionService* extension_service = profile_->GetExtensionService(); | 280 ExtensionService* extension_service = |
| 281 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 280 DCHECK(extension_service); | 282 DCHECK(extension_service); |
| 281 | 283 |
| 282 #if defined(TOOLKIT_VIEWS) | 284 #if defined(TOOLKIT_VIEWS) |
| 283 cancelled_ = false; | 285 cancelled_ = false; |
| 284 #endif | 286 #endif |
| 285 | 287 |
| 286 // Set the default here. Activating the intent resets the picker model. | 288 // Set the default here. Activating the intent resets the picker model. |
| 287 // TODO(gbillock): we should perhaps couple the model to the dispatcher so | 289 // TODO(gbillock): we should perhaps couple the model to the dispatcher so |
| 288 // we can re-activate the model on use-another-service. | 290 // we can re-activate the model on use-another-service. |
| 289 if (!suppress_defaults) | 291 if (!suppress_defaults) |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 } | 647 } |
| 646 } | 648 } |
| 647 | 649 |
| 648 OnPickerEvent(kPickerEventRegistryDataComplete); | 650 OnPickerEvent(kPickerEventRegistryDataComplete); |
| 649 OnIntentDataArrived(); | 651 OnIntentDataArrived(); |
| 650 } | 652 } |
| 651 | 653 |
| 652 void WebIntentPickerController::OnCWSIntentServicesAvailable( | 654 void WebIntentPickerController::OnCWSIntentServicesAvailable( |
| 653 const CWSIntentsRegistry::IntentExtensionList& extensions) { | 655 const CWSIntentsRegistry::IntentExtensionList& extensions) { |
| 654 ExtensionServiceInterface* extension_service = | 656 ExtensionServiceInterface* extension_service = |
| 655 profile_->GetExtensionService(); | 657 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 656 | 658 |
| 657 std::vector<WebIntentPickerModel::SuggestedExtension> suggestions; | 659 std::vector<WebIntentPickerModel::SuggestedExtension> suggestions; |
| 658 for (size_t i = 0; i < extensions.size(); ++i) { | 660 for (size_t i = 0; i < extensions.size(); ++i) { |
| 659 const CWSIntentsRegistry::IntentExtensionInfo& info = extensions[i]; | 661 const CWSIntentsRegistry::IntentExtensionInfo& info = extensions[i]; |
| 660 | 662 |
| 661 // Do not include suggestions for already installed extensions. | 663 // Do not include suggestions for already installed extensions. |
| 662 if (extension_service->GetExtensionById(info.id, true)) | 664 if (extension_service->GetExtensionById(info.id, true)) |
| 663 continue; | 665 continue; |
| 664 | 666 |
| 665 suggestions.push_back(WebIntentPickerModel::SuggestedExtension( | 667 suggestions.push_back(WebIntentPickerModel::SuggestedExtension( |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 content::DownloadManager* download_manager = | 967 content::DownloadManager* download_manager = |
| 966 content::BrowserContext::GetDownloadManager(profile); | 968 content::BrowserContext::GetDownloadManager(profile); |
| 967 if (!download_manager) | 969 if (!download_manager) |
| 968 return; | 970 return; |
| 969 content::DownloadItem* item = | 971 content::DownloadItem* item = |
| 970 download_manager->GetDownload(download_id_.local()); | 972 download_manager->GetDownload(download_id_.local()); |
| 971 if (item) | 973 if (item) |
| 972 item->Cancel(true); | 974 item->Cancel(true); |
| 973 download_id_ = content::DownloadId(); | 975 download_id_ = content::DownloadId(); |
| 974 } | 976 } |
| OLD | NEW |