Chromium Code Reviews| Index: chrome/browser/android/foreign_session_helper.cc |
| diff --git a/chrome/browser/android/foreign_session_helper.cc b/chrome/browser/android/foreign_session_helper.cc |
| index 7d7f48684fe29e25978c518271bb5836399ea8e2..17b986716c5fdebd58cbae7e55586e8dd9becfd1 100644 |
| --- a/chrome/browser/android/foreign_session_helper.cc |
| +++ b/chrome/browser/android/foreign_session_helper.cc |
| @@ -7,9 +7,12 @@ |
| #include <jni.h> |
| #include "base/android/jni_string.h" |
| +#include "base/prefs/pref_service.h" |
| #include "base/prefs/scoped_user_pref_update.h" |
| +#include "chrome/browser/android/tab_android.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/profiles/profile_android.h" |
| +#include "chrome/browser/sessions/session_restore.h" |
| #include "chrome/browser/sync/glue/session_model_associator.h" |
| #include "chrome/browser/sync/profile_sync_service.h" |
| #include "chrome/browser/sync/profile_sync_service_factory.h" |
| @@ -244,10 +247,10 @@ jboolean ForeignSessionHelper::GetForeignSessions(JNIEnv* env, |
| return true; |
| } |
| -jboolean ForeignSessionHelper::OpenForeignSessionTab(JNIEnv* env, |
| - jobject obj, |
| - jstring session_tag, |
| - jint tab_id) { |
| +jboolean ForeignSessionHelper::OpenForeignSessionTabOld(JNIEnv* env, |
| + jobject obj, |
| + jstring session_tag, |
| + jint tab_id) { |
| SessionModelAssociator* associator = GetSessionModelAssociator(profile_); |
| if (!associator) { |
| LOG(ERROR) << "Null SessionModelAssociator returned."; |
| @@ -287,6 +290,47 @@ jboolean ForeignSessionHelper::OpenForeignSessionTab(JNIEnv* env, |
| return true; |
| } |
| +jboolean ForeignSessionHelper::OpenForeignSessionTab(JNIEnv* env, |
| + jobject obj, |
| + jobject j_tab, |
| + jstring session_tag, |
| + jint tab_id, |
| + jint j_disposition) { |
| + SessionModelAssociator* associator = GetSessionModelAssociator(profile_); |
| + if (!associator) { |
| + LOG(ERROR) << "Null SessionModelAssociator returned."; |
| + return false; |
| + } |
| + |
| + const SessionTab* tab; |
|
newt (away)
2013/11/02 02:04:42
call this session_tab or foreign_tab? It's confusi
apiccion
2013/11/02 02:48:27
Done. And changed the names throughout the file fo
|
| + |
| + if (!associator->GetForeignTab(ConvertJavaStringToUTF8(env, session_tag), |
| + tab_id, &tab)) { |
| + LOG(ERROR) << "Failed to load foreign tab."; |
| + return false; |
| + } |
| + |
| + if (tab->navigations.empty()) { |
| + LOG(ERROR) << "Foreign tab no longer has valid navigations."; |
| + return false; |
| + } |
| + |
| + TabAndroid* tab_android = TabAndroid::GetNativeTab(env, j_tab); |
| + if (!tab_android) |
| + return false; |
| + content::WebContents* web_contents = tab_android->web_contents(); |
| + if (!web_contents) |
| + return false; |
| + |
| + WindowOpenDisposition disposition = |
| + static_cast<WindowOpenDisposition>(j_disposition); |
| + SessionRestore::RestoreForeignSessionTab(web_contents, |
| + *tab, |
| + disposition); |
| + |
| + return true; |
| +} |
| + |
| void ForeignSessionHelper::SetForeignSessionCollapsed(JNIEnv* env, jobject obj, |
| jstring session_tag, |
| jboolean is_collapsed) { |