| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 std::vector<const browser_sync::SyncedSession*> sessions; | 207 std::vector<const browser_sync::SyncedSession*> sessions; |
| 208 if (!open_tabs->GetAllForeignSessions(&sessions)) | 208 if (!open_tabs->GetAllForeignSessions(&sessions)) |
| 209 return false; | 209 return false; |
| 210 | 210 |
| 211 // Use a pref to keep track of sessions that were collapsed by the user. | 211 // Use a pref to keep track of sessions that were collapsed by the user. |
| 212 // To prevent the pref from accumulating stale sessions, clear it each time | 212 // To prevent the pref from accumulating stale sessions, clear it each time |
| 213 // and only add back sessions that are still current. | 213 // and only add back sessions that are still current. |
| 214 DictionaryPrefUpdate pref_update(profile_->GetPrefs(), | 214 DictionaryPrefUpdate pref_update(profile_->GetPrefs(), |
| 215 prefs::kNtpCollapsedForeignSessions); | 215 prefs::kNtpCollapsedForeignSessions); |
| 216 DictionaryValue* pref_collapsed_sessions = pref_update.Get(); | 216 base::DictionaryValue* pref_collapsed_sessions = pref_update.Get(); |
| 217 scoped_ptr<DictionaryValue> collapsed_sessions( | 217 scoped_ptr<base::DictionaryValue> collapsed_sessions( |
| 218 pref_collapsed_sessions->DeepCopy()); | 218 pref_collapsed_sessions->DeepCopy()); |
| 219 pref_collapsed_sessions->Clear(); | 219 pref_collapsed_sessions->Clear(); |
| 220 | 220 |
| 221 ScopedJavaLocalRef<jobject> last_pushed_session; | 221 ScopedJavaLocalRef<jobject> last_pushed_session; |
| 222 ScopedJavaLocalRef<jobject> last_pushed_window; | 222 ScopedJavaLocalRef<jobject> last_pushed_window; |
| 223 | 223 |
| 224 // Note: we don't own the SyncedSessions themselves. | 224 // Note: we don't own the SyncedSessions themselves. |
| 225 for (size_t i = 0; i < sessions.size(); ++i) { | 225 for (size_t i = 0; i < sessions.size(); ++i) { |
| 226 const browser_sync::SyncedSession &session = *(sessions[i]); | 226 const browser_sync::SyncedSession &session = *(sessions[i]); |
| 227 if (ShouldSkipSession(session)) | 227 if (ShouldSkipSession(session)) |
| (...skipping 65 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 |