Chromium Code Reviews| Index: chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.cc |
| diff --git a/chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.cc b/chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..82fe3a59bf7b011e7067996c42990745d3662920 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.cc |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#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/common/chrome_notification_types.h" |
| +#include "content/public/browser/notification_service.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( |
|
Evan Stade
2012/10/02 14:42:43
why does this exist? just to make tests fail? You
newt (away)
2012/10/05 13:31:05
Yes, it's for tests. Many of our tests start by l
Evan Stade
2012/10/05 15:16:13
sure
newt (away)
2012/10/05 15:38:33
filed http://crbug.com/154307
|
| + &NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation, |
| + base::Unretained(this))); |
| +} |
| + |
| +void NewTabPageReadyHandler::HandleNewTabPageReady( |
| + const ListValue* args) { |
| + content::NotificationService::current()->Notify( |
| + chrome::NOTIFICATION_NEW_TAB_READY, |
| + content::Source<content::WebContents>(web_ui()->GetWebContents()), |
| + content::NotificationService::NoDetails()); |
| +} |
| + |
| +void NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation( |
| + const ListValue* args) { |
| + // NTP reached an unexpected state trying to send finish loading notification |
| + // a second time. The notification should be sent only when page is |
| + // completely done loading. This could otherwise create a race condition in |
| + // tests waiting for the NTP to have loaded (any navigation NTP does after |
| + // loading could interfere with the test navigation). |
| + NOTREACHED(); |
| +} |