| 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 <memory> | |
| 8 #include <utility> | 7 #include <utility> |
| 9 | 8 |
| 10 #include "base/bind.h" | 9 #include "base/bind.h" |
| 11 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | |
| 14 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 15 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/task_scheduler/post_task.h" | 17 #include "base/task_scheduler/post_task.h" |
| 20 #include "base/values.h" | |
| 21 #include "chrome/browser/extensions/path_util.h" | 18 #include "chrome/browser/extensions/path_util.h" |
| 22 #include "chrome/browser/extensions/unpacked_installer.h" | 19 #include "chrome/browser/extensions/unpacked_installer.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 25 #include "content/public/browser/navigation_handle.h" | 22 #include "content/public/browser/navigation_handle.h" |
| 26 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
| 28 #include "content/public/browser/web_ui_data_source.h" | 25 #include "content/public/browser/web_ui_data_source.h" |
| 29 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
| 30 #include "extensions/browser/file_highlighter.h" | 27 #include "extensions/browser/file_highlighter.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 base::FilePath prettified_path = path_util::PrettifyPath(file_path); | 198 base::FilePath prettified_path = path_util::PrettifyPath(file_path); |
| 202 | 199 |
| 203 std::unique_ptr<base::DictionaryValue> manifest_value( | 200 std::unique_ptr<base::DictionaryValue> manifest_value( |
| 204 new base::DictionaryValue()); | 201 new base::DictionaryValue()); |
| 205 SourceHighlighter highlighter(manifest, line_number); | 202 SourceHighlighter highlighter(manifest, line_number); |
| 206 // If the line number is 0, this highlights no regions, but still adds the | 203 // If the line number is 0, this highlights no regions, but still adds the |
| 207 // full manifest. | 204 // full manifest. |
| 208 highlighter.SetHighlightedRegions(manifest_value.get()); | 205 highlighter.SetHighlightedRegions(manifest_value.get()); |
| 209 | 206 |
| 210 std::unique_ptr<base::DictionaryValue> failure(new base::DictionaryValue()); | 207 std::unique_ptr<base::DictionaryValue> failure(new base::DictionaryValue()); |
| 211 failure->SetString("path", prettified_path.LossyDisplayName()); | 208 failure->Set("path", new base::Value(prettified_path.LossyDisplayName())); |
| 212 failure->SetString("error", error); | 209 failure->Set("error", new base::Value(base::UTF8ToUTF16(error))); |
| 213 failure->Set("manifest", std::move(manifest_value)); | 210 failure->Set("manifest", manifest_value.release()); |
| 214 failures_.Append(std::move(failure)); | 211 failures_.Append(std::move(failure)); |
| 215 | 212 |
| 216 // Only notify the frontend if the frontend UI is ready. | 213 // Only notify the frontend if the frontend UI is ready. |
| 217 if (ui_ready_) | 214 if (ui_ready_) |
| 218 NotifyFrontendOfFailure(); | 215 NotifyFrontendOfFailure(); |
| 219 } | 216 } |
| 220 | 217 |
| 221 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { | 218 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { |
| 222 web_ui()->CallJavascriptFunctionUnsafe( | 219 web_ui()->CallJavascriptFunctionUnsafe( |
| 223 "extensions.ExtensionLoader.notifyLoadFailed", failures_); | 220 "extensions.ExtensionLoader.notifyLoadFailed", failures_); |
| 224 failures_.Clear(); | 221 failures_.Clear(); |
| 225 } | 222 } |
| 226 | 223 |
| 227 } // namespace extensions | 224 } // namespace extensions |
| OLD | NEW |