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/pack_extension_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/pack_extension_handler.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_creator.h" | 7 #include "chrome/browser/extensions/extension_creator.h" |
8 #include "chrome/browser/ui/chrome_select_file_policy.h" | 8 #include "chrome/browser/ui/chrome_select_file_policy.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 DCHECK_EQ(2U, args->GetSize()); | 150 DCHECK_EQ(2U, args->GetSize()); |
151 | 151 |
152 std::string select_type; | 152 std::string select_type; |
153 if (!args->GetString(0, &select_type)) | 153 if (!args->GetString(0, &select_type)) |
154 NOTREACHED(); | 154 NOTREACHED(); |
155 | 155 |
156 std::string operation; | 156 std::string operation; |
157 if (!args->GetString(1, &operation)) | 157 if (!args->GetString(1, &operation)) |
158 NOTREACHED(); | 158 NOTREACHED(); |
159 | 159 |
160 SelectFileDialog::Type type = SelectFileDialog::SELECT_FOLDER; | 160 ui::SelectFileDialog::Type type = ui::SelectFileDialog::SELECT_FOLDER; |
161 SelectFileDialog::FileTypeInfo info; | 161 ui::SelectFileDialog::FileTypeInfo info; |
162 int file_type_index = 0; | 162 int file_type_index = 0; |
163 if (select_type == "file") | 163 if (select_type == "file") |
164 type = SelectFileDialog::SELECT_OPEN_FILE; | 164 type = ui::SelectFileDialog::SELECT_OPEN_FILE; |
165 | 165 |
166 string16 select_title; | 166 string16 select_title; |
167 if (operation == "load") { | 167 if (operation == "load") { |
168 select_title = l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); | 168 select_title = l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); |
169 } else if (operation == "pem") { | 169 } else if (operation == "pem") { |
170 select_title = l10n_util::GetStringUTF16( | 170 select_title = l10n_util::GetStringUTF16( |
171 IDS_EXTENSION_PACK_DIALOG_SELECT_KEY); | 171 IDS_EXTENSION_PACK_DIALOG_SELECT_KEY); |
172 info.extensions.push_back(std::vector<FilePath::StringType>()); | 172 info.extensions.push_back(std::vector<FilePath::StringType>()); |
173 info.extensions.front().push_back(FILE_PATH_LITERAL("pem")); | 173 info.extensions.front().push_back(FILE_PATH_LITERAL("pem")); |
174 info.extension_description_overrides.push_back( | 174 info.extension_description_overrides.push_back( |
175 l10n_util::GetStringUTF16( | 175 l10n_util::GetStringUTF16( |
176 IDS_EXTENSION_PACK_DIALOG_KEY_FILE_TYPE_DESCRIPTION)); | 176 IDS_EXTENSION_PACK_DIALOG_KEY_FILE_TYPE_DESCRIPTION)); |
177 info.include_all_files = true; | 177 info.include_all_files = true; |
178 file_type_index = 1; | 178 file_type_index = 1; |
179 } else { | 179 } else { |
180 NOTREACHED(); | 180 NOTREACHED(); |
181 } | 181 } |
182 | 182 |
183 load_extension_dialog_ = SelectFileDialog::Create( | 183 load_extension_dialog_ = ui::SelectFileDialog::Create( |
184 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); | 184 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); |
185 load_extension_dialog_->SelectFile( | 185 load_extension_dialog_->SelectFile( |
186 type, select_title, FilePath(), &info, file_type_index, | 186 type, select_title, FilePath(), &info, file_type_index, |
187 FILE_PATH_LITERAL(""), | 187 FILE_PATH_LITERAL(""), |
188 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), | 188 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), |
189 NULL); | 189 NULL); |
190 } | 190 } |
191 | 191 |
192 void PackExtensionHandler::ShowAlert(const std::string& message) { | 192 void PackExtensionHandler::ShowAlert(const std::string& message) { |
193 ListValue arguments; | 193 ListValue arguments; |
194 arguments.Append(Value::CreateStringValue(message)); | 194 arguments.Append(Value::CreateStringValue(message)); |
195 web_ui()->CallJavascriptFunction("PackExtensionOverlay.showError", arguments); | 195 web_ui()->CallJavascriptFunction("PackExtensionOverlay.showError", arguments); |
196 } | 196 } |
OLD | NEW |