Index: chrome/browser/extensions/extension_install_dialog.cc |
diff --git a/chrome/browser/extensions/extension_install_dialog.cc b/chrome/browser/extensions/extension_install_dialog.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a58e2595c51a385602fbe2807dc5ea89ab9c502a |
--- /dev/null |
+++ b/chrome/browser/extensions/extension_install_dialog.cc |
@@ -0,0 +1,74 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/extensions/extension_install_dialog.h" |
+ |
+#include "base/file_path.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/values.h" |
+#include "chrome/common/extensions/extension.h" |
+ |
+// A flag used for SetExtensionInstallDialogForManifestAutoConfirmForTests |
+enum AutoConfirmForTest { |
+ DO_NOT_SKIP = 0, |
+ PROCEED, |
+ ABORT |
+}; |
+AutoConfirmForTest auto_confirm_for_tests = DO_NOT_SKIP; |
+ |
+void ShowExtensionInstallDialogForManifest( |
+ Profile *profile, |
+ ExtensionInstallUI::Delegate* delegate, |
+ const DictionaryValue* manifest, |
+ const std::string& id, |
+ const std::string& localized_name, |
+ SkBitmap* icon, |
+ ExtensionInstallUI::PromptType type, |
+ scoped_refptr<Extension>* dummy_extension) { |
+ scoped_ptr<DictionaryValue> localized_manifest; |
+ if (!localized_name.empty()) { |
+ localized_manifest.reset(manifest->DeepCopy()); |
+ localized_manifest->SetString(extension_manifest_keys::kName, |
+ localized_name); |
+ } |
+ |
+ std::string init_errors; |
+ *dummy_extension = Extension::CreateWithId( |
+ FilePath(), |
+ Extension::INTERNAL, |
+ localized_manifest.get() ? *localized_manifest.get() : *manifest, |
+ Extension::NO_FLAGS, |
+ id, |
+ &init_errors); |
+ if (!dummy_extension->get()) { |
+ return; |
+ } |
+ |
+ if (icon->empty()) |
+ icon = const_cast<SkBitmap*>(&Extension::GetDefaultIcon( |
+ (*dummy_extension)->is_app())); |
+ |
+ // In tests, we may have setup to proceed or abort without putting up the real |
+ // confirmation dialog. |
+ if (auto_confirm_for_tests != DO_NOT_SKIP) { |
+ if (auto_confirm_for_tests == PROCEED) |
+ delegate->InstallUIProceed(); |
+ else |
+ delegate->InstallUIAbort(true); |
+ return; |
+ } |
+ |
+ ShowExtensionInstallDialog(profile, |
+ delegate, |
+ dummy_extension->get(), |
+ icon, |
+ (*dummy_extension)->GetPermissionMessageStrings(), |
+ ExtensionInstallUI::INSTALL_PROMPT); |
+ return; |
+} |
+ |
+void SetExtensionInstallDialogForManifestAutoConfirmForTests( |
+ bool should_proceed) { |
+ auto_confirm_for_tests = should_proceed ? PROCEED : ABORT; |
+} |