Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/values.h" | |
| 10 #include "chrome/common/chrome_notification_types.h" | |
| 11 #include "content/public/browser/notification_service.h" | |
| 12 #include "content/public/browser/web_contents.h" | |
| 13 #include "content/public/browser/web_ui.h" | |
| 14 | |
| 15 NewTabPageReadyHandler::NewTabPageReadyHandler() { | |
| 16 } | |
| 17 | |
| 18 NewTabPageReadyHandler::~NewTabPageReadyHandler() { | |
| 19 } | |
| 20 | |
| 21 void NewTabPageReadyHandler::RegisterMessages() { | |
| 22 web_ui()->RegisterMessageCallback("notifyNTPReady", base::Bind( | |
| 23 &NewTabPageReadyHandler::HandleNewTabPageReady, base::Unretained(this))); | |
| 24 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
| |
| 25 &NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation, | |
| 26 base::Unretained(this))); | |
| 27 } | |
| 28 | |
| 29 void NewTabPageReadyHandler::HandleNewTabPageReady( | |
| 30 const ListValue* args) { | |
| 31 content::NotificationService::current()->Notify( | |
| 32 chrome::NOTIFICATION_NEW_TAB_READY, | |
| 33 content::Source<content::WebContents>(web_ui()->GetWebContents()), | |
| 34 content::NotificationService::NoDetails()); | |
| 35 } | |
| 36 | |
| 37 void NewTabPageReadyHandler::HandleNewTabPageUnexpectedNavigation( | |
| 38 const ListValue* args) { | |
| 39 // NTP reached an unexpected state trying to send finish loading notification | |
| 40 // a second time. The notification should be sent only when page is | |
| 41 // completely done loading. This could otherwise create a race condition in | |
| 42 // tests waiting for the NTP to have loaded (any navigation NTP does after | |
| 43 // loading could interfere with the test navigation). | |
| 44 NOTREACHED(); | |
| 45 } | |
| OLD | NEW |