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