| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_creator.h" | 9 #include "chrome/browser/extensions/extension_creator.h" |
| 10 #include "chrome/browser/ui/chrome_select_file_policy.h" | 10 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 base::Unretained(this))); | 66 base::Unretained(this))); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void PackExtensionHandler::OnPackSuccess(const base::FilePath& crx_file, | 69 void PackExtensionHandler::OnPackSuccess(const base::FilePath& crx_file, |
| 70 const base::FilePath& pem_file) { | 70 const base::FilePath& pem_file) { |
| 71 ListValue arguments; | 71 ListValue arguments; |
| 72 arguments.Append(Value::CreateStringValue( | 72 arguments.Append(Value::CreateStringValue( |
| 73 UTF16ToUTF8(PackExtensionJob::StandardSuccessMessage( | 73 UTF16ToUTF8(PackExtensionJob::StandardSuccessMessage( |
| 74 crx_file, pem_file)))); | 74 crx_file, pem_file)))); |
| 75 web_ui()->CallJavascriptFunction( | 75 web_ui()->CallJavascriptFunction( |
| 76 "PackExtensionOverlay.showSuccessMessage", arguments); | 76 "extensions.PackExtensionOverlay.showSuccessMessage", arguments); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void PackExtensionHandler::OnPackFailure(const std::string& error, | 79 void PackExtensionHandler::OnPackFailure(const std::string& error, |
| 80 ExtensionCreator::ErrorType type) { | 80 ExtensionCreator::ErrorType type) { |
| 81 if (type == ExtensionCreator::kCRXExists) { | 81 if (type == ExtensionCreator::kCRXExists) { |
| 82 base::StringValue error_str(error); | 82 base::StringValue error_str(error); |
| 83 base::StringValue extension_path_str(extension_path_.value()); | 83 base::StringValue extension_path_str(extension_path_.value()); |
| 84 base::StringValue key_path_str(private_key_path_.value()); | 84 base::StringValue key_path_str(private_key_path_.value()); |
| 85 base::FundamentalValue overwrite_flag(ExtensionCreator::kOverwriteCRX); | 85 base::FundamentalValue overwrite_flag(ExtensionCreator::kOverwriteCRX); |
| 86 | 86 |
| 87 web_ui()->CallJavascriptFunction( | 87 web_ui()->CallJavascriptFunction( |
| 88 "ExtensionSettings.askToOverrideWarning", error_str, extension_path_str, | 88 "extensions.ExtensionSettings.askToOverrideWarning", |
| 89 key_path_str, overwrite_flag); | 89 error_str, extension_path_str, key_path_str, overwrite_flag); |
| 90 } else { | 90 } else { |
| 91 ShowAlert(error); | 91 ShowAlert(error); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 void PackExtensionHandler::FileSelected(const base::FilePath& path, int index, | 95 void PackExtensionHandler::FileSelected(const base::FilePath& path, int index, |
| 96 void* params) { | 96 void* params) { |
| 97 ListValue results; | 97 ListValue results; |
| 98 results.Append(Value::CreateStringValue(path.value())); | 98 results.Append(Value::CreateStringValue(path.value())); |
| 99 web_ui()->CallJavascriptFunction("window.handleFilePathSelected", results); | 99 web_ui()->CallJavascriptFunction("window.handleFilePathSelected", results); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 &info, | 195 &info, |
| 196 file_type_index, | 196 file_type_index, |
| 197 base::FilePath::StringType(), | 197 base::FilePath::StringType(), |
| 198 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), | 198 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), |
| 199 NULL); | 199 NULL); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void PackExtensionHandler::ShowAlert(const std::string& message) { | 202 void PackExtensionHandler::ShowAlert(const std::string& message) { |
| 203 ListValue arguments; | 203 ListValue arguments; |
| 204 arguments.Append(Value::CreateStringValue(message)); | 204 arguments.Append(Value::CreateStringValue(message)); |
| 205 web_ui()->CallJavascriptFunction("PackExtensionOverlay.showError", arguments); | 205 web_ui()->CallJavascriptFunction( |
| 206 "extensions.PackExtensionOverlay.showError", arguments); |
| 206 } | 207 } |
| 207 | 208 |
| 208 } // namespace extensions | 209 } // namespace extensions |
| OLD | NEW |