Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / ntp / android / new_tab_page_ready_handler.cc
blob01fd6b8f8d0c73f958992bf4906253e584758bfd
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 "chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.h"
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/values.h"
10 #include "chrome/browser/android/tab_android.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_ui.h"
14 NewTabPageReadyHandler::NewTabPageReadyHandler() {
17 NewTabPageReadyHandler::~NewTabPageReadyHandler() {
20 void NewTabPageReadyHandler::RegisterMessages() {
21 web_ui()->RegisterMessageCallback("notifyNTPReady", base::Bind(
22 &NewTabPageReadyHandler::HandleNewTabPageReady, base::Unretained(this)));
23 web_ui()->RegisterMessageCallback("NTPUnexpectedNavigation", base::Bind(
24 &NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation,
25 base::Unretained(this)));
26 web_ui()->RegisterMessageCallback("notifyNTPTitleLoaded", base::Bind(
27 &NewTabPageReadyHandler::HandleNewTabPageTitleLoaded,
28 base::Unretained(this)));
31 void NewTabPageReadyHandler::HandleNewTabPageTitleLoaded(
32 const base::ListValue* args) {
33 web_ui()->OverrideTitle(base::string16());
36 void NewTabPageReadyHandler::HandleNewTabPageReady(
37 const base::ListValue* args) {
38 TabAndroid* tab = TabAndroid::FromWebContents(web_ui()->GetWebContents());
39 if (!tab)
40 return;
41 tab->OnNewTabPageReady();
44 void NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation(
45 const base::ListValue* args) {
46 // NTP reached an unexpected state trying to send finish loading notification
47 // a second time. The notification should be sent only when page is
48 // completely done loading. This could otherwise create a race condition in
49 // tests waiting for the NTP to have loaded (any navigation NTP does after
50 // loading could interfere with the test navigation).
51 NOTREACHED();