Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1401)

Side by Side Diff: chrome/browser/android/foreign_session_helper.cc

Issue 510043002: Fix foreign tabs with > 6 navigations not showing up on Android, take 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 if (!service || !service->ShouldPushChanges()) 43 if (!service || !service->ShouldPushChanges())
44 return NULL; 44 return NULL;
45 45
46 return service->GetOpenTabsUIDelegate(); 46 return service->GetOpenTabsUIDelegate();
47 } 47 }
48 48
49 bool ShouldSkipTab(const SessionTab& session_tab) { 49 bool ShouldSkipTab(const SessionTab& session_tab) {
50 if (session_tab.navigations.empty()) 50 if (session_tab.navigations.empty())
51 return true; 51 return true;
52 52
53 int selected_index = session_tab.current_navigation_index; 53 int selected_index = session_tab.normalized_navigation_index();
54 if (selected_index < 0 ||
55 selected_index >= static_cast<int>(session_tab.navigations.size()))
56 return true;
57
58 const ::sessions::SerializedNavigationEntry& current_navigation = 54 const ::sessions::SerializedNavigationEntry& current_navigation =
59 session_tab.navigations.at(selected_index); 55 session_tab.navigations.at(selected_index);
60 56
61 if (current_navigation.virtual_url().is_empty()) 57 if (current_navigation.virtual_url().is_empty())
62 return true; 58 return true;
63 59
64 return false; 60 return false;
65 } 61 }
66 62
67 bool ShouldSkipWindow(const SessionWindow& window) { 63 bool ShouldSkipWindow(const SessionWindow& window) {
(...skipping 20 matching lines...) Expand all
88 JNIEnv* env, 84 JNIEnv* env,
89 const SessionWindow& window, 85 const SessionWindow& window,
90 ScopedJavaLocalRef<jobject>& j_window) { 86 ScopedJavaLocalRef<jobject>& j_window) {
91 for (std::vector<SessionTab*>::const_iterator tab_it = window.tabs.begin(); 87 for (std::vector<SessionTab*>::const_iterator tab_it = window.tabs.begin();
92 tab_it != window.tabs.end(); ++tab_it) { 88 tab_it != window.tabs.end(); ++tab_it) {
93 const SessionTab &session_tab = **tab_it; 89 const SessionTab &session_tab = **tab_it;
94 90
95 if (ShouldSkipTab(session_tab)) 91 if (ShouldSkipTab(session_tab))
96 continue; 92 continue;
97 93
98 int selected_index = session_tab.current_navigation_index; 94 int selected_index = session_tab.normalized_navigation_index();
99 DCHECK(selected_index >= 0); 95 DCHECK(selected_index >= 0);
100 DCHECK(selected_index < static_cast<int>(session_tab.navigations.size())); 96 DCHECK(selected_index < static_cast<int>(session_tab.navigations.size()));
101 97
102 const ::sessions::SerializedNavigationEntry& current_navigation = 98 const ::sessions::SerializedNavigationEntry& current_navigation =
103 session_tab.navigations.at(selected_index); 99 session_tab.navigations.at(selected_index);
104 100
105 GURL tab_url = current_navigation.virtual_url(); 101 GURL tab_url = current_navigation.virtual_url();
106 102
107 Java_ForeignSessionHelper_pushTab( 103 Java_ForeignSessionHelper_pushTab(
108 env, j_window.obj(), 104 env, j_window.obj(),
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 jstring session_tag) { 289 jstring session_tag) {
294 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_); 290 OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(profile_);
295 if (open_tabs) 291 if (open_tabs)
296 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag)); 292 open_tabs->DeleteForeignSession(ConvertJavaStringToUTF8(env, session_tag));
297 } 293 }
298 294
299 // static 295 // static
300 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) { 296 bool ForeignSessionHelper::RegisterForeignSessionHelper(JNIEnv* env) {
301 return RegisterNativesImpl(env); 297 return RegisterNativesImpl(env);
302 } 298 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698