Index: content/renderer/manifest/manifest_parser.cc |
diff --git a/content/renderer/manifest/manifest_parser.cc b/content/renderer/manifest/manifest_parser.cc |
index 9a3e8520932cc7d18b6054066deda1d8f0a65c29..a83d2a951c694012ed08b9479549fc677c281f32 100644 |
--- a/content/renderer/manifest/manifest_parser.cc |
+++ b/content/renderer/manifest/manifest_parser.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/renderer/manifest/manifest_parser.h" |
+#include "content/public/renderer/manifest_parser.h" |
#include "base/json/json_reader.h" |
#include "base/strings/nullable_string16.h" |
@@ -11,7 +11,9 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/values.h" |
+#include "content/public/common/content_client.h" |
#include "content/public/common/manifest.h" |
+#include "content/public/renderer/content_renderer_client.h" |
#include "content/renderer/manifest/manifest_uma_util.h" |
#include "ui/gfx/geometry/size.h" |
@@ -85,23 +87,35 @@ const std::string& GetErrorPrefix() { |
} // anonymous namespace |
+// static |
+scoped_ptr<ManifestParser> ManifestParser::Get() { |
+ ManifestParser* parser = nullptr; |
+ if (GetContentClient()->renderer()->OverrideManifestParser(&parser)) { |
+ return scoped_ptr<ManifestParser>(parser); |
+ } |
+ |
+ return scoped_ptr<ManifestParser>(new ManifestParser); |
+} |
-ManifestParser::ManifestParser(const base::StringPiece& data, |
- const GURL& manifest_url, |
- const GURL& document_url) |
- : data_(data), |
- manifest_url_(manifest_url), |
- document_url_(document_url), |
- failed_(false) { |
+ManifestParser::ManifestParser() |
+ : failed_(false) { |
} |
ManifestParser::~ManifestParser() { |
} |
-void ManifestParser::Parse() { |
+void ManifestParser::Parse(const base::StringPiece& data, |
+ const GURL& manifest_url, |
+ const GURL& document_url) { |
+ manifest_url_ = manifest_url; |
+ document_url_ = document_url; |
+ |
+ DCHECK(manifest_url_.is_valid()); |
+ DCHECK(document_url_.is_valid()); |
+ |
std::string parse_error; |
scoped_ptr<base::Value> value( |
- base::JSONReader::ReadAndReturnError(data_, base::JSON_PARSE_RFC, |
+ base::JSONReader::ReadAndReturnError(data, base::JSON_PARSE_RFC, |
nullptr, &parse_error)); |
if (!value) { |
@@ -121,18 +135,21 @@ void ManifestParser::Parse() { |
} |
DCHECK(dictionary); |
+ ParseExtensionPoint(*dictionary); |
+ |
manifest_.name = ParseName(*dictionary); |
manifest_.short_name = ParseShortName(*dictionary); |
manifest_.start_url = ParseStartURL(*dictionary); |
manifest_.display = ParseDisplay(*dictionary); |
manifest_.orientation = ParseOrientation(*dictionary); |
manifest_.icons = ParseIcons(*dictionary); |
- manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary); |
- manifest_.gcm_user_visible_only = ParseGCMUserVisibleOnly(*dictionary); |
ManifestUmaUtil::ParseSucceeded(manifest_); |
} |
+void ManifestParser::ParseExtensionPoint(const base::DictionaryValue&) { |
+} |
+ |
const Manifest& ManifestParser::manifest() const { |
return manifest_; |
} |
@@ -334,14 +351,4 @@ std::vector<Manifest::Icon> ManifestParser::ParseIcons( |
return icons; |
} |
-base::NullableString16 ManifestParser::ParseGCMSenderID( |
- const base::DictionaryValue& dictionary) { |
- return ParseString(dictionary, "gcm_sender_id", Trim); |
-} |
- |
-bool ManifestParser::ParseGCMUserVisibleOnly( |
- const base::DictionaryValue& dictionary) { |
- return ParseBoolean(dictionary, "gcm_user_visible_only", false); |
-} |
- |
} // namespace content |