Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / updater / safe_manifest_parser.h
blobd3a550b2439e4d1ab590c3aa1e7299b5f9708423
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_
6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_
7 #include <string>
9 #include "base/basictypes.h"
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/extensions/updater/manifest_fetch_data.h"
13 #include "chrome/common/extensions/update_manifest.h"
14 #include "content/public/browser/utility_process_host_client.h"
16 namespace extensions {
18 // Utility class to handle doing xml parsing in a sandboxed utility process.
19 class SafeManifestParser : public content::UtilityProcessHostClient {
20 public:
21 // Callback that is invoked when the manifest results are ready.
22 typedef base::Callback<void(const ManifestFetchData&,
23 const UpdateManifest::Results*)> UpdateCallback;
25 // Takes ownership of |fetch_data|.
26 SafeManifestParser(const std::string& xml,
27 ManifestFetchData* fetch_data,
28 const UpdateCallback& update_callback);
30 // Posts a task over to the IO loop to start the parsing of xml_ in a
31 // utility process.
32 void Start();
34 private:
35 virtual ~SafeManifestParser();
37 // Creates the sandboxed utility process and tells it to start parsing.
38 void ParseInSandbox();
40 // content::UtilityProcessHostClient implementation.
41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
43 void OnParseUpdateManifestSucceeded(const UpdateManifest::Results& results);
44 void OnParseUpdateManifestFailed(const std::string& error_message);
46 const std::string xml_;
48 // Should be accessed only on UI thread.
49 scoped_ptr<ManifestFetchData> fetch_data_;
50 UpdateCallback update_callback_;
52 DISALLOW_COPY_AND_ASSIGN(SafeManifestParser);
55 } // namespace extensions
57 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_