| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 DCHECK(selected_index >= 0); | 99 DCHECK(selected_index >= 0); |
| 100 DCHECK(selected_index < static_cast<int>(session_tab.navigations.size())); | 100 DCHECK(selected_index < static_cast<int>(session_tab.navigations.size())); |
| 101 | 101 |
| 102 const ::sessions::SerializedNavigationEntry& current_navigation = | 102 const ::sessions::SerializedNavigationEntry& current_navigation = |
| 103 session_tab.navigations.at(selected_index); | 103 session_tab.navigations.at(selected_index); |
| 104 | 104 |
| 105 GURL tab_url = current_navigation.virtual_url(); | 105 GURL tab_url = current_navigation.virtual_url(); |
| 106 | 106 |
| 107 Java_ForeignSessionHelper_pushTab( | 107 Java_ForeignSessionHelper_pushTab( |
| 108 env, j_window.obj(), | 108 env, j_window.obj(), |
| 109 ConvertUTF8ToJavaString(env, tab_url.spec()).Release(), | 109 ConvertUTF8ToJavaString(env, tab_url.spec()).obj(), |
| 110 ConvertUTF16ToJavaString(env, current_navigation.title()).Release(), | 110 ConvertUTF16ToJavaString(env, current_navigation.title()).obj(), |
| 111 session_tab.timestamp.ToJavaTime(), | 111 session_tab.timestamp.ToJavaTime(), |
| 112 session_tab.tab_id.id()); | 112 session_tab.tab_id.id()); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 void CopyWindowsToJava( | 116 void CopyWindowsToJava( |
| 117 JNIEnv* env, | 117 JNIEnv* env, |
| 118 const SyncedSession& session, | 118 const SyncedSession& session, |
| 119 ScopedJavaLocalRef<jobject>& j_session) { | 119 ScopedJavaLocalRef<jobject>& j_session) { |
| 120 for (SyncedSession::SyncedWindowMap::const_iterator it = | 120 for (SyncedSession::SyncedWindowMap::const_iterator it = |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 const bool is_collapsed = collapsed_sessions->HasKey(session.session_tag); | 230 const bool is_collapsed = collapsed_sessions->HasKey(session.session_tag); |
| 231 | 231 |
| 232 if (is_collapsed) | 232 if (is_collapsed) |
| 233 pref_collapsed_sessions->SetBoolean(session.session_tag, true); | 233 pref_collapsed_sessions->SetBoolean(session.session_tag, true); |
| 234 | 234 |
| 235 last_pushed_session.Reset( | 235 last_pushed_session.Reset( |
| 236 Java_ForeignSessionHelper_pushSession( | 236 Java_ForeignSessionHelper_pushSession( |
| 237 env, | 237 env, |
| 238 result, | 238 result, |
| 239 ConvertUTF8ToJavaString(env, session.session_tag).Release(), | 239 ConvertUTF8ToJavaString(env, session.session_tag).obj(), |
| 240 ConvertUTF8ToJavaString(env, session.session_name).Release(), | 240 ConvertUTF8ToJavaString(env, session.session_name).obj(), |
| 241 session.device_type, | 241 session.device_type, |
| 242 session.modified_time.ToJavaTime())); | 242 session.modified_time.ToJavaTime())); |
| 243 | 243 |
| 244 CopyWindowsToJava(env, session, last_pushed_session); | 244 CopyWindowsToJava(env, session, last_pushed_session); |
| 245 } | 245 } |
| 246 | 246 |
| 247 return true; | 247 return true; |
| 248 } | 248 } |
| 249 | 249 |
| 250 jboolean ForeignSessionHelper::OpenForeignSessionTab(JNIEnv* env, | 250 jboolean ForeignSessionHelper::OpenForeignSessionTab(JNIEnv* env, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 jstring session_tag) { | 293 jstring session_tag) { |
| 294 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); | 294 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); |
| 295 if (open_tabs) | 295 if (open_tabs) |
| 296 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); | 296 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); |
| 297 } | 297 } |
| 298 | 298 |
| 299 // static | 299 // static |
| 300 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { | 300 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { |
| 301 return RegisterNativesImpl(env); | 301 return RegisterNativesImpl(env); |
| 302 } | 302 } |
| OLD | NEW |