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_
12 #include "net/test/embedded_test_server/embedded_test_server.h"
13 #include "net/test/embedded_test_server/http_request.h"
14 #include "net/test/embedded_test_server/http_response.h"
19 // Simple fake CWS update check request handler that returns a fixed update
20 // check response. The response is created either from SetUpdateCrx() or
27 // Initializes as CWS request handler and overrides app gallery command line
29 void Init(net::test_server::EmbeddedTestServer
* embedded_test_server
);
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
33 // slightly different template (as documented on
34 // https://developer.chrome.com/extensions/autoupdate).
35 void InitAsPrivateStore(
36 net::test_server::EmbeddedTestServer
* embedded_test_server
,
37 const std::string
& update_check_end_point
);
39 // Sets up the update check response with has_update template.
40 void SetUpdateCrx(const std::string
& app_id
,
41 const std::string
& crx_file
,
42 const std::string
& version
);
44 // Sets up the update check response with no_update template.
45 void SetNoUpdate(const std::string
& app_id
);
47 // Returns the current |update_check_count_| and resets it.
48 int GetUpdateCheckCountAndReset();
51 void SetupWebStoreURL(const GURL
& test_server_url
);
52 void OverrideGalleryCommandlineSwitches();
54 bool GetUpdateCheckContent(const std::vector
<std::string
>& ids
,
55 std::string
* update_check_content
);
57 // Request handler for kiosk app update server.
58 scoped_ptr
<net::test_server::HttpResponse
> HandleRequest(
59 const net::test_server::HttpRequest
& request
);
63 std::string has_update_template_
;
64 std::string no_update_template_
;
65 std::string update_check_end_point_
;
67 // Map keyed by app_id to app_update_content.
68 std::map
<std::string
, std::string
> id_to_update_check_content_map_
;
69 int update_check_count_
;
71 DISALLOW_COPY_AND_ASSIGN(FakeCWS
);
74 } // namespace chromeos
76 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_FAKE_CWS_H_