| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/webui/system_info_ui.h" | 5 #include "chrome/browser/ui/webui/system_info_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 using content::WebContents; | 40 using content::WebContents; |
| 41 using content::WebUIMessageHandler; | 41 using content::WebUIMessageHandler; |
| 42 using system_logs::SystemLogsResponse; | 42 using system_logs::SystemLogsResponse; |
| 43 using system_logs::AboutSystemLogsFetcher; | 43 using system_logs::AboutSystemLogsFetcher; |
| 44 | 44 |
| 45 class SystemInfoUIHTMLSource : public content::URLDataSource{ | 45 class SystemInfoUIHTMLSource : public content::URLDataSource{ |
| 46 public: | 46 public: |
| 47 SystemInfoUIHTMLSource(); | 47 SystemInfoUIHTMLSource(); |
| 48 | 48 |
| 49 // content::URLDataSource implementation. | 49 // content::URLDataSource implementation. |
| 50 virtual std::string GetSource() const OVERRIDE; | 50 virtual std::string GetSource() const override; |
| 51 virtual void StartDataRequest( | 51 virtual void StartDataRequest( |
| 52 const std::string& path, | 52 const std::string& path, |
| 53 int render_process_id, | 53 int render_process_id, |
| 54 int render_frame_id, | 54 int render_frame_id, |
| 55 const content::URLDataSource::GotDataCallback& callback) OVERRIDE; | 55 const content::URLDataSource::GotDataCallback& callback) override; |
| 56 virtual std::string GetMimeType(const std::string&) const OVERRIDE { | 56 virtual std::string GetMimeType(const std::string&) const override { |
| 57 return "text/html"; | 57 return "text/html"; |
| 58 } | 58 } |
| 59 virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { | 59 virtual bool ShouldAddContentSecurityPolicy() const override { |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 virtual ~SystemInfoUIHTMLSource() {} | 64 virtual ~SystemInfoUIHTMLSource() {} |
| 65 | 65 |
| 66 void SysInfoComplete(scoped_ptr<SystemLogsResponse> response); | 66 void SysInfoComplete(scoped_ptr<SystemLogsResponse> response); |
| 67 void RequestComplete(); | 67 void RequestComplete(); |
| 68 void WaitForData(); | 68 void WaitForData(); |
| 69 | 69 |
| 70 // Stored data from StartDataRequest() | 70 // Stored data from StartDataRequest() |
| 71 std::string path_; | 71 std::string path_; |
| 72 content::URLDataSource::GotDataCallback callback_; | 72 content::URLDataSource::GotDataCallback callback_; |
| 73 | 73 |
| 74 scoped_ptr<SystemLogsResponse> response_; | 74 scoped_ptr<SystemLogsResponse> response_; |
| 75 base::WeakPtrFactory<SystemInfoUIHTMLSource> weak_ptr_factory_; | 75 base::WeakPtrFactory<SystemInfoUIHTMLSource> weak_ptr_factory_; |
| 76 DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource); | 76 DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // The handler for Javascript messages related to the "system" view. | 79 // The handler for Javascript messages related to the "system" view. |
| 80 class SystemInfoHandler : public WebUIMessageHandler, | 80 class SystemInfoHandler : public WebUIMessageHandler, |
| 81 public base::SupportsWeakPtr<SystemInfoHandler> { | 81 public base::SupportsWeakPtr<SystemInfoHandler> { |
| 82 public: | 82 public: |
| 83 SystemInfoHandler(); | 83 SystemInfoHandler(); |
| 84 virtual ~SystemInfoHandler(); | 84 virtual ~SystemInfoHandler(); |
| 85 | 85 |
| 86 // WebUIMessageHandler implementation. | 86 // WebUIMessageHandler implementation. |
| 87 virtual void RegisterMessages() OVERRIDE; | 87 virtual void RegisterMessages() override; |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); | 90 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 //////////////////////////////////////////////////////////////////////////////// | 93 //////////////////////////////////////////////////////////////////////////////// |
| 94 // | 94 // |
| 95 // SystemInfoUIHTMLSource | 95 // SystemInfoUIHTMLSource |
| 96 // | 96 // |
| 97 //////////////////////////////////////////////////////////////////////////////// | 97 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 SystemInfoUI::SystemInfoUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 186 SystemInfoUI::SystemInfoUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 187 SystemInfoHandler* handler = new SystemInfoHandler(); | 187 SystemInfoHandler* handler = new SystemInfoHandler(); |
| 188 web_ui->AddMessageHandler(handler); | 188 web_ui->AddMessageHandler(handler); |
| 189 SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); | 189 SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); |
| 190 | 190 |
| 191 // Set up the chrome://system/ source. | 191 // Set up the chrome://system/ source. |
| 192 Profile* profile = Profile::FromWebUI(web_ui); | 192 Profile* profile = Profile::FromWebUI(web_ui); |
| 193 content::URLDataSource::Add(profile, html_source); | 193 content::URLDataSource::Add(profile, html_source); |
| 194 } | 194 } |
| OLD | NEW |