This source file includes following definitions.
- page_load_complete_
- RegisterMessages
- OnGetEverything
- OnUpdate
#include "content/browser/media/media_internals_handler.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/values.h"
#include "content/browser/media/media_internals_proxy.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
namespace content {
MediaInternalsMessageHandler::MediaInternalsMessageHandler()
: proxy_(new MediaInternalsProxy()),
page_load_complete_(false) {}
MediaInternalsMessageHandler::~MediaInternalsMessageHandler() {
proxy_->Detach();
}
void MediaInternalsMessageHandler::RegisterMessages() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
proxy_->Attach(this);
web_ui()->RegisterMessageCallback("getEverything",
base::Bind(&MediaInternalsMessageHandler::OnGetEverything,
base::Unretained(this)));
}
void MediaInternalsMessageHandler::OnGetEverything(
const base::ListValue* list) {
page_load_complete_ = true;
proxy_->GetEverything();
}
void MediaInternalsMessageHandler::OnUpdate(const base::string16& update) {
RenderFrameHost* host = web_ui()->GetWebContents()->GetMainFrame();
if (host && page_load_complete_)
host->ExecuteJavaScript(update);
}
}