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" |
11 #include "chrome/browser/extensions/extension_install_ui.h" | 11 #include "chrome/browser/extensions/extension_install_prompt.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_system.h" | 13 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/extensions/extension_switch_utils.h" | 15 #include "chrome/common/extensions/extension_switch_utils.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/browser/web_contents_view.h" | 17 #include "content/public/browser/web_contents_view.h" |
18 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 void InstallExtensionHandler::HandleInstallMessage(const ListValue* args) { | 76 void InstallExtensionHandler::HandleInstallMessage(const ListValue* args) { |
77 if (file_to_install_.empty()) { | 77 if (file_to_install_.empty()) { |
78 LOG(ERROR) << "No file captured to install."; | 78 LOG(ERROR) << "No file captured to install."; |
79 return; | 79 return; |
80 } | 80 } |
81 | 81 |
82 Profile* profile = Profile::FromWebUI(web_ui()); | 82 Profile* profile = Profile::FromWebUI(web_ui()); |
83 scoped_refptr<CrxInstaller> crx_installer( | 83 scoped_refptr<CrxInstaller> crx_installer( |
84 CrxInstaller::Create( | 84 CrxInstaller::Create( |
85 ExtensionSystem::Get(profile)->extension_service(), | 85 ExtensionSystem::Get(profile)->extension_service(), |
86 new ExtensionInstallUI(profile))); | 86 new ExtensionInstallPrompt(profile))); |
87 crx_installer->set_allow_off_store_install(true); | 87 crx_installer->set_allow_off_store_install(true); |
88 | 88 |
89 const bool kCaseSensitive = false; | 89 const bool kCaseSensitive = false; |
90 | 90 |
91 // Have to use EndsWith() because FilePath::Extension() would return ".js" for | 91 // Have to use EndsWith() because FilePath::Extension() would return ".js" for |
92 // "foo.user.js". | 92 // "foo.user.js". |
93 if (EndsWith(file_to_install_.BaseName().value(), | 93 if (EndsWith(file_to_install_.BaseName().value(), |
94 FILE_PATH_LITERAL(".user.js"), | 94 FILE_PATH_LITERAL(".user.js"), |
95 kCaseSensitive)) { | 95 kCaseSensitive)) { |
96 crx_installer->InstallUserScript( | 96 crx_installer->InstallUserScript( |
97 file_to_install_, | 97 file_to_install_, |
98 net::FilePathToFileURL(file_to_install_)); | 98 net::FilePathToFileURL(file_to_install_)); |
99 } else if (EndsWith(file_to_install_.BaseName().value(), | 99 } else if (EndsWith(file_to_install_.BaseName().value(), |
100 FILE_PATH_LITERAL(".crx"), | 100 FILE_PATH_LITERAL(".crx"), |
101 kCaseSensitive)) { | 101 kCaseSensitive)) { |
102 crx_installer->InstallCrx(file_to_install_); | 102 crx_installer->InstallCrx(file_to_install_); |
103 } else { | 103 } else { |
104 CHECK(false); | 104 CHECK(false); |
105 } | 105 } |
106 | 106 |
107 file_to_install_.clear(); | 107 file_to_install_.clear(); |
108 } | 108 } |
OLD | NEW |