Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: chrome/common/extensions/webview_handler.cc

Issue 134643011: Move webview and web_accessible_resources manifest handlers to src/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/webview_handler.h ('k') | chrome/renderer/extensions/resource_request_policy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/webview_handler.cc
diff --git a/chrome/common/extensions/webview_handler.cc b/chrome/common/extensions/webview_handler.cc
deleted file mode 100644
index ef8b241292ce7f2ca1356a69d8f9206cc5c776fc..0000000000000000000000000000000000000000
--- a/chrome/common/extensions/webview_handler.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/extensions/webview_handler.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/values.h"
-#include "extensions/common/error_utils.h"
-#include "extensions/common/manifest.h"
-#include "extensions/common/manifest_constants.h"
-
-namespace extensions {
-
-namespace keys = extensions::manifest_keys;
-namespace errors = extensions::manifest_errors;
-
-namespace {
-
-const WebviewInfo* GetResourcesInfo(
- const Extension& extension) {
- return static_cast<WebviewInfo*>(
- extension.GetManifestData(keys::kWebviewAccessibleResources));
-}
-
-} // namespace
-
-WebviewInfo::WebviewInfo() {
-}
-
-WebviewInfo::~WebviewInfo() {
-}
-
-// static
-bool WebviewInfo::IsResourceWebviewAccessible(
- const Extension* extension,
- const std::string& partition_id,
- const std::string& relative_path) {
- if (!extension)
- return false;
-
- const WebviewInfo* info = GetResourcesInfo(*extension);
- if (!info)
- return false;
-
- bool partition_is_privileged = false;
- for (size_t i = 0;
- i < info->webview_privileged_partitions_.size();
- ++i) {
- if (MatchPattern(partition_id, info->webview_privileged_partitions_[i])) {
- partition_is_privileged = true;
- break;
- }
- }
-
- return partition_is_privileged && extension->ResourceMatches(
- info->webview_accessible_resources_, relative_path);
-}
-
-WebviewHandler::WebviewHandler() {
-}
-
-WebviewHandler::~WebviewHandler() {
-}
-
-bool WebviewHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<WebviewInfo> info(new WebviewInfo());
-
- const base::DictionaryValue* dict_value = NULL;
- if (!extension->manifest()->GetDictionary(keys::kWebview,
- &dict_value)) {
- *error = base::ASCIIToUTF16(errors::kInvalidWebview);
- return false;
- }
-
- const base::ListValue* url_list = NULL;
- if (!dict_value->GetList(keys::kWebviewAccessibleResources,
- &url_list)) {
- *error = base::ASCIIToUTF16(errors::kInvalidWebviewAccessibleResourcesList);
- return false;
- }
-
- for (size_t i = 0; i < url_list->GetSize(); ++i) {
- std::string relative_path;
- if (!url_list->GetString(i, &relative_path)) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kInvalidWebviewAccessibleResource, base::IntToString(i));
- return false;
- }
- URLPattern pattern(URLPattern::SCHEME_EXTENSION);
- if (pattern.Parse(extension->url().spec()) != URLPattern::PARSE_SUCCESS) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kInvalidURLPatternError, extension->url().spec());
- return false;
- }
- while (relative_path[0] == '/')
- relative_path = relative_path.substr(1, relative_path.length() - 1);
- pattern.SetPath(pattern.path() + relative_path);
- info->webview_accessible_resources_.AddPattern(pattern);
- }
-
- const base::ListValue* partition_list = NULL;
- if (!dict_value->GetList(keys::kWebviewPrivilegedPartitions,
- &partition_list)) {
- *error = base::ASCIIToUTF16(errors::kInvalidWebviewPrivilegedPartitionList);
- return false;
- }
- for (size_t i = 0; i < partition_list->GetSize(); ++i) {
- std::string partition_wildcard;
- if (!partition_list->GetString(i, &partition_wildcard)) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kInvalidWebviewPrivilegedPartition, base::IntToString(i));
- return false;
- }
- info->webview_privileged_partitions_.push_back(partition_wildcard);
- }
- extension->SetManifestData(keys::kWebviewAccessibleResources, info.release());
- return true;
-}
-
-const std::vector<std::string> WebviewHandler::Keys() const {
- return SingleKey(keys::kWebview);
-}
-
-} // namespace extensions
« no previous file with comments | « chrome/common/extensions/webview_handler.h ('k') | chrome/renderer/extensions/resource_request_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698