OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/media/media_internals_handler.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/bind_helpers.h" | |
9 #include "base/values.h" | |
10 #include "chrome/browser/browser_process.h" | |
11 #include "chrome/browser/ui/webui/media/media_internals_proxy.h" | |
12 #include "content/public/browser/browser_thread.h" | |
13 #include "content/public/browser/render_view_host.h" | |
14 #include "content/public/browser/web_contents.h" | |
15 #include "content/public/browser/web_ui.h" | |
16 | |
17 using content::BrowserThread; | |
18 | |
19 MediaInternalsMessageHandler::MediaInternalsMessageHandler() | |
20 : proxy_(new MediaInternalsProxy()) {} | |
21 | |
22 MediaInternalsMessageHandler::~MediaInternalsMessageHandler() { | |
23 proxy_->Detach(); | |
24 } | |
25 | |
26 void MediaInternalsMessageHandler::RegisterMessages() { | |
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
28 proxy_->Attach(this); | |
29 | |
30 web_ui()->RegisterMessageCallback("getEverything", | |
31 base::Bind(&MediaInternalsMessageHandler::OnGetEverything, | |
32 base::Unretained(this))); | |
33 } | |
34 | |
35 void MediaInternalsMessageHandler::OnGetEverything(const ListValue* list) { | |
36 proxy_->GetEverything(); | |
37 } | |
38 | |
39 void MediaInternalsMessageHandler::OnUpdate(const string16& update) { | |
40 // Don't try to execute JavaScript in a RenderView that no longer exists. | |
41 content::RenderViewHost* host = | |
42 web_ui()->GetWebContents()->GetRenderViewHost(); | |
43 if (host) | |
44 host->ExecuteJavascriptInWebFrame(string16(), update); | |
45 } | |
OLD | NEW |