| 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 "net/test/embedded_test_server/embedded_test_server.h" | 8 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 9 #include "net/test/embedded_test_server/http_request.h" | 9 #include "net/test/embedded_test_server/http_request.h" |
| 10 #include "net/test/embedded_test_server/http_response.h" | 10 #include "net/test/embedded_test_server/http_response.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 | 14 |
| 15 // Simple fake CWS update check request handler that returns a fixed update |
| 16 // check response. The response is created either from SetUpdateCrx() or |
| 17 // SetNoUpdate(). |
| 15 class FakeCWS { | 18 class FakeCWS { |
| 16 public: | 19 public: |
| 17 FakeCWS() {} | 20 FakeCWS(); |
| 18 virtual ~FakeCWS() {} | 21 ~FakeCWS(); |
| 19 | 22 |
| 23 // Initializes as CWS request handler and overrides app gallery command line |
| 24 // switches. |
| 20 void Init(net::test_server::EmbeddedTestServer* embedded_test_server); | 25 void Init(net::test_server::EmbeddedTestServer* embedded_test_server); |
| 21 // Sets up the kiosk app update response. | 26 |
| 27 // Initializes as a private store handler using the given server and URL end |
| 28 // point. Private store does not override app gallery command lines and use a |
| 29 // slightly different template (as documented on |
| 30 // https://developer.chrome.com/extensions/autoupdate). |
| 31 void InitAsPrivateStore( |
| 32 net::test_server::EmbeddedTestServer* embedded_test_server, |
| 33 const std::string& update_check_end_point); |
| 34 |
| 35 // Sets up the update check response with has_update template. |
| 22 void SetUpdateCrx(const std::string& app_id, | 36 void SetUpdateCrx(const std::string& app_id, |
| 23 const std::string& crx_file, | 37 const std::string& crx_file, |
| 24 const std::string& version); | 38 const std::string& version); |
| 39 |
| 40 // Sets up the update check response with no_update template. |
| 25 void SetNoUpdate(const std::string& app_id); | 41 void SetNoUpdate(const std::string& app_id); |
| 26 | 42 |
| 43 // Returns the current |update_check_count_| and resets it. |
| 44 int GetUpdateCheckCountAndReset(); |
| 45 |
| 27 private: | 46 private: |
| 28 void SetupWebStore(const GURL& test_server_url); | 47 void SetupWebStoreURL(const GURL& test_server_url); |
| 29 void SetupWebStoreGalleryUrl(); | 48 void OverrideGalleryCommandlineSwitches(); |
| 30 void SetupCrxDownloadAndUpdateUrls( | 49 |
| 31 net::test_server::EmbeddedTestServer* embedded_test_server); | |
| 32 void SetupCrxDownloadUrl(); | |
| 33 void SetupCrxUpdateUrl( | |
| 34 net::test_server::EmbeddedTestServer* embedded_test_server); | |
| 35 // Sets up |update_check_content_| used in update request response later by | 50 // Sets up |update_check_content_| used in update request response later by |
| 36 // kiosk app update server request handler |HandleRequest|. | 51 // kiosk app update server request handler |HandleRequest|. |
| 37 void SetUpdateCheckContent(const std::string& update_check_file, | 52 void SetUpdateCheckContent(const std::string& update_check_file, |
| 38 const GURL& crx_download_url, | 53 const GURL& crx_download_url, |
| 39 const std::string& app_id, | 54 const std::string& app_id, |
| 40 const std::string& crx_fp, | 55 const std::string& crx_fp, |
| 41 const std::string& crx_size, | 56 const std::string& crx_size, |
| 42 const std::string& version, | 57 const std::string& version, |
| 43 std::string* update_check_content); | 58 std::string* update_check_content); |
| 59 |
| 44 // Request handler for kiosk app update server. | 60 // Request handler for kiosk app update server. |
| 45 scoped_ptr<net::test_server::HttpResponse> HandleRequest( | 61 scoped_ptr<net::test_server::HttpResponse> HandleRequest( |
| 46 const net::test_server::HttpRequest& request); | 62 const net::test_server::HttpRequest& request); |
| 47 | 63 |
| 48 GURL web_store_url_; | 64 GURL web_store_url_; |
| 65 |
| 66 std::string has_update_template_; |
| 67 std::string no_update_template_; |
| 68 std::string update_check_end_point_; |
| 69 |
| 49 std::string update_check_content_; | 70 std::string update_check_content_; |
| 71 int update_check_count_; |
| 50 | 72 |
| 51 DISALLOW_COPY_AND_ASSIGN(FakeCWS); | 73 DISALLOW_COPY_AND_ASSIGN(FakeCWS); |
| 52 }; | 74 }; |
| 53 | 75 |
| 54 } // namespace chromeos | 76 } // namespace chromeos |
| 55 | 77 |
| 56 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ | 78 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_ |
| OLD | NEW |