| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 void ExtensionInstallPrompt::ConfirmInstall( | 395 void ExtensionInstallPrompt::ConfirmInstall( |
| 396 Delegate* delegate, | 396 Delegate* delegate, |
| 397 const Extension* extension, | 397 const Extension* extension, |
| 398 const ShowDialogCallback& show_dialog_callback) { | 398 const ShowDialogCallback& show_dialog_callback) { |
| 399 DCHECK(ui_loop_ == MessageLoop::current()); | 399 DCHECK(ui_loop_ == MessageLoop::current()); |
| 400 extension_ = extension; | 400 extension_ = extension; |
| 401 permissions_ = extension->GetActivePermissions(); | 401 permissions_ = extension->GetActivePermissions(); |
| 402 delegate_ = delegate; | 402 delegate_ = delegate; |
| 403 prompt_type_ = INSTALL_PROMPT; | 403 prompt_type_ = INSTALL_PROMPT; |
| 404 show_dialog_callback_ = show_dialog_callback; | 404 show_dialog_callback_ = show_dialog_callback; |
| 405 DCHECK(!show_dialog_callback_.is_null()); | |
| 406 | 405 |
| 407 // We special-case themes to not show any confirm UI. Instead they are | 406 // We special-case themes to not show any confirm UI. Instead they are |
| 408 // immediately installed, and then we show an infobar (see OnInstallSuccess) | 407 // immediately installed, and then we show an infobar (see OnInstallSuccess) |
| 409 // to allow the user to revert if they don't like it. | 408 // to allow the user to revert if they don't like it. |
| 410 // | 409 // |
| 411 // We don't do this in the case where off-store extension installs are | 410 // We don't do this in the case where off-store extension installs are |
| 412 // disabled because in that case, we don't show the dangerous download UI, so | 411 // disabled because in that case, we don't show the dangerous download UI, so |
| 413 // we need the UI confirmation. | 412 // we need the UI confirmation. |
| 414 if (extension->is_theme()) { | 413 if (extension->is_theme()) { |
| 415 if (extension->from_webstore() || | 414 if (extension->from_webstore() || |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 break; | 581 break; |
| 583 } | 582 } |
| 584 default: | 583 default: |
| 585 NOTREACHED() << "Unknown message"; | 584 NOTREACHED() << "Unknown message"; |
| 586 return; | 585 return; |
| 587 } | 586 } |
| 588 | 587 |
| 589 if (AutoConfirmPrompt(delegate_)) | 588 if (AutoConfirmPrompt(delegate_)) |
| 590 return; | 589 return; |
| 591 | 590 |
| 592 DCHECK(!show_dialog_callback_.is_null()); | 591 if (show_dialog_callback_.is_null()) |
| 593 show_dialog_callback_.Run(parent_, navigator_, delegate_, prompt_); | 592 GetDefaultShowDialogCallback().Run(parent_, navigator_, delegate_, prompt_); |
| 593 else |
| 594 show_dialog_callback_.Run(parent_, navigator_, delegate_, prompt_); |
| 594 } | 595 } |
| 595 | 596 |
| 596 namespace chrome { | 597 namespace chrome { |
| 597 | 598 |
| 598 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( | 599 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( |
| 599 Browser* browser) { | 600 Browser* browser) { |
| 600 // |browser| can be NULL in unit tests. | 601 // |browser| can be NULL in unit tests. |
| 601 if (!browser) | 602 if (!browser) |
| 602 return new ExtensionInstallPrompt(NULL, NULL, NULL); | 603 return new ExtensionInstallPrompt(NULL, NULL, NULL); |
| 603 gfx::NativeWindow parent = | 604 gfx::NativeWindow parent = |
| 604 browser->window() ? browser->window()->GetNativeWindow() : NULL; | 605 browser->window() ? browser->window()->GetNativeWindow() : NULL; |
| 605 return new ExtensionInstallPrompt(parent, browser, browser->profile()); | 606 return new ExtensionInstallPrompt(parent, browser, browser->profile()); |
| 606 } | 607 } |
| 607 | 608 |
| 608 } // namespace chrome | 609 } // namespace chrome |
| OLD | NEW |