| 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 #include "chrome/browser/ui/webui/chromeos/system_info_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/system_info_ui.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/chromeos/cros/cros_library.h" | 17 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 18 #include "chrome/browser/chromeos/system_access.h" | 18 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/jstemplate_builder.h" | 22 #include "chrome/common/jstemplate_builder.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "content/browser/browser_thread.h" | 24 #include "content/browser/browser_thread.h" |
| 25 #include "content/browser/tab_contents/tab_contents.h" | 25 #include "content/browser/tab_contents/tab_contents.h" |
| 26 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
| 27 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 41 virtual void StartDataRequest(const std::string& path, | 41 virtual void StartDataRequest(const std::string& path, |
| 42 bool is_incognito, | 42 bool is_incognito, |
| 43 int request_id); | 43 int request_id); |
| 44 virtual std::string GetMimeType(const std::string&) const { | 44 virtual std::string GetMimeType(const std::string&) const { |
| 45 return "text/html"; | 45 return "text/html"; |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 ~SystemInfoUIHTMLSource() {} | 49 ~SystemInfoUIHTMLSource() {} |
| 50 | 50 |
| 51 void SyslogsComplete(chromeos::LogDictionaryType* sys_info, | 51 void SyslogsComplete(chromeos::system::LogDictionaryType* sys_info, |
| 52 std::string* ignored_content); | 52 std::string* ignored_content); |
| 53 | 53 |
| 54 CancelableRequestConsumer consumer_; | 54 CancelableRequestConsumer consumer_; |
| 55 | 55 |
| 56 // Stored data from StartDataRequest() | 56 // Stored data from StartDataRequest() |
| 57 std::string path_; | 57 std::string path_; |
| 58 int request_id_; | 58 int request_id_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource); | 60 DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource); |
| 61 }; | 61 }; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 85 : DataSource(chrome::kChromeUISystemInfoHost, MessageLoop::current()), | 85 : DataSource(chrome::kChromeUISystemInfoHost, MessageLoop::current()), |
| 86 request_id_(0) { | 86 request_id_(0) { |
| 87 } | 87 } |
| 88 | 88 |
| 89 void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path, | 89 void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path, |
| 90 bool is_incognito, | 90 bool is_incognito, |
| 91 int request_id) { | 91 int request_id) { |
| 92 path_ = path; | 92 path_ = path; |
| 93 request_id_ = request_id; | 93 request_id_ = request_id; |
| 94 | 94 |
| 95 chromeos::SystemAccess* system_access = | 95 chromeos::system::SyslogsProvider* provider = |
| 96 chromeos::SystemAccess::GetInstance(); | 96 chromeos::system::SyslogsProvider::GetInstance(); |
| 97 if (system_access) { | 97 if (provider) { |
| 98 system_access->RequestSyslogs( | 98 provider->RequestSyslogs( |
| 99 false, // don't compress. | 99 false, // don't compress. |
| 100 chromeos::SystemAccess::SYSLOGS_SYSINFO, | 100 chromeos::system::SyslogsProvider::SYSLOGS_SYSINFO, |
| 101 &consumer_, | 101 &consumer_, |
| 102 NewCallback(this, &SystemInfoUIHTMLSource::SyslogsComplete)); | 102 NewCallback(this, &SystemInfoUIHTMLSource::SyslogsComplete)); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 void SystemInfoUIHTMLSource::SyslogsComplete( | 106 void SystemInfoUIHTMLSource::SyslogsComplete( |
| 107 chromeos::LogDictionaryType* sys_info, | 107 chromeos::system::LogDictionaryType* sys_info, |
| 108 std::string* ignored_content) { | 108 std::string* ignored_content) { |
| 109 DCHECK(!ignored_content); | 109 DCHECK(!ignored_content); |
| 110 | 110 |
| 111 DictionaryValue strings; | 111 DictionaryValue strings; |
| 112 strings.SetString("title", l10n_util::GetStringUTF16(IDS_ABOUT_SYS_TITLE)); | 112 strings.SetString("title", l10n_util::GetStringUTF16(IDS_ABOUT_SYS_TITLE)); |
| 113 strings.SetString("description", | 113 strings.SetString("description", |
| 114 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_DESC)); | 114 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_DESC)); |
| 115 strings.SetString("table_title", | 115 strings.SetString("table_title", |
| 116 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_TABLE_TITLE)); | 116 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_TABLE_TITLE)); |
| 117 strings.SetString("expand_all_btn", | 117 strings.SetString("expand_all_btn", |
| 118 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_EXPAND_ALL)); | 118 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_EXPAND_ALL)); |
| 119 strings.SetString("collapse_all_btn", | 119 strings.SetString("collapse_all_btn", |
| 120 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE_ALL)); | 120 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE_ALL)); |
| 121 strings.SetString("expand_btn", | 121 strings.SetString("expand_btn", |
| 122 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_EXPAND)); | 122 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_EXPAND)); |
| 123 strings.SetString("collapse_btn", | 123 strings.SetString("collapse_btn", |
| 124 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE)); | 124 l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE)); |
| 125 SetFontAndTextDirection(&strings); | 125 SetFontAndTextDirection(&strings); |
| 126 | 126 |
| 127 if (sys_info) { | 127 if (sys_info) { |
| 128 ListValue* details = new ListValue(); | 128 ListValue* details = new ListValue(); |
| 129 strings.Set("details", details); | 129 strings.Set("details", details); |
| 130 chromeos::LogDictionaryType::iterator it; | 130 chromeos::system::LogDictionaryType::iterator it; |
| 131 for (it = sys_info->begin(); it != sys_info->end(); ++it) { | 131 for (it = sys_info->begin(); it != sys_info->end(); ++it) { |
| 132 DictionaryValue* val = new DictionaryValue; | 132 DictionaryValue* val = new DictionaryValue; |
| 133 val->SetString("stat_name", it->first); | 133 val->SetString("stat_name", it->first); |
| 134 val->SetString("stat_value", it->second); | 134 val->SetString("stat_value", it->second); |
| 135 details->Append(val); | 135 details->Append(val); |
| 136 } | 136 } |
| 137 strings.SetString("anchor", path_); | 137 strings.SetString("anchor", path_); |
| 138 delete sys_info; | 138 delete sys_info; |
| 139 } | 139 } |
| 140 static const base::StringPiece systeminfo_html( | 140 static const base::StringPiece systeminfo_html( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 //////////////////////////////////////////////////////////////////////////////// | 177 //////////////////////////////////////////////////////////////////////////////// |
| 178 | 178 |
| 179 SystemInfoUI::SystemInfoUI(TabContents* contents) : ChromeWebUI(contents) { | 179 SystemInfoUI::SystemInfoUI(TabContents* contents) : ChromeWebUI(contents) { |
| 180 SystemInfoHandler* handler = new SystemInfoHandler(); | 180 SystemInfoHandler* handler = new SystemInfoHandler(); |
| 181 AddMessageHandler((handler)->Attach(this)); | 181 AddMessageHandler((handler)->Attach(this)); |
| 182 SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); | 182 SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); |
| 183 | 183 |
| 184 // Set up the chrome://system/ source. | 184 // Set up the chrome://system/ source. |
| 185 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 185 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
| 186 } | 186 } |
| OLD | NEW |