From dbb92e0d55eede17bf2ada8370650d39834e6060 Mon Sep 17 00:00:00 2001 From: "asargent@chromium.org" Date: Thu, 20 Aug 2009 16:18:21 +0000 Subject: Do extensions update manifest XML parsing in a sandboxed process. This involves moving the xml parsing code from static functions in extension_updater.cc to a UpdateManifest class, and switching from logging any errors directly to collecting them up and passing them across the IPC channel. BUG=http://crbug.com/12677 TEST=extensions auto-update should still work correctly Review URL: http://codereview.chromium.org/164541 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23822 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/extensions/update_manifest.h | 71 ++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 chrome/common/extensions/update_manifest.h (limited to 'chrome/common/extensions/update_manifest.h') diff --git a/chrome/common/extensions/update_manifest.h b/chrome/common/extensions/update_manifest.h new file mode 100644 index 0000000..c1e5b2b --- /dev/null +++ b/chrome/common/extensions/update_manifest.h @@ -0,0 +1,71 @@ +// Copyright (c) 2009 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. + +#ifndef CHROME_COMMON_EXTENSIONS_UPDATE_MANIFEST_H_ +#define CHROME_COMMON_EXTENSIONS_UPDATE_MANIFEST_H_ + +#include +#include + +#include "base/logging.h" +#include "base/scoped_ptr.h" +#include "base/values.h" +#include "base/version.h" +#include "googleurl/src/gurl.h" + +class Version; + +class UpdateManifest { + public: + + // An update manifest looks like this: + // + // + // + // + // + // + // + // + // The "appid" attribute of the tag refers to the unique id of the + // extension. The "codebase" attribute of the tag is the url to + // fetch the updated crx file, and the "prodversionmin" attribute refers to + // the minimum version of the chrome browser that the update applies to. + + // The result of parsing one tag in an xml update check manifest. + struct Result { + std::string extension_id; + std::string version; + std::string browser_min_version; + std::string package_hash; + GURL crx_url; + }; + + typedef std::vector ResultList; + + UpdateManifest(); + ~UpdateManifest(); + + // Parses an update manifest xml string into Result data. Returns a bool + // indicating success or failure. On success, the results are available by + // calling results(), and on failure, the explanation for why is available + // by calling errors(). + bool Parse(const std::string& manifest_xml); + + const ResultList& results() { return results_; } + const std::string& errors() { return errors_; } + + private: + ResultList results_; + + std::string errors_; + + // Helper function that adds parse error details to our errors_ string. + void ParseError(const char* details, ...); +}; + +#endif // CHROME_COMMON_EXTENSIONS_UPDATE_MANIFEST_H_ + -- cgit v1.1