| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gpu_internals_ui.h" | 5 #include "chrome/browser/ui/webui/gpu_internals_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "content/public/browser/gpu_data_manager.h" | 27 #include "content/public/browser/gpu_data_manager.h" |
| 28 #include "content/public/browser/gpu_data_manager_observer.h" | 28 #include "content/public/browser/gpu_data_manager_observer.h" |
| 29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 30 #include "content/public/browser/web_ui.h" | 30 #include "content/public/browser/web_ui.h" |
| 31 #include "content/public/browser/web_ui_message_handler.h" | 31 #include "content/public/browser/web_ui_message_handler.h" |
| 32 #include "grit/browser_resources.h" | 32 #include "grit/browser_resources.h" |
| 33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 34 #include "third_party/angle/src/common/version.h" | 34 #include "third_party/angle/src/common/version.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 | 36 |
| 37 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 38 #include "content/public/browser/zygote_host_linux.h" |
| 39 #include "content/public/common/sandbox_linux.h" |
| 40 #endif |
| 41 |
| 37 using content::BrowserThread; | 42 using content::BrowserThread; |
| 38 using content::GpuDataManager; | 43 using content::GpuDataManager; |
| 39 using content::WebContents; | 44 using content::WebContents; |
| 40 using content::WebUIMessageHandler; | 45 using content::WebUIMessageHandler; |
| 41 | 46 |
| 42 namespace { | 47 namespace { |
| 43 | 48 |
| 44 ChromeWebUIDataSource* CreateGpuHTMLSource() { | 49 ChromeWebUIDataSource* CreateGpuHTMLSource() { |
| 45 ChromeWebUIDataSource* source = | 50 ChromeWebUIDataSource* source = |
| 46 new ChromeWebUIDataSource(chrome::kChromeUIGpuInternalsHost); | 51 new ChromeWebUIDataSource(chrome::kChromeUIGpuInternalsHost); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 74 | 79 |
| 75 // CrashUploadList::Delegate implemenation. | 80 // CrashUploadList::Delegate implemenation. |
| 76 virtual void OnCrashListAvailable() OVERRIDE; | 81 virtual void OnCrashListAvailable() OVERRIDE; |
| 77 | 82 |
| 78 // Messages | 83 // Messages |
| 79 void OnBrowserBridgeInitialized(const ListValue* list); | 84 void OnBrowserBridgeInitialized(const ListValue* list); |
| 80 void OnCallAsync(const ListValue* list); | 85 void OnCallAsync(const ListValue* list); |
| 81 | 86 |
| 82 // Submessages dispatched from OnCallAsync | 87 // Submessages dispatched from OnCallAsync |
| 83 Value* OnRequestClientInfo(const ListValue* list); | 88 Value* OnRequestClientInfo(const ListValue* list); |
| 89 Value* OnRequestSandboxInfo(const ListValue* list); |
| 84 Value* OnRequestLogMessages(const ListValue* list); | 90 Value* OnRequestLogMessages(const ListValue* list); |
| 85 Value* OnRequestCrashList(const ListValue* list); | 91 Value* OnRequestCrashList(const ListValue* list); |
| 86 | 92 |
| 87 // Executes the javascript function |function_name| in the renderer, passing | 93 // Executes the javascript function |function_name| in the renderer, passing |
| 88 // it the argument |value|. | 94 // it the argument |value|. |
| 89 void CallJavascriptFunction(const std::wstring& function_name, | 95 void CallJavascriptFunction(const std::wstring& function_name, |
| 90 const Value* value); | 96 const Value* value); |
| 91 | 97 |
| 92 private: | 98 private: |
| 93 scoped_refptr<CrashUploadList> crash_list_; | 99 scoped_refptr<CrashUploadList> crash_list_; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 DCHECK(ok); | 156 DCHECK(ok); |
| 151 | 157 |
| 152 Value* argCopy = arg->DeepCopy(); | 158 Value* argCopy = arg->DeepCopy(); |
| 153 submessageArgs->Append(argCopy); | 159 submessageArgs->Append(argCopy); |
| 154 } | 160 } |
| 155 | 161 |
| 156 // call the submessage handler | 162 // call the submessage handler |
| 157 Value* ret = NULL; | 163 Value* ret = NULL; |
| 158 if (submessage == "requestClientInfo") { | 164 if (submessage == "requestClientInfo") { |
| 159 ret = OnRequestClientInfo(submessageArgs); | 165 ret = OnRequestClientInfo(submessageArgs); |
| 166 } else if (submessage == "requestSandboxInfo") { |
| 167 ret = OnRequestSandboxInfo(submessageArgs); |
| 160 } else if (submessage == "requestLogMessages") { | 168 } else if (submessage == "requestLogMessages") { |
| 161 ret = OnRequestLogMessages(submessageArgs); | 169 ret = OnRequestLogMessages(submessageArgs); |
| 162 } else if (submessage == "requestCrashList") { | 170 } else if (submessage == "requestCrashList") { |
| 163 ret = OnRequestCrashList(submessageArgs); | 171 ret = OnRequestCrashList(submessageArgs); |
| 164 } else { // unrecognized submessage | 172 } else { // unrecognized submessage |
| 165 NOTREACHED(); | 173 NOTREACHED(); |
| 166 delete submessageArgs; | 174 delete submessageArgs; |
| 167 return; | 175 return; |
| 168 } | 176 } |
| 169 delete submessageArgs; | 177 delete submessageArgs; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 dict->SetString("graphics_backend", "Skia"); | 238 dict->SetString("graphics_backend", "Skia"); |
| 231 #else | 239 #else |
| 232 dict->SetString("graphics_backend", "Core Graphics"); | 240 dict->SetString("graphics_backend", "Core Graphics"); |
| 233 #endif | 241 #endif |
| 234 dict->SetString("blacklist_version", | 242 dict->SetString("blacklist_version", |
| 235 GpuBlacklist::GetInstance()->GetVersion()); | 243 GpuBlacklist::GetInstance()->GetVersion()); |
| 236 | 244 |
| 237 return dict; | 245 return dict; |
| 238 } | 246 } |
| 239 | 247 |
| 248 Value* GpuMessageHandler::OnRequestSandboxInfo(const ListValue*) { |
| 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 250 |
| 251 DictionaryValue* dict = new DictionaryValue(); |
| 252 |
| 253 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 254 const int status = content::ZygoteHost::GetInstance()->GetSandboxStatus(); |
| 255 dict->SetBoolean("suid_sanbox", status & content::kSandboxLinuxSUID); |
| 256 dict->SetBoolean("pid_namespaces", status & content::kSandboxLinuxPIDNS); |
| 257 dict->SetBoolean("net_namespaces", status & content::kSandboxLinuxNetNS); |
| 258 dict->SetBoolean("seccomp_legacy", |
| 259 status & content::kSandboxLinuxSeccompLegacy); |
| 260 dict->SetBoolean("seccomp_bpf", status & content::kSandboxLinuxSeccompBpf); |
| 261 bool good = ((status & content::kSandboxLinuxSUID) && |
| 262 (status & content::kSandboxLinuxPIDNS)) || |
| 263 (status & content::kSandboxLinuxSeccompLegacy); |
| 264 dict->SetBoolean("sandbox_ok", good); |
| 265 #else |
| 266 dict->SetBoolean("suid_sanbox", false); |
| 267 dict->SetBoolean("pid_namespaces", false); |
| 268 dict->SetBoolean("net_namespaces", false); |
| 269 dict->SetBoolean("seccomp_legacy", false); |
| 270 dict->SetBoolean("seccomp_bpf", false); |
| 271 dict->SetBoolean("sandbox_ok", true); |
| 272 #endif |
| 273 |
| 274 return dict; |
| 275 } |
| 276 |
| 240 Value* GpuMessageHandler::OnRequestLogMessages(const ListValue*) { | 277 Value* GpuMessageHandler::OnRequestLogMessages(const ListValue*) { |
| 241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 242 | 279 |
| 243 return GpuDataManager::GetInstance()->GetLogMessages().DeepCopy(); | 280 return GpuDataManager::GetInstance()->GetLogMessages().DeepCopy(); |
| 244 } | 281 } |
| 245 | 282 |
| 246 Value* GpuMessageHandler::OnRequestCrashList(const ListValue*) { | 283 Value* GpuMessageHandler::OnRequestCrashList(const ListValue*) { |
| 247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 284 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 248 | 285 |
| 249 if (!CrashesUI::CrashReportingEnabled()) { | 286 if (!CrashesUI::CrashReportingEnabled()) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 //////////////////////////////////////////////////////////////////////////////// | 336 //////////////////////////////////////////////////////////////////////////////// |
| 300 | 337 |
| 301 GpuInternalsUI::GpuInternalsUI(content::WebUI* web_ui) | 338 GpuInternalsUI::GpuInternalsUI(content::WebUI* web_ui) |
| 302 : WebUIController(web_ui) { | 339 : WebUIController(web_ui) { |
| 303 web_ui->AddMessageHandler(new GpuMessageHandler()); | 340 web_ui->AddMessageHandler(new GpuMessageHandler()); |
| 304 | 341 |
| 305 // Set up the chrome://gpu-internals/ source. | 342 // Set up the chrome://gpu-internals/ source. |
| 306 Profile* profile = Profile::FromWebUI(web_ui); | 343 Profile* profile = Profile::FromWebUI(web_ui); |
| 307 ChromeURLDataManager::AddDataSource(profile, CreateGpuHTMLSource()); | 344 ChromeURLDataManager::AddDataSource(profile, CreateGpuHTMLSource()); |
| 308 } | 345 } |
| OLD | NEW |