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 "content/browser/tracing/tracing_ui.h" | 5 #include "content/browser/tracing/tracing_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "content/browser/tracing/tracing_controller_impl.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/tracing_controller.h" | 21 #include "content/public/browser/tracing_controller.h" |
21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
22 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
23 #include "content/public/browser/web_ui_data_source.h" | 24 #include "content/public/browser/web_ui_data_source.h" |
24 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
25 #include "grit/tracing_resources.h" | 26 #include "grit/tracing_resources.h" |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 namespace { | 29 namespace { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // Set up the chrome://tracing/ source. | 237 // Set up the chrome://tracing/ source. |
237 BrowserContext* browser_context = | 238 BrowserContext* browser_context = |
238 web_ui->GetWebContents()->GetBrowserContext(); | 239 web_ui->GetWebContents()->GetBrowserContext(); |
239 | 240 |
240 WebUIDataSource* source = WebUIDataSource::Create(kChromeUITracingHost); | 241 WebUIDataSource* source = WebUIDataSource::Create(kChromeUITracingHost); |
241 source->SetJsonPath("strings.js"); | 242 source->SetJsonPath("strings.js"); |
242 source->SetDefaultResource(IDR_TRACING_HTML); | 243 source->SetDefaultResource(IDR_TRACING_HTML); |
243 source->AddResourcePath("tracing.js", IDR_TRACING_JS); | 244 source->AddResourcePath("tracing.js", IDR_TRACING_JS); |
244 source->SetRequestFilter(base::Bind(OnTracingRequest)); | 245 source->SetRequestFilter(base::Bind(OnTracingRequest)); |
245 WebUIDataSource::Add(browser_context, source); | 246 WebUIDataSource::Add(browser_context, source); |
| 247 TracingControllerImpl::GetInstance()->RegisterTracingUI(this); |
| 248 } |
| 249 |
| 250 TracingUI::~TracingUI() { |
| 251 TracingControllerImpl::GetInstance()->UnregisterTracingUI(this); |
| 252 } |
| 253 |
| 254 void TracingUI::OnMonitoringStateChanged(bool is_monitoring) { |
| 255 web_ui()->CallJavascriptFunction( |
| 256 "onMonitoringStateChanged", base::FundamentalValue(is_monitoring)); |
246 } | 257 } |
247 | 258 |
248 } // namespace content | 259 } // namespace content |
OLD | NEW |