OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extension_loader_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 | 180 |
181 void ExtensionLoaderHandler::AddFailure( | 181 void ExtensionLoaderHandler::AddFailure( |
182 const base::FilePath& file_path, | 182 const base::FilePath& file_path, |
183 const std::string& error, | 183 const std::string& error, |
184 size_t line_number, | 184 size_t line_number, |
185 const std::string& manifest) { | 185 const std::string& manifest) { |
186 failed_paths_.push_back(file_path); | 186 failed_paths_.push_back(file_path); |
187 base::FilePath prettified_path = path_util::PrettifyPath(file_path); | 187 base::FilePath prettified_path = path_util::PrettifyPath(file_path); |
188 | 188 |
189 scoped_ptr<base::DictionaryValue> manifest_value(new base::DictionaryValue()); | 189 std::unique_ptr<base::DictionaryValue> manifest_value( |
| 190 new base::DictionaryValue()); |
190 SourceHighlighter highlighter(manifest, line_number); | 191 SourceHighlighter highlighter(manifest, line_number); |
191 // If the line number is 0, this highlights no regions, but still adds the | 192 // If the line number is 0, this highlights no regions, but still adds the |
192 // full manifest. | 193 // full manifest. |
193 highlighter.SetHighlightedRegions(manifest_value.get()); | 194 highlighter.SetHighlightedRegions(manifest_value.get()); |
194 | 195 |
195 scoped_ptr<base::DictionaryValue> failure(new base::DictionaryValue()); | 196 std::unique_ptr<base::DictionaryValue> failure(new base::DictionaryValue()); |
196 failure->Set("path", | 197 failure->Set("path", |
197 new base::StringValue(prettified_path.LossyDisplayName())); | 198 new base::StringValue(prettified_path.LossyDisplayName())); |
198 failure->Set("error", new base::StringValue(base::UTF8ToUTF16(error))); | 199 failure->Set("error", new base::StringValue(base::UTF8ToUTF16(error))); |
199 failure->Set("manifest", manifest_value.release()); | 200 failure->Set("manifest", manifest_value.release()); |
200 failures_.Append(failure.release()); | 201 failures_.Append(failure.release()); |
201 | 202 |
202 // Only notify the frontend if the frontend UI is ready. | 203 // Only notify the frontend if the frontend UI is ready. |
203 if (ui_ready_) | 204 if (ui_ready_) |
204 NotifyFrontendOfFailure(); | 205 NotifyFrontendOfFailure(); |
205 } | 206 } |
206 | 207 |
207 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { | 208 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { |
208 web_ui()->CallJavascriptFunction( | 209 web_ui()->CallJavascriptFunction( |
209 "extensions.ExtensionLoader.notifyLoadFailed", | 210 "extensions.ExtensionLoader.notifyLoadFailed", |
210 failures_); | 211 failures_); |
211 failures_.Clear(); | 212 failures_.Clear(); |
212 } | 213 } |
213 | 214 |
214 } // namespace extensions | 215 } // namespace extensions |
OLD | NEW |