| 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_dialog.h" | 5 #include "chrome/browser/extensions/extension_install_dialog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void ShowExtensionInstallDialog(Profile* profile, | 63 void ShowExtensionInstallDialog(Profile* profile, |
| 64 ExtensionInstallUI::Delegate* delegate, | 64 ExtensionInstallUI::Delegate* delegate, |
| 65 const ExtensionInstallUI::Prompt& prompt) { | 65 const ExtensionInstallUI::Prompt& prompt) { |
| 66 AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch(); | 66 AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch(); |
| 67 if (auto_confirm != DO_NOT_SKIP) { | 67 if (auto_confirm != DO_NOT_SKIP) { |
| 68 DoAutoConfirm(auto_confirm, delegate); | 68 DoAutoConfirm(auto_confirm, delegate); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 ShowExtensionInstallDialogImpl(profile, delegate, prompt); | 71 ShowExtensionInstallDialogImpl(profile, delegate, prompt); |
| 72 } | 72 } |
| 73 | |
| 74 bool ShowExtensionInstallDialogForManifest( | |
| 75 Profile* profile, | |
| 76 ExtensionInstallUI::Delegate* delegate, | |
| 77 const DictionaryValue* manifest, | |
| 78 const std::string& id, | |
| 79 const std::string& localized_name, | |
| 80 const std::string& localized_description, | |
| 81 SkBitmap* icon, | |
| 82 const ExtensionInstallUI::Prompt& prompt, | |
| 83 scoped_refptr<Extension>* dummy_extension) { | |
| 84 scoped_ptr<DictionaryValue> localized_manifest; | |
| 85 if (!localized_name.empty() || !localized_description.empty()) { | |
| 86 localized_manifest.reset(manifest->DeepCopy()); | |
| 87 if (!localized_name.empty()) { | |
| 88 localized_manifest->SetString(extension_manifest_keys::kName, | |
| 89 localized_name); | |
| 90 } | |
| 91 if (!localized_description.empty()) { | |
| 92 localized_manifest->SetString(extension_manifest_keys::kDescription, | |
| 93 localized_description); | |
| 94 } | |
| 95 } | |
| 96 | |
| 97 std::string init_errors; | |
| 98 *dummy_extension = Extension::Create( | |
| 99 FilePath(), | |
| 100 Extension::INTERNAL, | |
| 101 localized_manifest.get() ? *localized_manifest.get() : *manifest, | |
| 102 Extension::NO_FLAGS, | |
| 103 id, | |
| 104 &init_errors); | |
| 105 if (!dummy_extension->get()) { | |
| 106 return false; | |
| 107 } | |
| 108 | |
| 109 if (icon->empty()) | |
| 110 icon = const_cast<SkBitmap*>(&Extension::GetDefaultIcon( | |
| 111 (*dummy_extension)->is_app())); | |
| 112 | |
| 113 // In tests, we may have setup to proceed or abort without putting up the real | |
| 114 // confirmation dialog. | |
| 115 AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch(); | |
| 116 if (auto_confirm != DO_NOT_SKIP) { | |
| 117 DoAutoConfirm(auto_confirm, delegate); | |
| 118 return true; | |
| 119 } | |
| 120 | |
| 121 ExtensionInstallUI::Prompt filled_out_prompt = prompt; | |
| 122 filled_out_prompt.SetPermissions( | |
| 123 (*dummy_extension)->GetPermissionMessageStrings()); | |
| 124 filled_out_prompt.set_extension(*dummy_extension); | |
| 125 filled_out_prompt.set_icon(gfx::Image(new SkBitmap(*icon))); | |
| 126 | |
| 127 ShowExtensionInstallDialog(profile, delegate, filled_out_prompt); | |
| 128 return true; | |
| 129 } | |
| OLD | NEW |