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

Unified Diff: chrome/browser/ui/webui/ntp/foreign_session_handler.cc

Issue 9838064: Add a sign-in promo message to the Other Devices menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only show promo when user is signed in but has no tab sync data. Created 8 years, 9 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/foreign_session_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc
index 4a6bbaed1601a893c36c1a9f65c796fe3fc52ed2..2c6b4accdc3eef43bfd053413f0f2a5b203f61b0 100644
--- a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc
+++ b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/url_constants.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_ui.h"
@@ -94,38 +95,30 @@ void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) {
SessionModelAssociator* associator = GetModelAssociator();
std::vector<const SyncedSession*> sessions;
- if (associator == NULL) {
- // Called before associator created, exit.
- return;
- }
-
- // Note: we don't own the SyncedSessions themselves.
- if (!associator->GetAllForeignSessions(&sessions)) {
- LOG(ERROR) << "ForeignSessionHandler failed to get session data from"
- "SessionModelAssociator.";
- return;
- }
- int added_count = 0;
ListValue session_list;
- for (std::vector<const SyncedSession*>::const_iterator i =
- sessions.begin(); i != sessions.end() &&
- added_count < kMaxSessionsToShow; ++i) {
- const SyncedSession* session = *i;
- scoped_ptr<DictionaryValue> session_data(new DictionaryValue());
- session_data->SetString("tag", session->session_tag);
- session_data->SetString("name", session->session_name);
- scoped_ptr<ListValue> window_list(new ListValue());
- for (SyncedSession::SyncedWindowMap::const_iterator it =
- session->windows.begin(); it != session->windows.end(); ++it) {
- SessionWindow* window = it->second;
- scoped_ptr<DictionaryValue> window_data(new DictionaryValue());
- if (SessionWindowToValue(*window, window_data.get())) {
- window_list->Append(window_data.release());
+ if (associator && associator->GetAllForeignSessions(&sessions)) {
+ // Note: we don't own the SyncedSessions themselves.
+ int added_count = 0;
+ for (std::vector<const SyncedSession*>::const_iterator i =
Dan Beam 2012/03/26 20:42:39 change from iterator to index
Patrick Dubroy 2012/03/26 21:41:47 Done.
+ sessions.begin(); i != sessions.end() &&
+ added_count < kMaxSessionsToShow; ++i) {
+ const SyncedSession* session = *i;
+ scoped_ptr<DictionaryValue> session_data(new DictionaryValue());
+ session_data->SetString("tag", session->session_tag);
+ session_data->SetString("name", session->session_name);
+ scoped_ptr<ListValue> window_list(new ListValue());
+ for (SyncedSession::SyncedWindowMap::const_iterator it =
+ session->windows.begin(); it != session->windows.end(); ++it) {
+ SessionWindow* window = it->second;
+ scoped_ptr<DictionaryValue> window_data(new DictionaryValue());
+ if (SessionWindowToValue(*window, window_data.get())) {
Dan Beam 2012/03/26 20:57:38 nit: no curlies
Patrick Dubroy 2012/03/26 21:41:47 Done.
+ window_list->Append(window_data.release());
+ }
}
+ session_data->Set("windows", window_list.release());
+ session_list.Append(session_data.release());
+ added_count++;
}
- session_data->Set("windows", window_list.release());
- session_list.Append(session_data.release());
- added_count++;
}
web_ui()->CallJavascriptFunction("ntp.foreignSessions", session_list);
}

Powered by Google App Engine
This is Rietveld 408576698