OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "net/test/embedded_test_server/embedded_test_server.h" | 12 #include "net/test/embedded_test_server/embedded_test_server.h" |
13 #include "net/test/embedded_test_server/http_request.h" | 13 #include "net/test/embedded_test_server/http_request.h" |
14 #include "net/test/embedded_test_server/http_response.h" | 14 #include "net/test/embedded_test_server/http_response.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 // Simple fake CWS update check request handler that returns a fixed update | 19 // Simple fake CWS update check request handler that returns a fixed update |
20 // check response. The response is created either from SetUpdateCrx() or | 20 // check response. The response is created either from SetUpdateCrx() or |
21 // SetNoUpdate(). | 21 // SetNoUpdate(). |
22 class FakeCWS { | 22 class FakeCWS { |
23 public: | 23 public: |
24 FakeCWS(); | 24 FakeCWS(); |
25 ~FakeCWS(); | 25 ~FakeCWS(); |
26 | 26 |
27 // Initializes as CWS request handler and overrides app gallery command line | 27 // Initializes as CWS request handler and overrides app gallery command line |
28 // switches. | 28 // switches. |
29 void Init(net::test_server::EmbeddedTestServer* embedded_test_server); | 29 void Init(net::EmbeddedTestServer* embedded_test_server); |
30 | 30 |
31 // Initializes as a private store handler using the given server and URL end | 31 // Initializes as a private store handler using the given server and URL end |
32 // point. Private store does not override app gallery command lines and use a | 32 // point. Private store does not override app gallery command lines and use a |
33 // slightly different template (as documented on | 33 // slightly different template (as documented on |
34 // https://developer.chrome.com/extensions/autoupdate). | 34 // https://developer.chrome.com/extensions/autoupdate). |
35 void InitAsPrivateStore( | 35 void InitAsPrivateStore(net::EmbeddedTestServer* embedded_test_server, |
36 net::test_server::EmbeddedTestServer* embedded_test_server, | 36 const std::string& update_check_end_point); |
37 const std::string& update_check_end_point); | |
38 | 37 |
39 // Sets up the update check response with has_update template. | 38 // Sets up the update check response with has_update template. |
40 void SetUpdateCrx(const std::string& app_id, | 39 void SetUpdateCrx(const std::string& app_id, |
41 const std::string& crx_file, | 40 const std::string& crx_file, |
42 const std::string& version); | 41 const std::string& version); |
43 | 42 |
44 // Sets up the update check response with no_update template. | 43 // Sets up the update check response with no_update template. |
45 void SetNoUpdate(const std::string& app_id); | 44 void SetNoUpdate(const std::string& app_id); |
46 | 45 |
47 // Returns the current |update_check_count_| and resets it. | 46 // Returns the current |update_check_count_| and resets it. |
(...skipping 19 matching lines...) Expand all Loading... |
67 // Map keyed by app_id to app_update_content. | 66 // Map keyed by app_id to app_update_content. |
68 std::map<std::string, std::string> id_to_update_check_content_map_; | 67 std::map<std::string, std::string> id_to_update_check_content_map_; |
69 int update_check_count_; | 68 int update_check_count_; |
70 | 69 |
71 DISALLOW_COPY_AND_ASSIGN(FakeCWS); | 70 DISALLOW_COPY_AND_ASSIGN(FakeCWS); |
72 }; | 71 }; |
73 | 72 |
74 } // namespace chromeos | 73 } // namespace chromeos |
75 | 74 |
76 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ | 75 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ |
OLD | NEW |