diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 16:18:21 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 16:18:21 +0000 |
commit | dbb92e0d55eede17bf2ada8370650d39834e6060 (patch) | |
tree | 941532e52eceab1115b60556960abde35f786368 /chrome/common/extensions/update_manifest.h | |
parent | e667f718463a78b7d1de5a51e71982211f00f875 (diff) | |
download | chromium_src-dbb92e0d55eede17bf2ada8370650d39834e6060.zip chromium_src-dbb92e0d55eede17bf2ada8370650d39834e6060.tar.gz chromium_src-dbb92e0d55eede17bf2ada8370650d39834e6060.tar.bz2 |
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
Diffstat (limited to 'chrome/common/extensions/update_manifest.h')
-rw-r--r-- | chrome/common/extensions/update_manifest.h | 71 |
1 files changed, 71 insertions, 0 deletions
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 <string> +#include <vector> + +#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: + // + // <?xml version='1.0' encoding='UTF-8'?> + // <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> + // <app appid='12345'> + // <updatecheck codebase='http://example.com/extension_1.2.3.4.crx' + // version='1.2.3.4' prodversionmin='2.0.143.0' + // hash="12345"/> + // </app> + // </gupdate> + // + // The "appid" attribute of the <app> tag refers to the unique id of the + // extension. The "codebase" attribute of the <updatecheck> 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 <app> 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<Result> 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_ + |