Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / mock_url_fetchers.h
blobbc1fdb2d598eaccdfe34f01e7a3a8256a1119a41
1 // Copyright (c) 2012 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_LOGIN_MOCK_URL_FETCHERS_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "net/url_request/test_url_fetcher_factory.h"
14 #include "net/url_request/url_request_status.h"
15 #include "url/gurl.h"
17 namespace net {
18 class URLFetcherDelegate;
21 namespace chromeos {
23 // Simulates a URL fetch by posting a delayed task. This fetch expects to be
24 // canceled, and fails the test if it is not
25 class ExpectCanceledFetcher : public net::TestURLFetcher {
26 public:
27 ExpectCanceledFetcher(bool success,
28 const GURL& url,
29 const std::string& results,
30 net::URLFetcher::RequestType request_type,
31 net::URLFetcherDelegate* d);
32 virtual ~ExpectCanceledFetcher();
34 virtual void Start() OVERRIDE;
36 void CompleteFetch();
38 private:
39 base::WeakPtrFactory<ExpectCanceledFetcher> weak_factory_;
40 DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher);
43 class GotCanceledFetcher : public net::TestURLFetcher {
44 public:
45 GotCanceledFetcher(bool success,
46 const GURL& url,
47 const std::string& results,
48 net::URLFetcher::RequestType request_type,
49 net::URLFetcherDelegate* d);
50 virtual ~GotCanceledFetcher();
52 virtual void Start() OVERRIDE;
54 private:
55 DISALLOW_COPY_AND_ASSIGN(GotCanceledFetcher);
58 class SuccessFetcher : public net::TestURLFetcher {
59 public:
60 SuccessFetcher(bool success,
61 const GURL& url,
62 const std::string& results,
63 net::URLFetcher::RequestType request_type,
64 net::URLFetcherDelegate* d);
65 virtual ~SuccessFetcher();
67 virtual void Start() OVERRIDE;
69 private:
70 DISALLOW_COPY_AND_ASSIGN(SuccessFetcher);
73 class FailFetcher : public net::TestURLFetcher {
74 public:
75 FailFetcher(bool success,
76 const GURL& url,
77 const std::string& results,
78 net::URLFetcher::RequestType request_type,
79 net::URLFetcherDelegate* d);
80 virtual ~FailFetcher();
82 virtual void Start() OVERRIDE;
84 private:
85 DISALLOW_COPY_AND_ASSIGN(FailFetcher);
88 class CaptchaFetcher : public net::TestURLFetcher {
89 public:
90 CaptchaFetcher(bool success,
91 const GURL& url,
92 const std::string& results,
93 net::URLFetcher::RequestType request_type,
94 net::URLFetcherDelegate* d);
95 virtual ~CaptchaFetcher();
97 static std::string GetCaptchaToken();
98 static std::string GetCaptchaUrl();
99 static std::string GetUnlockUrl();
101 virtual void Start() OVERRIDE;
103 private:
104 static const char kCaptchaToken[];
105 static const char kCaptchaUrlBase[];
106 static const char kCaptchaUrlFragment[];
107 static const char kUnlockUrl[];
108 DISALLOW_COPY_AND_ASSIGN(CaptchaFetcher);
111 class HostedFetcher : public net::TestURLFetcher {
112 public:
113 HostedFetcher(bool success,
114 const GURL& url,
115 const std::string& results,
116 net::URLFetcher::RequestType request_type,
117 net::URLFetcherDelegate* d);
118 virtual ~HostedFetcher();
120 virtual void Start() OVERRIDE;
122 private:
123 DISALLOW_COPY_AND_ASSIGN(HostedFetcher);
126 } // namespace chromeos
128 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_