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/media/media_internals_handler.h" | 5 #include "chrome/browser/ui/webui/media/media_internals_handler.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/ui/webui/media/media_internals_proxy.h" | 9 #include "chrome/browser/ui/webui/media/media_internals_proxy.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" |
12 | 13 |
13 MediaInternalsMessageHandler::MediaInternalsMessageHandler() | 14 MediaInternalsMessageHandler::MediaInternalsMessageHandler() |
14 : proxy_(new MediaInternalsProxy()) {} | 15 : proxy_(new MediaInternalsProxy()) {} |
15 | 16 |
16 MediaInternalsMessageHandler::~MediaInternalsMessageHandler() { | 17 MediaInternalsMessageHandler::~MediaInternalsMessageHandler() { |
17 proxy_->Detach(); | 18 proxy_->Detach(); |
18 } | 19 } |
19 | 20 |
20 WebUIMessageHandler* MediaInternalsMessageHandler::Attach(WebUI* web_ui) { | 21 WebUIMessageHandler* MediaInternalsMessageHandler::Attach(WebUI* web_ui) { |
21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
22 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); | 23 WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui); |
23 proxy_->Attach(this); | 24 proxy_->Attach(this); |
24 return result; | 25 return result; |
25 } | 26 } |
26 | 27 |
27 void MediaInternalsMessageHandler::RegisterMessages() { | 28 void MediaInternalsMessageHandler::RegisterMessages() { |
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
29 | 30 |
30 web_ui_->RegisterMessageCallback( | 31 web_ui_->RegisterMessageCallback( |
31 "getEverything", | 32 "getEverything", |
32 NewCallback(this, &MediaInternalsMessageHandler::OnGetEverything)); | 33 NewCallback(this, &MediaInternalsMessageHandler::OnGetEverything)); |
33 } | 34 } |
34 | 35 |
35 void MediaInternalsMessageHandler::OnGetEverything(const ListValue* list) { | 36 void MediaInternalsMessageHandler::OnGetEverything(const ListValue* list) { |
36 proxy_->GetEverything(); | 37 proxy_->GetEverything(); |
37 } | 38 } |
38 | 39 |
39 void MediaInternalsMessageHandler::OnUpdate(const string16& update) { | 40 void MediaInternalsMessageHandler::OnUpdate(const string16& update) { |
40 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), update); | 41 web_ui_->tab_contents()->render_view_host()-> |
| 42 ExecuteJavascriptInWebFrame(string16(), update); |
41 } | 43 } |
OLD | NEW |