OLD | NEW |
| (Empty) |
1 // Copyright 2015 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. | |
4 | |
5 #ifndef MOJO_FETCHER_ABOUT_FETCHER_H_ | |
6 #define MOJO_FETCHER_ABOUT_FETCHER_H_ | |
7 | |
8 #include "mojo/shell/fetcher.h" | |
9 | |
10 #include <stdint.h> | |
11 | |
12 #include "base/macros.h" | |
13 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | |
14 #include "url/gurl.h" | |
15 | |
16 namespace mojo { | |
17 namespace fetcher { | |
18 | |
19 // Implements Fetcher for about: URLs. | |
20 class AboutFetcher : public shell::Fetcher { | |
21 public: | |
22 static const char kAboutScheme[]; | |
23 static const char kAboutBlankURL[]; | |
24 | |
25 static void Start(const GURL& url, const FetchCallback& loader_callback); | |
26 | |
27 private: | |
28 AboutFetcher(const GURL& url, const FetchCallback& loader_callback); | |
29 ~AboutFetcher() override; | |
30 | |
31 void BuildResponse(); | |
32 | |
33 // Must be called exactly once to run the loader callback (asynchrously). On | |
34 // success, the ownership of this object is passed to the loader callback; | |
35 // otherwise, the callback is run with a nullptr and this object is destroyed. | |
36 void PostToRunCallback(bool success); | |
37 | |
38 // shell::Fetcher implementation. | |
39 const GURL& GetURL() const override; | |
40 GURL GetRedirectURL() const override; | |
41 GURL GetRedirectReferer() const override; | |
42 URLResponsePtr AsURLResponse(base::TaskRunner* task_runner, | |
43 uint32_t skip) override; | |
44 void AsPath( | |
45 base::TaskRunner* task_runner, | |
46 base::Callback<void(const base::FilePath&, bool)> callback) override; | |
47 std::string MimeType() override; | |
48 bool HasMojoMagic() override; | |
49 bool PeekFirstLine(std::string* line) override; | |
50 | |
51 const GURL url_; | |
52 URLResponsePtr response_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(AboutFetcher); | |
55 }; | |
56 | |
57 } // namespace fetcher | |
58 } // namespace mojo | |
59 | |
60 #endif // MOJO_FETCHER_ABOUT_FETCHER_H_ | |
OLD | NEW |