| 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 AboutUIHTMLSource(const std::string& source, Profile* profile); |
| 21 AboutUIHTMLSource(const std::string& source_name, Profile* profile); | |
| 22 | 24 |
| 23 // Called when the network layer has requested a resource underneath | 25 // content::URLDataSourceDelegate implementation: |
| 24 // the path we registered. | 26 virtual std::string GetSource() OVERRIDE; |
| 25 virtual void StartDataRequest(const std::string& path, | 27 virtual void StartDataRequest(const std::string& path, |
| 26 bool is_incognito, | 28 bool is_incognito, |
| 27 int request_id) OVERRIDE; | 29 int request_id) OVERRIDE; |
| 28 | |
| 29 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; | 30 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; |
| 30 | 31 |
| 31 // Send the response data. | 32 // Send the response data. |
| 32 void FinishDataRequest(const std::string& html, int request_id); | 33 void FinishDataRequest(const std::string& html, int request_id); |
| 33 | 34 |
| 34 Profile* profile() { return profile_; } | 35 Profile* profile() { return profile_; } |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 virtual ~AboutUIHTMLSource(); | 38 virtual ~AboutUIHTMLSource(); |
| 38 | 39 |
| 40 std::string source_; |
| 39 Profile* profile_; | 41 Profile* profile_; |
| 40 | 42 |
| 41 DISALLOW_COPY_AND_ASSIGN(AboutUIHTMLSource); | 43 DISALLOW_COPY_AND_ASSIGN(AboutUIHTMLSource); |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 class AboutUI : public content::WebUIController { | 46 class AboutUI : public content::WebUIController { |
| 45 public: | 47 public: |
| 46 explicit AboutUI(content::WebUI* web_ui, const std::string& host); | 48 explicit AboutUI(content::WebUI* web_ui, const std::string& host); |
| 47 virtual ~AboutUI() {} | 49 virtual ~AboutUI() {} |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(AboutUI); | 52 DISALLOW_COPY_AND_ASSIGN(AboutUI); |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 namespace about_ui { | 55 namespace about_ui { |
| 54 | 56 |
| 55 // Helper functions | 57 // Helper functions |
| 56 void AppendHeader(std::string* output, int refresh, | 58 void AppendHeader(std::string* output, int refresh, |
| 57 const std::string& unescaped_title); | 59 const std::string& unescaped_title); |
| 58 void AppendBody(std::string *output); | 60 void AppendBody(std::string *output); |
| 59 void AppendFooter(std::string *output); | 61 void AppendFooter(std::string *output); |
| 60 | 62 |
| 61 } // namespace about_ui | 63 } // namespace about_ui |
| 62 | 64 |
| 63 #endif // CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ | 65 #endif // CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ |
| OLD | NEW |