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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/crx_installer.h" | 10 #include "chrome/browser/extensions/crx_installer.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 | 92 |
93 void InstallExtensionHandler::HandleInstallMessage( | 93 void InstallExtensionHandler::HandleInstallMessage( |
94 const base::ListValue* args) { | 94 const base::ListValue* args) { |
95 if (file_to_install_.empty()) { | 95 if (file_to_install_.empty()) { |
96 LOG(ERROR) << "No file captured to install."; | 96 LOG(ERROR) << "No file captured to install."; |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 Profile* profile = Profile::FromBrowserContext( | 100 Profile* profile = Profile::FromBrowserContext( |
101 web_ui()->GetWebContents()->GetBrowserContext()); | 101 web_ui()->GetWebContents()->GetBrowserContext()); |
102 scoped_ptr<ExtensionInstallPrompt> prompt( | |
103 new ExtensionInstallPrompt(web_ui()->GetWebContents())); | |
104 scoped_refptr<CrxInstaller> crx_installer(CrxInstaller::Create( | |
105 ExtensionSystem::Get(profile)->extension_service(), | |
106 prompt.Pass())); | |
107 crx_installer->set_error_on_unsupported_requirements(true); | |
108 crx_installer->set_off_store_install_allow_reason( | |
109 CrxInstaller::OffStoreInstallAllowedFromSettingsPage); | |
110 crx_installer->set_install_immediately(true); | |
111 | 102 |
112 const bool kCaseSensitive = false; | 103 const bool kCaseSensitive = false; |
113 | 104 |
114 if (EndsWith(file_display_name_, | 105 if (EndsWith( |
115 base::ASCIIToUTF16(".user.js"), | 106 file_display_name_, base::ASCIIToUTF16(".zip"), kCaseSensitive)) { |
asargent_no_longer_on_chrome
2014/07/29 21:38:10
should this be case insensitive?
elijahtaylor1
2014/07/31 17:26:27
This is unfortunately named, but is set false abov
| |
116 kCaseSensitive)) { | 107 UnpackedInstaller::Create( |
117 crx_installer->InstallUserScript( | 108 ExtensionSystem::Get(profile)->extension_service()) |
118 file_to_install_, | 109 ->LoadFromZipFile(file_to_install_); |
119 net::FilePathToFileURL(file_to_install_)); | |
120 } else if (EndsWith(file_display_name_, | |
121 base::ASCIIToUTF16(".crx"), | |
122 kCaseSensitive)) { | |
123 crx_installer->InstallCrx(file_to_install_); | |
124 } else { | 110 } else { |
125 CHECK(false); | 111 scoped_ptr<ExtensionInstallPrompt> prompt( |
112 new ExtensionInstallPrompt(web_ui()->GetWebContents())); | |
113 scoped_refptr<CrxInstaller> crx_installer(CrxInstaller::Create( | |
114 ExtensionSystem::Get(profile)->extension_service(), prompt.Pass())); | |
115 crx_installer->set_error_on_unsupported_requirements(true); | |
116 crx_installer->set_off_store_install_allow_reason( | |
117 CrxInstaller::OffStoreInstallAllowedFromSettingsPage); | |
118 crx_installer->set_install_immediately(true); | |
119 | |
120 if (EndsWith(file_display_name_, | |
121 base::ASCIIToUTF16(".user.js"), | |
122 kCaseSensitive)) { | |
123 crx_installer->InstallUserScript( | |
124 file_to_install_, net::FilePathToFileURL(file_to_install_)); | |
125 } else if (EndsWith(file_display_name_, | |
126 base::ASCIIToUTF16(".crx"), | |
127 kCaseSensitive)) { | |
128 crx_installer->InstallCrx(file_to_install_); | |
129 } else { | |
130 CHECK(false); | |
131 } | |
126 } | 132 } |
127 | 133 |
128 file_to_install_.clear(); | 134 file_to_install_.clear(); |
129 file_display_name_.clear(); | 135 file_display_name_.clear(); |
130 } | 136 } |
131 | 137 |
132 void InstallExtensionHandler::HandleInstallDirectoryMessage( | 138 void InstallExtensionHandler::HandleInstallDirectoryMessage( |
133 const base::ListValue* args) { | 139 const base::ListValue* args) { |
134 Profile* profile = Profile::FromBrowserContext( | 140 Profile* profile = Profile::FromBrowserContext( |
135 web_ui()->GetWebContents()->GetBrowserContext()); | 141 web_ui()->GetWebContents()->GetBrowserContext()); |
136 UnpackedInstaller::Create( | 142 UnpackedInstaller::Create( |
137 ExtensionSystem::Get(profile)-> | 143 ExtensionSystem::Get(profile)-> |
138 extension_service())->Load(file_to_install_); | 144 extension_service())->Load(file_to_install_); |
139 } | 145 } |
140 | 146 |
141 } // namespace extensions | 147 } // namespace extensions |
OLD | NEW |