Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.cc

Issue 11038014: [Android] Upstream remaining changes to NTP UI code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed indentation nit Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(
+ &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();
+}

Powered by Google App Engine
This is Rietveld 408576698