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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_
8 #include "net/test/embedded_test_server/embedded_test_server.h"
9 #include "net/test/embedded_test_server/http_request.h"
10 #include "net/test/embedded_test_server/http_response.h"
15 // Simple fake CWS update check request handler that returns a fixed update
16 // check response. The response is created either from SetUpdateCrx() or
23 // Initializes as CWS request handler and overrides app gallery command line
25 void Init(net::test_server::EmbeddedTestServer
* embedded_test_server
);
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
);
35 // Sets up the update check response with has_update template.
36 void SetUpdateCrx(const std::string
& app_id
,
37 const std::string
& crx_file
,
38 const std::string
& version
);
40 // Sets up the update check response with no_update template.
41 void SetNoUpdate(const std::string
& app_id
);
43 // Returns the current |update_check_count_| and resets it.
44 int GetUpdateCheckCountAndReset();
47 void SetupWebStoreURL(const GURL
& test_server_url
);
48 void OverrideGalleryCommandlineSwitches();
50 // Sets up |update_check_content_| used in update request response later by
51 // kiosk app update server request handler |HandleRequest|.
52 void SetUpdateCheckContent(const std::string
& update_check_file
,
53 const GURL
& crx_download_url
,
54 const std::string
& app_id
,
55 const std::string
& crx_fp
,
56 const std::string
& crx_size
,
57 const std::string
& version
,
58 std::string
* update_check_content
);
60 // Request handler for kiosk app update server.
61 scoped_ptr
<net::test_server::HttpResponse
> HandleRequest(
62 const net::test_server::HttpRequest
& request
);
66 std::string has_update_template_
;
67 std::string no_update_template_
;
68 std::string update_check_end_point_
;
70 std::string update_check_content_
;
71 int update_check_count_
;
73 DISALLOW_COPY_AND_ASSIGN(FakeCWS
);
76 } // namespace chromeos
78 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_