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