Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / media / media_internals_handler.cc
blobaafe26ea25963e045a03e7aa11529568bce1abf8
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.
5 #include "content/browser/media/media_internals_handler.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/values.h"
10 #include "content/browser/media/media_internals_proxy.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/browser/web_ui.h"
16 namespace content {
18 MediaInternalsMessageHandler::MediaInternalsMessageHandler()
19 : proxy_(new MediaInternalsProxy()),
20 page_load_complete_(false) {}
22 MediaInternalsMessageHandler::~MediaInternalsMessageHandler() {
23 proxy_->Detach();
26 void MediaInternalsMessageHandler::RegisterMessages() {
27 DCHECK_CURRENTLY_ON(BrowserThread::UI);
28 proxy_->Attach(this);
30 web_ui()->RegisterMessageCallback("getEverything",
31 base::Bind(&MediaInternalsMessageHandler::OnGetEverything,
32 base::Unretained(this)));
35 void MediaInternalsMessageHandler::OnGetEverything(
36 const base::ListValue* list) {
37 page_load_complete_ = true;
38 proxy_->GetEverything();
41 void MediaInternalsMessageHandler::OnUpdate(const base::string16& update) {
42 // Don't try to execute JavaScript in a RenderView that no longer exists nor
43 // if the chrome://media-internals page hasn't finished loading.
44 RenderFrameHost* host = web_ui()->GetWebContents()->GetMainFrame();
45 if (host && page_load_complete_)
46 host->ExecuteJavaScript(update);
49 } // namespace content