This source file includes following definitions.
- RegisterMessages
- HandleNewTabPageTitleLoaded
- HandleNewTabPageReady
- HandleNewTabPageUnexpectedNavigation
#include "chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/android/tab_android.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
NewTabPageReadyHandler::NewTabPageReadyHandler() {
}
NewTabPageReadyHandler::~NewTabPageReadyHandler() {
}
void NewTabPageReadyHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("notifyNTPReady", base::Bind(
&NewTabPageReadyHandler::HandleNewTabPageReady, base::Unretained(this)));
web_ui()->RegisterMessageCallback("NTPUnexpectedNavigation", base::Bind(
&NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation,
base::Unretained(this)));
web_ui()->RegisterMessageCallback("notifyNTPTitleLoaded", base::Bind(
&NewTabPageReadyHandler::HandleNewTabPageTitleLoaded,
base::Unretained(this)));
}
void NewTabPageReadyHandler::HandleNewTabPageTitleLoaded(
const base::ListValue* args) {
web_ui()->OverrideTitle(base::string16());
}
void NewTabPageReadyHandler::HandleNewTabPageReady(
const base::ListValue* args) {
TabAndroid* tab = TabAndroid::FromWebContents(web_ui()->GetWebContents());
if (!tab)
return;
tab->OnNewTabPageReady();
}
void NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation(
const base::ListValue* args) {
NOTREACHED();
}