| 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/extensions/extension_install_prompt.h" | 5 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 FetchOAuthIssueAdviceIfNeeded(); | 348 FetchOAuthIssueAdviceIfNeeded(); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void ExtensionInstallPrompt::ConfirmWebstoreInstall(Delegate* delegate, | 351 void ExtensionInstallPrompt::ConfirmWebstoreInstall(Delegate* delegate, |
| 352 const Extension* extension, | 352 const Extension* extension, |
| 353 const SkBitmap* icon) { | 353 const SkBitmap* icon) { |
| 354 // SetIcon requires |extension_| to be set. ConfirmInstall will setup the | 354 // SetIcon requires |extension_| to be set. ConfirmInstall will setup the |
| 355 // remaining fields. | 355 // remaining fields. |
| 356 extension_ = extension; | 356 extension_ = extension; |
| 357 SetIcon(icon); | 357 SetIcon(icon); |
| 358 ConfirmInstall(delegate, extension); | 358 ConfirmInstall(delegate, |
| 359 extension, |
| 360 base::Bind(ShowExtensionInstallDialogImpl)); |
| 359 } | 361 } |
| 360 | 362 |
| 361 void ExtensionInstallPrompt::ConfirmInstall(Delegate* delegate, | 363 void ExtensionInstallPrompt::ConfirmInstall( |
| 362 const Extension* extension) { | 364 Delegate* delegate, |
| 365 const Extension* extension, |
| 366 const ShowDialogCallback& show_dialog_callback) { |
| 363 DCHECK(ui_loop_ == MessageLoop::current()); | 367 DCHECK(ui_loop_ == MessageLoop::current()); |
| 364 extension_ = extension; | 368 extension_ = extension; |
| 365 permissions_ = extension->GetActivePermissions(); | 369 permissions_ = extension->GetActivePermissions(); |
| 366 delegate_ = delegate; | 370 delegate_ = delegate; |
| 367 prompt_type_ = INSTALL_PROMPT; | 371 prompt_type_ = INSTALL_PROMPT; |
| 372 show_dialog_callback_ = show_dialog_callback; |
| 368 | 373 |
| 369 // We special-case themes to not show any confirm UI. Instead they are | 374 // We special-case themes to not show any confirm UI. Instead they are |
| 370 // immediately installed, and then we show an infobar (see OnInstallSuccess) | 375 // immediately installed, and then we show an infobar (see OnInstallSuccess) |
| 371 // to allow the user to revert if they don't like it. | 376 // to allow the user to revert if they don't like it. |
| 372 // | 377 // |
| 373 // We don't do this in the case where off-store extension installs are | 378 // We don't do this in the case where off-store extension installs are |
| 374 // disabled because in that case, we don't show the dangerous download UI, so | 379 // disabled because in that case, we don't show the dangerous download UI, so |
| 375 // we need the UI confirmation. | 380 // we need the UI confirmation. |
| 376 if (extension->is_theme()) { | 381 if (extension->is_theme()) { |
| 377 if (extension->from_webstore() || | 382 if (extension->from_webstore() || |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 prompt_.SetPermissions(permissions_->GetWarningMessages(extension_type)); | 535 prompt_.SetPermissions(permissions_->GetWarningMessages(extension_type)); |
| 531 } | 536 } |
| 532 | 537 |
| 533 switch (prompt_type_) { | 538 switch (prompt_type_) { |
| 534 case PERMISSIONS_PROMPT: | 539 case PERMISSIONS_PROMPT: |
| 535 case RE_ENABLE_PROMPT: | 540 case RE_ENABLE_PROMPT: |
| 536 case INLINE_INSTALL_PROMPT: | 541 case INLINE_INSTALL_PROMPT: |
| 537 case INSTALL_PROMPT: { | 542 case INSTALL_PROMPT: { |
| 538 prompt_.set_extension(extension_); | 543 prompt_.set_extension(extension_); |
| 539 prompt_.set_icon(gfx::Image(icon_)); | 544 prompt_.set_icon(gfx::Image(icon_)); |
| 540 ShowExtensionInstallDialog(parent_, navigator_, delegate_, prompt_); | 545 ShowExtensionInstallDialog(parent_, |
| 546 navigator_, |
| 547 delegate_, |
| 548 prompt_, |
| 549 show_dialog_callback_); |
| 541 break; | 550 break; |
| 542 } | 551 } |
| 543 case BUNDLE_INSTALL_PROMPT: { | 552 case BUNDLE_INSTALL_PROMPT: { |
| 544 prompt_.set_bundle(bundle_); | 553 prompt_.set_bundle(bundle_); |
| 545 ShowExtensionInstallDialog(parent_, navigator_, delegate_, prompt_); | 554 ShowExtensionInstallDialog(parent_, |
| 555 navigator_, |
| 556 delegate_, |
| 557 prompt_, |
| 558 show_dialog_callback_); |
| 546 break; | 559 break; |
| 547 } | 560 } |
| 548 default: | 561 default: |
| 549 NOTREACHED() << "Unknown message"; | 562 NOTREACHED() << "Unknown message"; |
| 550 break; | 563 break; |
| 551 } | 564 } |
| 552 } | 565 } |
| 553 | 566 |
| 554 namespace chrome { | 567 namespace chrome { |
| 555 | 568 |
| 556 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( | 569 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( |
| 557 Browser* browser) { | 570 Browser* browser) { |
| 558 // |browser| can be NULL in unit tests. | 571 // |browser| can be NULL in unit tests. |
| 559 if (!browser) | 572 if (!browser) |
| 560 return new ExtensionInstallPrompt(NULL, NULL, NULL); | 573 return new ExtensionInstallPrompt(NULL, NULL, NULL); |
| 561 gfx::NativeWindow parent = | 574 gfx::NativeWindow parent = |
| 562 browser->window() ? browser->window()->GetNativeWindow() : NULL; | 575 browser->window() ? browser->window()->GetNativeWindow() : NULL; |
| 563 return new ExtensionInstallPrompt(parent, browser, browser->profile()); | 576 return new ExtensionInstallPrompt(parent, browser, browser->profile()); |
| 564 } | 577 } |
| 565 | 578 |
| 566 } // namespace chrome | 579 } // namespace chrome |
| OLD | NEW |