OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/ntp/android/promo_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/android/promo_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/android/intent_helper.h" | 14 #include "chrome/browser/android/intent_helper.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/signin/signin_manager.h" | 18 #include "chrome/browser/signin/signin_manager.h" |
19 #include "chrome/browser/sync/glue/session_model_associator.h" | |
20 #include "chrome/browser/sync/glue/synced_session.h" | 19 #include "chrome/browser/sync/glue/synced_session.h" |
| 20 #include "chrome/browser/sync/open_tabs_ui_delegate.h" |
21 #include "chrome/browser/sync/profile_sync_service.h" | 21 #include "chrome/browser/sync/profile_sync_service.h" |
22 #include "chrome/browser/sync/profile_sync_service_factory.h" | 22 #include "chrome/browser/sync/profile_sync_service_factory.h" |
23 #include "chrome/browser/web_resource/notification_promo.h" | 23 #include "chrome/browser/web_resource/notification_promo.h" |
24 #include "chrome/browser/web_resource/notification_promo_mobile_ntp.h" | 24 #include "chrome/browser/web_resource/notification_promo_mobile_ntp.h" |
25 #include "chrome/browser/web_resource/promo_resource_service.h" | 25 #include "chrome/browser/web_resource/promo_resource_service.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "components/user_prefs/pref_registry_syncable.h" | 27 #include "components/user_prefs/pref_registry_syncable.h" |
28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 if (!prefs || prefs->GetBoolean(prefs::kNtpPromoDesktopSessionFound)) | 305 if (!prefs || prefs->GetBoolean(prefs::kNtpPromoDesktopSessionFound)) |
306 return; | 306 return; |
307 | 307 |
308 // Check if the sync is currently active. | 308 // Check if the sync is currently active. |
309 ProfileSyncService* service = | 309 ProfileSyncService* service = |
310 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 310 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
311 if (!service || !service->ShouldPushChanges()) | 311 if (!service || !service->ShouldPushChanges()) |
312 return; | 312 return; |
313 | 313 |
314 // Check if the sync has any open sessions. | 314 // Check if the sync has any open sessions. |
315 browser_sync::SessionModelAssociator* associator = | 315 browser_sync::OpenTabsUIDelegate* open_tabs = |
316 service->GetSessionModelAssociator(); | 316 service->GetOpenTabsUIDelegate(); |
317 if (!associator) | 317 if (!open_tabs) |
318 return; | 318 return; |
319 | 319 |
320 // Let's see if there are no desktop sessions. | 320 // Let's see if there are no desktop sessions. |
321 std::vector<const browser_sync::SyncedSession*> sessions; | 321 std::vector<const browser_sync::SyncedSession*> sessions; |
322 ListValue session_list; | 322 ListValue session_list; |
323 if (!associator->GetAllForeignSessions(&sessions)) | 323 if (!open_tabs->GetAllForeignSessions(&sessions)) |
324 return; | 324 return; |
325 | 325 |
326 for (size_t i = 0; i < sessions.size(); ++i) { | 326 for (size_t i = 0; i < sessions.size(); ++i) { |
327 const browser_sync::SyncedSession::DeviceType device_type = | 327 const browser_sync::SyncedSession::DeviceType device_type = |
328 sessions[i]->device_type; | 328 sessions[i]->device_type; |
329 if (device_type == browser_sync::SyncedSession::TYPE_WIN || | 329 if (device_type == browser_sync::SyncedSession::TYPE_WIN || |
330 device_type == browser_sync::SyncedSession::TYPE_MACOSX || | 330 device_type == browser_sync::SyncedSession::TYPE_MACOSX || |
331 device_type == browser_sync::SyncedSession::TYPE_LINUX) { | 331 device_type == browser_sync::SyncedSession::TYPE_LINUX) { |
332 // Found a desktop session: write out the pref. | 332 // Found a desktop session: write out the pref. |
333 prefs->SetBoolean(prefs::kNtpPromoDesktopSessionFound, true); | 333 prefs->SetBoolean(prefs::kNtpPromoDesktopSessionFound, true); |
334 return; | 334 return; |
335 } | 335 } |
336 } | 336 } |
337 } | 337 } |
OLD | NEW |