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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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<extensions::CrxInstaller> crx_installer( | 86 scoped_refptr<extensions::CrxInstaller> crx_installer( |
87 extensions::CrxInstaller::Create( | 87 extensions::CrxInstaller::Create( |
88 extensions::ExtensionSystem::Get(profile)->extension_service(), | 88 extensions::ExtensionSystem::Get(profile)->extension_service(), |
89 chrome::CreateExtensionInstallPromptWithBrowser(browser))); | 89 chrome::CreateExtensionInstallPromptWithBrowser(browser))); |
| 90 crx_installer->set_error_on_unsported_requirements(true); |
90 crx_installer->set_off_store_install_allow_reason( | 91 crx_installer->set_off_store_install_allow_reason( |
91 extensions::CrxInstaller::OffStoreInstallAllowedFromSettingsPage); | 92 extensions::CrxInstaller::OffStoreInstallAllowedFromSettingsPage); |
92 | 93 |
93 const bool kCaseSensitive = false; | 94 const bool kCaseSensitive = false; |
94 | 95 |
95 // Have to use EndsWith() because FilePath::Extension() would return ".js" for | 96 // Have to use EndsWith() because FilePath::Extension() would return ".js" for |
96 // "foo.user.js". | 97 // "foo.user.js". |
97 if (EndsWith(file_to_install_.BaseName().value(), | 98 if (EndsWith(file_to_install_.BaseName().value(), |
98 FILE_PATH_LITERAL(".user.js"), | 99 FILE_PATH_LITERAL(".user.js"), |
99 kCaseSensitive)) { | 100 kCaseSensitive)) { |
100 crx_installer->InstallUserScript( | 101 crx_installer->InstallUserScript( |
101 file_to_install_, | 102 file_to_install_, |
102 net::FilePathToFileURL(file_to_install_)); | 103 net::FilePathToFileURL(file_to_install_)); |
103 } else if (EndsWith(file_to_install_.BaseName().value(), | 104 } else if (EndsWith(file_to_install_.BaseName().value(), |
104 FILE_PATH_LITERAL(".crx"), | 105 FILE_PATH_LITERAL(".crx"), |
105 kCaseSensitive)) { | 106 kCaseSensitive)) { |
106 crx_installer->InstallCrx(file_to_install_); | 107 crx_installer->InstallCrx(file_to_install_); |
107 } else { | 108 } else { |
108 CHECK(false); | 109 CHECK(false); |
109 } | 110 } |
110 | 111 |
111 file_to_install_.clear(); | 112 file_to_install_.clear(); |
112 } | 113 } |
OLD | NEW |