| 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/ui/webui/extensions/install_extension_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/install_extension_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/crx_installer.h" | 10 #include "chrome/browser/extensions/crx_installer.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 LOG(ERROR) << "No file captured to install."; | 79 LOG(ERROR) << "No file captured to install."; |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 | 82 |
| 83 Browser* browser = browser::FindBrowserWithWebContents( | 83 Browser* browser = browser::FindBrowserWithWebContents( |
| 84 web_ui()->GetWebContents()); | 84 web_ui()->GetWebContents()); |
| 85 Profile* profile = browser->profile(); | 85 Profile* profile = browser->profile(); |
| 86 scoped_refptr<CrxInstaller> crx_installer( | 86 scoped_refptr<CrxInstaller> crx_installer( |
| 87 CrxInstaller::Create( | 87 CrxInstaller::Create( |
| 88 ExtensionSystem::Get(profile)->extension_service(), | 88 ExtensionSystem::Get(profile)->extension_service(), |
| 89 new ExtensionInstallPrompt(browser))); | 89 chrome::CreateExtensionInstallPromptWithBrowser(browser))); |
| 90 crx_installer->set_off_store_install_allow_reason( | 90 crx_installer->set_off_store_install_allow_reason( |
| 91 CrxInstaller::OffStoreInstallAllowedFromSettingsPage); | 91 CrxInstaller::OffStoreInstallAllowedFromSettingsPage); |
| 92 | 92 |
| 93 const bool kCaseSensitive = false; | 93 const bool kCaseSensitive = false; |
| 94 | 94 |
| 95 // Have to use EndsWith() because FilePath::Extension() would return ".js" for | 95 // Have to use EndsWith() because FilePath::Extension() would return ".js" for |
| 96 // "foo.user.js". | 96 // "foo.user.js". |
| 97 if (EndsWith(file_to_install_.BaseName().value(), | 97 if (EndsWith(file_to_install_.BaseName().value(), |
| 98 FILE_PATH_LITERAL(".user.js"), | 98 FILE_PATH_LITERAL(".user.js"), |
| 99 kCaseSensitive)) { | 99 kCaseSensitive)) { |
| 100 crx_installer->InstallUserScript( | 100 crx_installer->InstallUserScript( |
| 101 file_to_install_, | 101 file_to_install_, |
| 102 net::FilePathToFileURL(file_to_install_)); | 102 net::FilePathToFileURL(file_to_install_)); |
| 103 } else if (EndsWith(file_to_install_.BaseName().value(), | 103 } else if (EndsWith(file_to_install_.BaseName().value(), |
| 104 FILE_PATH_LITERAL(".crx"), | 104 FILE_PATH_LITERAL(".crx"), |
| 105 kCaseSensitive)) { | 105 kCaseSensitive)) { |
| 106 crx_installer->InstallCrx(file_to_install_); | 106 crx_installer->InstallCrx(file_to_install_); |
| 107 } else { | 107 } else { |
| 108 CHECK(false); | 108 CHECK(false); |
| 109 } | 109 } |
| 110 | 110 |
| 111 file_to_install_.clear(); | 111 file_to_install_.clear(); |
| 112 } | 112 } |
| OLD | NEW |