| Index: chrome/browser/ui/webui/extensions/extension_error_handler.cc
|
| diff --git a/chrome/browser/ui/webui/extensions/extension_error_handler.cc b/chrome/browser/ui/webui/extensions/extension_error_handler.cc
|
| index 11999a671a134ce8d58fa2a8b439a90d3fa1dd3c..5e678f49e7d3766b80fc93247fd35266d3a5ce85 100644
|
| --- a/chrome/browser/ui/webui/extensions/extension_error_handler.cc
|
| +++ b/chrome/browser/ui/webui/extensions/extension_error_handler.cc
|
| @@ -19,7 +19,7 @@
|
| #include "content/public/browser/web_ui.h"
|
| #include "content/public/browser/web_ui_data_source.h"
|
| #include "extensions/browser/extension_error.h"
|
| -#include "extensions/browser/manifest_highlighter.h"
|
| +#include "extensions/browser/file_highlighter.h"
|
| #include "grit/generated_resources.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| @@ -31,29 +31,9 @@ namespace {
|
| const char kFileTypeKey[] = "fileType";
|
| const char kManifestFileType[] = "manifest";
|
| const char kPathSuffixKey[] = "pathSuffix";
|
| +const char kSourceFileType[] = "source";
|
| const char kTitleKey[] = "title";
|
|
|
| -const char kBeforeHighlightKey[] = "beforeHighlight";
|
| -const char kHighlightKey[] = "highlight";
|
| -const char kAfterHighlightKey[] = "afterHighlight";
|
| -
|
| -// Populate a DictionaryValue with the highlighted portions for the callback to
|
| -// ExtensionErrorOverlay, given the components.
|
| -void HighlightDictionary(base::DictionaryValue* dict,
|
| - const ManifestHighlighter& highlighter) {
|
| - std::string before_feature = highlighter.GetBeforeFeature();
|
| - if (!before_feature.empty())
|
| - dict->SetString(kBeforeHighlightKey, base::UTF8ToUTF16(before_feature));
|
| -
|
| - std::string feature = highlighter.GetFeature();
|
| - if (!feature.empty())
|
| - dict->SetString(kHighlightKey, base::UTF8ToUTF16(feature));
|
| -
|
| - std::string after_feature = highlighter.GetAfterFeature();
|
| - if (!after_feature.empty())
|
| - dict->SetString(kAfterHighlightKey, base::UTF8ToUTF16(after_feature));
|
| -}
|
| -
|
| } // namespace
|
|
|
| ExtensionErrorHandler::ExtensionErrorHandler(Profile* profile)
|
| @@ -69,6 +49,9 @@ void ExtensionErrorHandler::GetLocalizedValues(
|
| "extensionErrorsManifestErrors",
|
| l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERRORS_MANIFEST_ERRORS));
|
| source->AddString(
|
| + "extensionErrorsRuntimeErrors",
|
| + l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERRORS_RUNTIME_ERRORS));
|
| + source->AddString(
|
| "extensionErrorsShowMore",
|
| l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERRORS_SHOW_MORE));
|
| source->AddString(
|
| @@ -77,6 +60,15 @@ void ExtensionErrorHandler::GetLocalizedValues(
|
| source->AddString(
|
| "extensionErrorViewSource",
|
| l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_VIEW_SOURCE));
|
| + source->AddString(
|
| + "extensionErrorContext",
|
| + l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_CONTEXT));
|
| + source->AddString(
|
| + "extensionErrorStackTrace",
|
| + l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_STACK_TRACE));
|
| + source->AddString(
|
| + "extensionErrorAnonymousFunction",
|
| + l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_ANONYMOUS_FUNCTION));
|
| }
|
|
|
| void ExtensionErrorHandler::RegisterMessages() {
|
| @@ -91,7 +83,7 @@ void ExtensionErrorHandler::HandleRequestFileSource(
|
| // There should only be one argument, a dictionary. Use this instead of a list
|
| // because it's more descriptive, harder to accidentally break with minor
|
| // modifications, and supports optional arguments more easily.
|
| - CHECK_EQ(1u, args->GetSize());
|
| + DCHECK_EQ(1u, args->GetSize());
|
|
|
| const base::DictionaryValue* dict = NULL;
|
|
|
| @@ -146,8 +138,17 @@ void ExtensionErrorHandler::HandleRequestFileSource(
|
| manifest_key,
|
| specific,
|
| base::Owned(contents));
|
| + } else if (file_type == kSourceFileType) {
|
| + int line_number = 1;
|
| + dict->GetInteger(RuntimeError::kLineNumberKey, &line_number);
|
| +
|
| + contents = new std::string; // Owned by GetSourceFileCallback()
|
| + closure = base::Bind(&ExtensionErrorHandler::GetSourceFileCallback,
|
| + base::Unretained(this),
|
| + base::Owned(results.release()),
|
| + line_number,
|
| + base::Owned(contents));
|
| } else {
|
| - // currently, only manifest file types supported.
|
| NOTREACHED();
|
| return;
|
| }
|
| @@ -166,7 +167,17 @@ void ExtensionErrorHandler::GetManifestFileCallback(
|
| const std::string& specific,
|
| std::string* contents) {
|
| ManifestHighlighter highlighter(*contents, key, specific);
|
| - HighlightDictionary(results, highlighter);
|
| + highlighter.SetHighlightedRegions(results);
|
| + web_ui()->CallJavascriptFunction(
|
| + "extensions.ExtensionErrorOverlay.requestFileSourceResponse", *results);
|
| +}
|
| +
|
| +void ExtensionErrorHandler::GetSourceFileCallback(
|
| + base::DictionaryValue* results,
|
| + int line_number,
|
| + std::string* contents) {
|
| + SourceHighlighter highlighter(*contents, line_number);
|
| + highlighter.SetHighlightedRegions(results);
|
| web_ui()->CallJavascriptFunction(
|
| "extensions.ExtensionErrorOverlay.requestFileSourceResponse", *results);
|
| }
|
|
|