OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/external_install_error.h" | 5 #include "chrome/browser/extensions/external_install_error.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/external_install_manager.h" | 12 #include "chrome/browser/extensions/external_install_manager.h" |
12 #include "chrome/browser/extensions/webstore_data_fetcher.h" | 13 #include "chrome/browser/extensions/webstore_data_fetcher.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
16 #include "chrome/browser/ui/global_error/global_error.h" | 17 #include "chrome/browser/ui/global_error/global_error.h" |
17 #include "chrome/browser/ui/global_error/global_error_service.h" | 18 #include "chrome/browser/ui/global_error/global_error_service.h" |
18 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 19 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 manager_->RemoveExternalInstallError(); | 313 manager_->RemoveExternalInstallError(); |
313 } | 314 } |
314 } | 315 } |
315 | 316 |
316 void ExternalInstallError::ShowDialog(Browser* browser) { | 317 void ExternalInstallError::ShowDialog(Browser* browser) { |
317 DCHECK(install_ui_.get()); | 318 DCHECK(install_ui_.get()); |
318 DCHECK(prompt_.get()); | 319 DCHECK(prompt_.get()); |
319 DCHECK(browser); | 320 DCHECK(browser); |
320 content::WebContents* web_contents = NULL; | 321 content::WebContents* web_contents = NULL; |
321 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 322 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
322 ExtensionInstallPrompt::ShowParams params(web_contents); | 323 install_ui_show_params_.reset( |
| 324 new ExtensionInstallPromptShowParams(web_contents)); |
323 ExtensionInstallPrompt::GetDefaultShowDialogCallback().Run( | 325 ExtensionInstallPrompt::GetDefaultShowDialogCallback().Run( |
324 params, this, prompt_); | 326 install_ui_show_params_.get(), this, prompt_); |
325 } | 327 } |
326 | 328 |
327 const Extension* ExternalInstallError::GetExtension() const { | 329 const Extension* ExternalInstallError::GetExtension() const { |
328 return ExtensionRegistry::Get(browser_context_) | 330 return ExtensionRegistry::Get(browser_context_) |
329 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); | 331 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); |
330 } | 332 } |
331 | 333 |
332 void ExternalInstallError::OnWebstoreRequestFailure() { | 334 void ExternalInstallError::OnWebstoreRequestFailure() { |
333 OnFetchComplete(); | 335 OnFetchComplete(); |
334 } | 336 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 372 |
371 install_ui_->ConfirmExternalInstall( | 373 install_ui_->ConfirmExternalInstall( |
372 this, | 374 this, |
373 GetExtension(), | 375 GetExtension(), |
374 base::Bind(&ExternalInstallError::OnDialogReady, | 376 base::Bind(&ExternalInstallError::OnDialogReady, |
375 weak_factory_.GetWeakPtr()), | 377 weak_factory_.GetWeakPtr()), |
376 prompt_); | 378 prompt_); |
377 } | 379 } |
378 | 380 |
379 void ExternalInstallError::OnDialogReady( | 381 void ExternalInstallError::OnDialogReady( |
380 const ExtensionInstallPrompt::ShowParams& show_params, | 382 ExtensionInstallPromptShowParams* show_params, |
381 ExtensionInstallPrompt::Delegate* prompt_delegate, | 383 ExtensionInstallPrompt::Delegate* prompt_delegate, |
382 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { | 384 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { |
383 DCHECK_EQ(this, prompt_delegate); | 385 DCHECK_EQ(this, prompt_delegate); |
384 prompt_ = prompt; | 386 prompt_ = prompt; |
385 | 387 |
386 if (alert_type_ == BUBBLE_ALERT) { | 388 if (alert_type_ == BUBBLE_ALERT) { |
387 global_error_.reset(new ExternalInstallBubbleAlert(this, prompt_.get())); | 389 global_error_.reset(new ExternalInstallBubbleAlert(this, prompt_.get())); |
388 error_service_->AddGlobalError(global_error_.get()); | 390 error_service_->AddGlobalError(global_error_.get()); |
389 | 391 |
390 Browser* browser = | 392 Browser* browser = |
391 chrome::FindTabbedBrowser(Profile::FromBrowserContext(browser_context_), | 393 chrome::FindTabbedBrowser(Profile::FromBrowserContext(browser_context_), |
392 true, | 394 true, |
393 chrome::GetActiveDesktop()); | 395 chrome::GetActiveDesktop()); |
394 if (browser) | 396 if (browser) |
395 global_error_->ShowBubbleView(browser); | 397 global_error_->ShowBubbleView(browser); |
396 } else { | 398 } else { |
397 DCHECK(alert_type_ == MENU_ALERT); | 399 DCHECK(alert_type_ == MENU_ALERT); |
398 global_error_.reset(new ExternalInstallMenuAlert(this)); | 400 global_error_.reset(new ExternalInstallMenuAlert(this)); |
399 error_service_->AddGlobalError(global_error_.get()); | 401 error_service_->AddGlobalError(global_error_.get()); |
400 } | 402 } |
401 } | 403 } |
402 | 404 |
403 } // namespace extensions | 405 } // namespace extensions |
OLD | NEW |