OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/android/foreign_session_helper.h" | 5 #include "chrome/browser/android/foreign_session_helper.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 using browser_sync::OpenTabsUIDelegate; | 35 using browser_sync::OpenTabsUIDelegate; |
36 using browser_sync::SyncedSession; | 36 using browser_sync::SyncedSession; |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 OpenTabsUIDelegate* GetOpenTabsUIDelegate(Profile* profile) { | 40 OpenTabsUIDelegate* GetOpenTabsUIDelegate(Profile* profile) { |
41 ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()-> | 41 ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()-> |
42 GetForProfile(profile); | 42 GetForProfile(profile); |
43 | 43 |
44 // Only return the delegate if it exists and it is done syncing sessions. | 44 // Only return the delegate if it exists and it is done syncing sessions. |
45 if (!service || !service->SyncActive()) | 45 if (!service || !service->IsSyncActive()) |
46 return NULL; | 46 return NULL; |
47 | 47 |
48 return service->GetOpenTabsUIDelegate(); | 48 return service->GetOpenTabsUIDelegate(); |
49 } | 49 } |
50 | 50 |
51 bool ShouldSkipTab(const sessions::SessionTab& session_tab) { | 51 bool ShouldSkipTab(const sessions::SessionTab& session_tab) { |
52 if (session_tab.navigations.empty()) | 52 if (session_tab.navigations.empty()) |
53 return true; | 53 return true; |
54 | 54 |
55 int selected_index = session_tab.normalized_navigation_index(); | 55 int selected_index = session_tab.normalized_navigation_index(); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 jstring session_tag) { | 299 jstring session_tag) { |
300 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); | 300 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); |
301 if (open_tabs) | 301 if (open_tabs) |
302 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); | 302 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); |
303 } | 303 } |
304 | 304 |
305 // static | 305 // static |
306 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { | 306 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { |
307 return RegisterNativesImpl(env); | 307 return RegisterNativesImpl(env); |
308 } | 308 } |
OLD | NEW |