| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 base::FilePath prettified_path = path_util::PrettifyPath(file_path); | 190 base::FilePath prettified_path = path_util::PrettifyPath(file_path); |
| 191 | 191 |
| 192 std::unique_ptr<base::DictionaryValue> manifest_value( | 192 std::unique_ptr<base::DictionaryValue> manifest_value( |
| 193 new base::DictionaryValue()); | 193 new base::DictionaryValue()); |
| 194 SourceHighlighter highlighter(manifest, line_number); | 194 SourceHighlighter highlighter(manifest, line_number); |
| 195 // If the line number is 0, this highlights no regions, but still adds the | 195 // If the line number is 0, this highlights no regions, but still adds the |
| 196 // full manifest. | 196 // full manifest. |
| 197 highlighter.SetHighlightedRegions(manifest_value.get()); | 197 highlighter.SetHighlightedRegions(manifest_value.get()); |
| 198 | 198 |
| 199 std::unique_ptr<base::DictionaryValue> failure(new base::DictionaryValue()); | 199 std::unique_ptr<base::DictionaryValue> failure(new base::DictionaryValue()); |
| 200 failure->Set("path", | 200 failure->Set("path", new base::Value(prettified_path.LossyDisplayName())); |
| 201 new base::StringValue(prettified_path.LossyDisplayName())); | 201 failure->Set("error", new base::Value(base::UTF8ToUTF16(error))); |
| 202 failure->Set("error", new base::StringValue(base::UTF8ToUTF16(error))); | |
| 203 failure->Set("manifest", manifest_value.release()); | 202 failure->Set("manifest", manifest_value.release()); |
| 204 failures_.Append(std::move(failure)); | 203 failures_.Append(std::move(failure)); |
| 205 | 204 |
| 206 // Only notify the frontend if the frontend UI is ready. | 205 // Only notify the frontend if the frontend UI is ready. |
| 207 if (ui_ready_) | 206 if (ui_ready_) |
| 208 NotifyFrontendOfFailure(); | 207 NotifyFrontendOfFailure(); |
| 209 } | 208 } |
| 210 | 209 |
| 211 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { | 210 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { |
| 212 web_ui()->CallJavascriptFunctionUnsafe( | 211 web_ui()->CallJavascriptFunctionUnsafe( |
| 213 "extensions.ExtensionLoader.notifyLoadFailed", failures_); | 212 "extensions.ExtensionLoader.notifyLoadFailed", failures_); |
| 214 failures_.Clear(); | 213 failures_.Clear(); |
| 215 } | 214 } |
| 216 | 215 |
| 217 } // namespace extensions | 216 } // namespace extensions |
| OLD | NEW |