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 std::string GetSource() const override; |
51 virtual void StartDataRequest( | 51 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 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 bool ShouldAddContentSecurityPolicy() const override { return false; } |
60 return false; | |
61 } | |
62 | 60 |
63 private: | 61 private: |
64 virtual ~SystemInfoUIHTMLSource() {} | 62 ~SystemInfoUIHTMLSource() override {} |
65 | 63 |
66 void SysInfoComplete(scoped_ptr<SystemLogsResponse> response); | 64 void SysInfoComplete(scoped_ptr<SystemLogsResponse> response); |
67 void RequestComplete(); | 65 void RequestComplete(); |
68 void WaitForData(); | 66 void WaitForData(); |
69 | 67 |
70 // Stored data from StartDataRequest() | 68 // Stored data from StartDataRequest() |
71 std::string path_; | 69 std::string path_; |
72 content::URLDataSource::GotDataCallback callback_; | 70 content::URLDataSource::GotDataCallback callback_; |
73 | 71 |
74 scoped_ptr<SystemLogsResponse> response_; | 72 scoped_ptr<SystemLogsResponse> response_; |
75 base::WeakPtrFactory<SystemInfoUIHTMLSource> weak_ptr_factory_; | 73 base::WeakPtrFactory<SystemInfoUIHTMLSource> weak_ptr_factory_; |
76 DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource); | 74 DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource); |
77 }; | 75 }; |
78 | 76 |
79 // The handler for Javascript messages related to the "system" view. | 77 // The handler for Javascript messages related to the "system" view. |
80 class SystemInfoHandler : public WebUIMessageHandler, | 78 class SystemInfoHandler : public WebUIMessageHandler, |
81 public base::SupportsWeakPtr<SystemInfoHandler> { | 79 public base::SupportsWeakPtr<SystemInfoHandler> { |
82 public: | 80 public: |
83 SystemInfoHandler(); | 81 SystemInfoHandler(); |
84 virtual ~SystemInfoHandler(); | 82 ~SystemInfoHandler() override; |
85 | 83 |
86 // WebUIMessageHandler implementation. | 84 // WebUIMessageHandler implementation. |
87 virtual void RegisterMessages() override; | 85 void RegisterMessages() override; |
88 | 86 |
89 private: | 87 private: |
90 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); | 88 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); |
91 }; | 89 }; |
92 | 90 |
93 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
94 // | 92 // |
95 // SystemInfoUIHTMLSource | 93 // SystemInfoUIHTMLSource |
96 // | 94 // |
97 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 183 |
186 SystemInfoUI::SystemInfoUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 184 SystemInfoUI::SystemInfoUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
187 SystemInfoHandler* handler = new SystemInfoHandler(); | 185 SystemInfoHandler* handler = new SystemInfoHandler(); |
188 web_ui->AddMessageHandler(handler); | 186 web_ui->AddMessageHandler(handler); |
189 SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); | 187 SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); |
190 | 188 |
191 // Set up the chrome://system/ source. | 189 // Set up the chrome://system/ source. |
192 Profile* profile = Profile::FromWebUI(web_ui); | 190 Profile* profile = Profile::FromWebUI(web_ui); |
193 content::URLDataSource::Add(profile, html_source); | 191 content::URLDataSource::Add(profile, html_source); |
194 } | 192 } |
OLD | NEW |