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