| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_UPDATE_RESPONSE_H_ | |
| 6 #define CHROME_BROWSER_COMPONENT_UPDATER_UPDATE_RESPONSE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 #include "base/basictypes.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 namespace component_updater { | |
| 14 | |
| 15 // Parses responses for the update protocol version 3. | |
| 16 // (http://code.google.com/p/omaha/wiki/ServerProtocol) | |
| 17 // | |
| 18 // An update response looks like this: | |
| 19 // | |
| 20 // <?xml version="1.0" encoding="UTF-8"?> | |
| 21 // <response protocol="3.0" server="prod"> | |
| 22 // <daystart elapsed_seconds="56508"/> | |
| 23 // <app appid="{430FD4D0-B729-4F61-AA34-91526481799D}" status="ok"> | |
| 24 // <updatecheck status="noupdate"/> | |
| 25 // <ping status="ok"/> | |
| 26 // </app> | |
| 27 // <app appid="{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}" status="ok"> | |
| 28 // <updatecheck status="ok"> | |
| 29 // <urls> | |
| 30 // <url codebase="http://host/edgedl/chrome/install/782.112/" | |
| 31 // <url codebasediff="http://fallback/chrome/diff/782.112/"/> | |
| 32 // </urls> | |
| 33 // <manifest version="13.0.782.112" prodversionmin="2.0.143.0"> | |
| 34 // <packages> | |
| 35 // <package name="component.crx" | |
| 36 // namediff="diff_1.2.3.4.crx" | |
| 37 // fp="1.123" | |
| 38 // hash_sha256="9830b4245c4..." size="23963192" | |
| 39 // hashdiff_sha256="cfb6caf3d0..." sizediff="101"/> | |
| 40 // </packages> | |
| 41 // </manifest> | |
| 42 // </updatecheck> | |
| 43 // <ping status="ok"/> | |
| 44 // </app> | |
| 45 // </response> | |
| 46 // | |
| 47 // The <daystart> tag contains a "elapsed_seconds" attribute which refers to | |
| 48 // the server's notion of how many seconds it has been since midnight. | |
| 49 // | |
| 50 // The "appid" attribute of the <app> tag refers to the unique id of the | |
| 51 // extension. The "codebase" attribute of the <updatecheck> tag is the url to | |
| 52 // fetch the updated crx file, and the "prodversionmin" attribute refers to | |
| 53 // the minimum version of the chrome browser that the update applies to. | |
| 54 // | |
| 55 // The diff data members correspond to the differential update package, if | |
| 56 // a differential update is specified in the response. | |
| 57 class UpdateResponse { | |
| 58 public: | |
| 59 // The result of parsing one <app> tag in an xml update check response. | |
| 60 struct Result { | |
| 61 struct Manifest { | |
| 62 struct Package { | |
| 63 Package(); | |
| 64 ~Package(); | |
| 65 | |
| 66 std::string fingerprint; | |
| 67 | |
| 68 // Attributes for the full update. | |
| 69 std::string name; | |
| 70 std::string hash_sha256; | |
| 71 int size; | |
| 72 | |
| 73 // Attributes for the differential update. | |
| 74 std::string namediff; | |
| 75 std::string hashdiff_sha256; | |
| 76 int sizediff; | |
| 77 }; | |
| 78 | |
| 79 Manifest(); | |
| 80 ~Manifest(); | |
| 81 | |
| 82 std::string version; | |
| 83 std::string browser_min_version; | |
| 84 std::vector<Package> packages; | |
| 85 }; | |
| 86 | |
| 87 Result(); | |
| 88 ~Result(); | |
| 89 | |
| 90 std::string extension_id; | |
| 91 | |
| 92 // The list of fallback urls, for full and diff updates respectively. | |
| 93 // These urls are base urls; they don't include the filename. | |
| 94 std::vector<GURL> crx_urls; | |
| 95 std::vector<GURL> crx_diffurls; | |
| 96 | |
| 97 Manifest manifest; | |
| 98 }; | |
| 99 | |
| 100 static const int kNoDaystart = -1; | |
| 101 struct Results { | |
| 102 Results(); | |
| 103 ~Results(); | |
| 104 | |
| 105 // This will be >= 0, or kNoDaystart if the <daystart> tag was not present. | |
| 106 int daystart_elapsed_seconds; | |
| 107 std::vector<Result> list; | |
| 108 }; | |
| 109 | |
| 110 UpdateResponse(); | |
| 111 ~UpdateResponse(); | |
| 112 | |
| 113 // Parses an update response xml string into Result data. Returns a bool | |
| 114 // indicating success or failure. On success, the results are available by | |
| 115 // calling results(). The details for any failures are available by calling | |
| 116 // errors(). | |
| 117 bool Parse(const std::string& manifest_xml); | |
| 118 | |
| 119 const Results& results() const { return results_; } | |
| 120 const std::string& errors() const { return errors_; } | |
| 121 | |
| 122 private: | |
| 123 Results results_; | |
| 124 std::string errors_; | |
| 125 | |
| 126 // Adds parse error details to |errors_| string. | |
| 127 void ParseError(const char* details, ...); | |
| 128 | |
| 129 DISALLOW_COPY_AND_ASSIGN(UpdateResponse); | |
| 130 }; | |
| 131 | |
| 132 } // namespace component_updater | |
| 133 | |
| 134 #endif // CHROME_BROWSER_COMPONENT_UPDATER_UPDATE_RESPONSE_H_ | |
| OLD | NEW |