| 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/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" |
| 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback_old.h" |
| 9 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 10 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 11 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 12 #include "base/values.h" | 15 #include "base/values.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 15 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
| 16 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 17 #include "content/browser/browser_thread.h" | 20 #include "content/browser/browser_thread.h" |
| 18 #include "content/browser/gpu/gpu_data_manager.h" | 21 #include "content/browser/gpu/gpu_data_manager.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 WebUIMessageHandler* GpuMessageHandler::Attach(WebUI* web_ui) { | 98 WebUIMessageHandler* GpuMessageHandler::Attach(WebUI* web_ui) { |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 97 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); | 100 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); |
| 98 return result; | 101 return result; |
| 99 } | 102 } |
| 100 | 103 |
| 101 /* BrowserBridge.callAsync prepends a requestID to these messages. */ | 104 /* BrowserBridge.callAsync prepends a requestID to these messages. */ |
| 102 void GpuMessageHandler::RegisterMessages() { | 105 void GpuMessageHandler::RegisterMessages() { |
| 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 104 | 107 |
| 105 web_ui_->RegisterMessageCallback( | 108 web_ui_->RegisterMessageCallback("browserBridgeInitialized", |
| 106 "browserBridgeInitialized", | 109 base::Bind(&GpuMessageHandler::OnBrowserBridgeInitialized, |
| 107 NewCallback(this, &GpuMessageHandler::OnBrowserBridgeInitialized)); | 110 base::Unretained(this))); |
| 108 web_ui_->RegisterMessageCallback( | 111 web_ui_->RegisterMessageCallback("callAsync", |
| 109 "callAsync", | 112 base::Bind(&GpuMessageHandler::OnCallAsync, |
| 110 NewCallback(this, &GpuMessageHandler::OnCallAsync)); | 113 base::Unretained(this))); |
| 111 } | 114 } |
| 112 | 115 |
| 113 void GpuMessageHandler::OnCallAsync(const ListValue* args) { | 116 void GpuMessageHandler::OnCallAsync(const ListValue* args) { |
| 114 DCHECK_GE(args->GetSize(), static_cast<size_t>(2)); | 117 DCHECK_GE(args->GetSize(), static_cast<size_t>(2)); |
| 115 // unpack args into requestId, submessage and submessageArgs | 118 // unpack args into requestId, submessage and submessageArgs |
| 116 bool ok; | 119 bool ok; |
| 117 Value* requestId; | 120 Value* requestId; |
| 118 ok = args->Get(0, &requestId); | 121 ok = args->Get(0, &requestId); |
| 119 DCHECK(ok); | 122 DCHECK(ok); |
| 120 | 123 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // | 240 // |
| 238 //////////////////////////////////////////////////////////////////////////////// | 241 //////////////////////////////////////////////////////////////////////////////// |
| 239 | 242 |
| 240 GpuInternalsUI::GpuInternalsUI(TabContents* contents) : ChromeWebUI(contents) { | 243 GpuInternalsUI::GpuInternalsUI(TabContents* contents) : ChromeWebUI(contents) { |
| 241 AddMessageHandler((new GpuMessageHandler())->Attach(this)); | 244 AddMessageHandler((new GpuMessageHandler())->Attach(this)); |
| 242 | 245 |
| 243 // Set up the chrome://gpu-internals/ source. | 246 // Set up the chrome://gpu-internals/ source. |
| 244 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 247 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
| 245 profile->GetChromeURLDataManager()->AddDataSource(CreateGpuHTMLSource()); | 248 profile->GetChromeURLDataManager()->AddDataSource(CreateGpuHTMLSource()); |
| 246 } | 249 } |
| OLD | NEW |