OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_UI_WEBUI_ABOUT_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/public/browser/url_data_source_delegate.h" |
12 #include "content/public/browser/web_ui_controller.h" | 14 #include "content/public/browser/web_ui_controller.h" |
13 | 15 |
14 class Profile; | 16 class Profile; |
15 | 17 |
16 // We expose this class because the OOBE flow may need to explicitly add the | 18 // We expose this class because the OOBE flow may need to explicitly add the |
17 // chrome://terms source outside of the normal flow. | 19 // chrome://terms source outside of the normal flow. |
18 class AboutUIHTMLSource : public ChromeURLDataManager::DataSource { | 20 class AboutUIHTMLSource : public content::URLDataSourceDelegate, |
| 21 public base::SupportsWeakPtr<AboutUIHTMLSource> { |
19 public: | 22 public: |
20 // Construct a data source for the specified |source_name|. | 23 // Construct a data source for the specified |source_name|. |
21 AboutUIHTMLSource(const std::string& source_name, Profile* profile); | 24 AboutUIHTMLSource(const std::string& source_name, Profile* profile); |
22 | 25 |
23 // Called when the network layer has requested a resource underneath | 26 // content::URLDataSourceDelegate implementation. |
24 // the path we registered. | 27 virtual std::string GetSource() OVERRIDE; |
25 virtual void StartDataRequest(const std::string& path, | 28 virtual void StartDataRequest(const std::string& path, |
26 bool is_incognito, | 29 bool is_incognito, |
27 int request_id) OVERRIDE; | 30 int request_id) OVERRIDE; |
28 | |
29 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; | 31 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; |
30 | 32 |
31 // Send the response data. | 33 // Send the response data. |
32 void FinishDataRequest(const std::string& html, int request_id); | 34 void FinishDataRequest(const std::string& html, int request_id); |
33 | 35 |
34 Profile* profile() { return profile_; } | 36 Profile* profile() { return profile_; } |
35 | 37 |
36 private: | 38 private: |
37 virtual ~AboutUIHTMLSource(); | 39 virtual ~AboutUIHTMLSource(); |
38 | 40 |
| 41 std::string source_name_; |
39 Profile* profile_; | 42 Profile* profile_; |
40 | 43 |
41 DISALLOW_COPY_AND_ASSIGN(AboutUIHTMLSource); | 44 DISALLOW_COPY_AND_ASSIGN(AboutUIHTMLSource); |
42 }; | 45 }; |
43 | 46 |
44 class AboutUI : public content::WebUIController { | 47 class AboutUI : public content::WebUIController { |
45 public: | 48 public: |
46 explicit AboutUI(content::WebUI* web_ui, const std::string& host); | 49 explicit AboutUI(content::WebUI* web_ui, const std::string& host); |
47 virtual ~AboutUI() {} | 50 virtual ~AboutUI() {} |
48 | 51 |
49 private: | 52 private: |
50 DISALLOW_COPY_AND_ASSIGN(AboutUI); | 53 DISALLOW_COPY_AND_ASSIGN(AboutUI); |
51 }; | 54 }; |
52 | 55 |
53 namespace about_ui { | 56 namespace about_ui { |
54 | 57 |
55 // Helper functions | 58 // Helper functions |
56 void AppendHeader(std::string* output, int refresh, | 59 void AppendHeader(std::string* output, int refresh, |
57 const std::string& unescaped_title); | 60 const std::string& unescaped_title); |
58 void AppendBody(std::string *output); | 61 void AppendBody(std::string *output); |
59 void AppendFooter(std::string *output); | 62 void AppendFooter(std::string *output); |
60 | 63 |
61 } // namespace about_ui | 64 } // namespace about_ui |
62 | 65 |
63 #endif // CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ | 66 #endif // CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ |
OLD | NEW |