| 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" |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 450 |
| 451 void WebIntentPickerController::OnExtensionInstallRequested( | 451 void WebIntentPickerController::OnExtensionInstallRequested( |
| 452 const std::string& id) { | 452 const std::string& id) { |
| 453 picker_model_->SetPendingExtensionInstallId(id); | 453 picker_model_->SetPendingExtensionInstallId(id); |
| 454 | 454 |
| 455 scoped_ptr<WebstoreInstaller::Approval> approval( | 455 scoped_ptr<WebstoreInstaller::Approval> approval( |
| 456 WebstoreInstaller::Approval::CreateWithInstallPrompt(profile_)); | 456 WebstoreInstaller::Approval::CreateWithInstallPrompt(profile_)); |
| 457 // Don't show a bubble pointing to the extension or any other post | 457 // Don't show a bubble pointing to the extension or any other post |
| 458 // installation UI. | 458 // installation UI. |
| 459 approval->skip_post_install_ui = true; | 459 approval->skip_post_install_ui = true; |
| 460 approval->custom_install_dialog_callback = base::Bind( |
| 461 &WebIntentPickerController::OnShowExtensionInstallDialog, |
| 462 weak_ptr_factory_.GetWeakPtr()); |
| 460 | 463 |
| 461 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 464 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
| 462 profile_, this, | 465 profile_, this, |
| 463 &web_contents_->GetController(), id, | 466 &web_contents_->GetController(), id, |
| 464 approval.Pass(), WebstoreInstaller::FLAG_INLINE_INSTALL); | 467 approval.Pass(), WebstoreInstaller::FLAG_INLINE_INSTALL); |
| 465 | 468 |
| 466 pending_async_count_++; | 469 pending_async_count_++; |
| 467 installer->Start(); | 470 installer->Start(); |
| 468 } | 471 } |
| 469 | 472 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 const gfx::Image& icon_image) { | 868 const gfx::Image& icon_image) { |
| 866 picker_model_->SetSuggestedExtensionIconWithId(extension_id, icon_image); | 869 picker_model_->SetSuggestedExtensionIconWithId(extension_id, icon_image); |
| 867 AsyncOperationFinished(); | 870 AsyncOperationFinished(); |
| 868 } | 871 } |
| 869 | 872 |
| 870 void WebIntentPickerController::OnExtensionIconUnavailable( | 873 void WebIntentPickerController::OnExtensionIconUnavailable( |
| 871 const std::string& extension_id) { | 874 const std::string& extension_id) { |
| 872 AsyncOperationFinished(); | 875 AsyncOperationFinished(); |
| 873 } | 876 } |
| 874 | 877 |
| 878 void WebIntentPickerController::OnShowExtensionInstallDialog( |
| 879 gfx::NativeWindow parent, |
| 880 content::PageNavigator* navigator, |
| 881 ExtensionInstallPrompt::Delegate* delegate, |
| 882 const ExtensionInstallPrompt::Prompt& prompt) { |
| 883 picker_model_->SetPendingExtensionInstallDelegate(delegate); |
| 884 picker_model_->SetPendingExtensionInstallPrompt(prompt); |
| 885 if (picker_) |
| 886 picker_->OnShowExtensionInstallDialog(parent, navigator, delegate, prompt); |
| 887 } |
| 888 |
| 875 void WebIntentPickerController::SetWindowDispositionSource( | 889 void WebIntentPickerController::SetWindowDispositionSource( |
| 876 content::WebContents* source, | 890 content::WebContents* source, |
| 877 content::WebIntentsDispatcher* dispatcher) { | 891 content::WebIntentsDispatcher* dispatcher) { |
| 878 DCHECK(source); | 892 DCHECK(source); |
| 879 DCHECK(dispatcher); | 893 DCHECK(dispatcher); |
| 880 window_disposition_source_ = source; | 894 window_disposition_source_ = source; |
| 881 if (window_disposition_source_) { | 895 if (window_disposition_source_) { |
| 882 // This object is self-deleting when the source WebContents is destroyed. | 896 // This object is self-deleting when the source WebContents is destroyed. |
| 883 new SourceWindowObserver(window_disposition_source_, | 897 new SourceWindowObserver(window_disposition_source_, |
| 884 weak_ptr_factory_.GetWeakPtr()); | 898 weak_ptr_factory_.GetWeakPtr()); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 content::DownloadManager* download_manager = | 1098 content::DownloadManager* download_manager = |
| 1085 content::BrowserContext::GetDownloadManager(profile); | 1099 content::BrowserContext::GetDownloadManager(profile); |
| 1086 if (!download_manager) | 1100 if (!download_manager) |
| 1087 return; | 1101 return; |
| 1088 content::DownloadItem* item = | 1102 content::DownloadItem* item = |
| 1089 download_manager->GetDownload(download_id_.local()); | 1103 download_manager->GetDownload(download_id_.local()); |
| 1090 if (item) | 1104 if (item) |
| 1091 item->Cancel(true); | 1105 item->Cancel(true); |
| 1092 download_id_ = content::DownloadId(); | 1106 download_id_ = content::DownloadId(); |
| 1093 } | 1107 } |
| OLD | NEW |