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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 base::Unretained(this))); | 61 base::Unretained(this))); |
62 web_ui()->RegisterMessageCallback( | 62 web_ui()->RegisterMessageCallback( |
63 "packExtensionSelectFilePath", | 63 "packExtensionSelectFilePath", |
64 base::Bind(&PackExtensionHandler::HandleSelectFilePathMessage, | 64 base::Bind(&PackExtensionHandler::HandleSelectFilePathMessage, |
65 base::Unretained(this))); | 65 base::Unretained(this))); |
66 } | 66 } |
67 | 67 |
68 void PackExtensionHandler::OnPackSuccess(const base::FilePath& crx_file, | 68 void PackExtensionHandler::OnPackSuccess(const base::FilePath& crx_file, |
69 const base::FilePath& pem_file) { | 69 const base::FilePath& pem_file) { |
70 base::ListValue arguments; | 70 base::ListValue arguments; |
71 arguments.Append(base::Value::CreateStringValue( | 71 arguments.Append(new base::StringValue(base::UTF16ToUTF8( |
72 base::UTF16ToUTF8(PackExtensionJob::StandardSuccessMessage( | 72 PackExtensionJob::StandardSuccessMessage(crx_file, pem_file)))); |
73 crx_file, pem_file)))); | |
74 web_ui()->CallJavascriptFunction( | 73 web_ui()->CallJavascriptFunction( |
75 "extensions.PackExtensionOverlay.showSuccessMessage", arguments); | 74 "extensions.PackExtensionOverlay.showSuccessMessage", arguments); |
76 } | 75 } |
77 | 76 |
78 void PackExtensionHandler::OnPackFailure(const std::string& error, | 77 void PackExtensionHandler::OnPackFailure(const std::string& error, |
79 ExtensionCreator::ErrorType type) { | 78 ExtensionCreator::ErrorType type) { |
80 if (type == ExtensionCreator::kCRXExists) { | 79 if (type == ExtensionCreator::kCRXExists) { |
81 base::StringValue error_str(error); | 80 base::StringValue error_str(error); |
82 base::StringValue extension_path_str(extension_path_.value()); | 81 base::StringValue extension_path_str(extension_path_.value()); |
83 base::StringValue key_path_str(private_key_path_.value()); | 82 base::StringValue key_path_str(private_key_path_.value()); |
84 base::FundamentalValue overwrite_flag(ExtensionCreator::kOverwriteCRX); | 83 base::FundamentalValue overwrite_flag(ExtensionCreator::kOverwriteCRX); |
85 | 84 |
86 web_ui()->CallJavascriptFunction( | 85 web_ui()->CallJavascriptFunction( |
87 "extensions.ExtensionSettings.askToOverrideWarning", | 86 "extensions.ExtensionSettings.askToOverrideWarning", |
88 error_str, extension_path_str, key_path_str, overwrite_flag); | 87 error_str, extension_path_str, key_path_str, overwrite_flag); |
89 } else { | 88 } else { |
90 ShowAlert(error); | 89 ShowAlert(error); |
91 } | 90 } |
92 } | 91 } |
93 | 92 |
94 void PackExtensionHandler::FileSelected(const base::FilePath& path, int index, | 93 void PackExtensionHandler::FileSelected(const base::FilePath& path, int index, |
95 void* params) { | 94 void* params) { |
96 base::ListValue results; | 95 base::ListValue results; |
97 results.Append(base::Value::CreateStringValue(path.value())); | 96 results.Append(new base::StringValue(path.value())); |
98 web_ui()->CallJavascriptFunction("window.handleFilePathSelected", results); | 97 web_ui()->CallJavascriptFunction("window.handleFilePathSelected", results); |
99 } | 98 } |
100 | 99 |
101 void PackExtensionHandler::MultiFilesSelected( | 100 void PackExtensionHandler::MultiFilesSelected( |
102 const std::vector<base::FilePath>& files, void* params) { | 101 const std::vector<base::FilePath>& files, void* params) { |
103 NOTREACHED(); | 102 NOTREACHED(); |
104 } | 103 } |
105 | 104 |
106 void PackExtensionHandler::HandlePackMessage(const base::ListValue* args) { | 105 void PackExtensionHandler::HandlePackMessage(const base::ListValue* args) { |
107 DCHECK_EQ(3U, args->GetSize()); | 106 DCHECK_EQ(3U, args->GetSize()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 path_to_use, | 192 path_to_use, |
194 &info, | 193 &info, |
195 file_type_index, | 194 file_type_index, |
196 base::FilePath::StringType(), | 195 base::FilePath::StringType(), |
197 web_ui()->GetWebContents()->GetTopLevelNativeWindow(), | 196 web_ui()->GetWebContents()->GetTopLevelNativeWindow(), |
198 NULL); | 197 NULL); |
199 } | 198 } |
200 | 199 |
201 void PackExtensionHandler::ShowAlert(const std::string& message) { | 200 void PackExtensionHandler::ShowAlert(const std::string& message) { |
202 base::ListValue arguments; | 201 base::ListValue arguments; |
203 arguments.Append(base::Value::CreateStringValue(message)); | 202 arguments.Append(new base::StringValue(message)); |
204 web_ui()->CallJavascriptFunction( | 203 web_ui()->CallJavascriptFunction( |
205 "extensions.PackExtensionOverlay.showError", arguments); | 204 "extensions.PackExtensionOverlay.showError", arguments); |
206 } | 205 } |
207 | 206 |
208 } // namespace extensions | 207 } // namespace extensions |
OLD | NEW |