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