| 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 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 for (const auto& tab_ptr : window.tabs) { | 68 for (const auto& tab_ptr : window.tabs) { |
| 69 const sessions::SessionTab& session_tab = *(tab_ptr.get()); | 69 const sessions::SessionTab& session_tab = *(tab_ptr.get()); |
| 70 if (!ShouldSkipTab(session_tab)) | 70 if (!ShouldSkipTab(session_tab)) |
| 71 return false; | 71 return false; |
| 72 } | 72 } |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool ShouldSkipSession(const SyncedSession& session) { | 76 bool ShouldSkipSession(const SyncedSession& session) { |
| 77 for (const auto& window_pair : session.windows) { | 77 for (const auto& window_pair : session.windows) { |
| 78 const sessions::SessionWindow& window = *(window_pair.second.get()); | 78 const sessions::SessionWindow& window = window_pair.second->wrapped_window; |
| 79 if (!ShouldSkipWindow(window)) | 79 if (!ShouldSkipWindow(window)) |
| 80 return false; | 80 return false; |
| 81 } | 81 } |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CopyTabToJava( | 85 void CopyTabToJava( |
| 86 JNIEnv* env, | 86 JNIEnv* env, |
| 87 const sessions::SessionTab& tab, | 87 const sessions::SessionTab& tab, |
| 88 ScopedJavaLocalRef<jobject>& j_window) { | 88 ScopedJavaLocalRef<jobject>& j_window) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 113 | 113 |
| 114 CopyTabToJava(env, session_tab, j_window); | 114 CopyTabToJava(env, session_tab, j_window); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CopySessionToJava( | 118 void CopySessionToJava( |
| 119 JNIEnv* env, | 119 JNIEnv* env, |
| 120 const SyncedSession& session, | 120 const SyncedSession& session, |
| 121 ScopedJavaLocalRef<jobject>& j_session) { | 121 ScopedJavaLocalRef<jobject>& j_session) { |
| 122 for (const auto& window_pair : session.windows) { | 122 for (const auto& window_pair : session.windows) { |
| 123 const sessions::SessionWindow& window = *(window_pair.second.get()); | 123 const sessions::SessionWindow& window = window_pair.second->wrapped_window; |
| 124 | 124 |
| 125 if (ShouldSkipWindow(window)) | 125 if (ShouldSkipWindow(window)) |
| 126 continue; | 126 continue; |
| 127 | 127 |
| 128 ScopedJavaLocalRef<jobject> last_pushed_window; | 128 ScopedJavaLocalRef<jobject> last_pushed_window; |
| 129 last_pushed_window.Reset(Java_ForeignSessionHelper_pushWindow( | 129 last_pushed_window.Reset(Java_ForeignSessionHelper_pushWindow( |
| 130 env, j_session, window.timestamp.ToJavaTime(), window.window_id.id())); | 130 env, j_session, window.timestamp.ToJavaTime(), window.window_id.id())); |
| 131 | 131 |
| 132 CopyWindowToJava(env, window, last_pushed_window); | 132 CopyWindowToJava(env, window, last_pushed_window); |
| 133 } | 133 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 const JavaParamRef<jstring>& session_tag) { | 318 const JavaParamRef<jstring>& session_tag) { |
| 319 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); | 319 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); |
| 320 if (open_tabs) | 320 if (open_tabs) |
| 321 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); | 321 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); |
| 322 } | 322 } |
| 323 | 323 |
| 324 // static | 324 // static |
| 325 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { | 325 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { |
| 326 return RegisterNativesImpl(env); | 326 return RegisterNativesImpl(env); |
| 327 } | 327 } |
| OLD | NEW |