| 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/ntp/new_tab_page_prefs.h" | 5 #include "chrome/browser/android/ntp/new_tab_page_prefs.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 "chrome/browser/profiles/profile_android.h" | 10 #include "chrome/browser/profiles/profile_android.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 : profile_(profile) { | 29 : profile_(profile) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 void NewTabPagePrefs::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 32 void NewTabPagePrefs::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 33 delete this; | 33 delete this; |
| 34 } | 34 } |
| 35 | 35 |
| 36 NewTabPagePrefs::~NewTabPagePrefs() { | 36 NewTabPagePrefs::~NewTabPagePrefs() { |
| 37 } | 37 } |
| 38 | 38 |
| 39 jboolean NewTabPagePrefs::GetCurrentlyOpenTabsCollapsed( | |
| 40 JNIEnv* env, | |
| 41 const JavaParamRef<jobject>& obj) { | |
| 42 PrefService* prefs = profile_->GetPrefs(); | |
| 43 return prefs->GetBoolean(prefs::kNtpCollapsedCurrentlyOpenTabs); | |
| 44 } | |
| 45 | |
| 46 void NewTabPagePrefs::SetCurrentlyOpenTabsCollapsed( | |
| 47 JNIEnv* env, | |
| 48 const JavaParamRef<jobject>& obj, | |
| 49 jboolean is_collapsed) { | |
| 50 PrefService* prefs = profile_->GetPrefs(); | |
| 51 prefs->SetBoolean(prefs::kNtpCollapsedCurrentlyOpenTabs, is_collapsed); | |
| 52 } | |
| 53 | |
| 54 jboolean NewTabPagePrefs::GetSnapshotDocumentCollapsed( | 39 jboolean NewTabPagePrefs::GetSnapshotDocumentCollapsed( |
| 55 JNIEnv* env, | 40 JNIEnv* env, |
| 56 const JavaParamRef<jobject>& obj) { | 41 const JavaParamRef<jobject>& obj) { |
| 57 return profile_->GetPrefs()->GetBoolean(prefs::kNtpCollapsedSnapshotDocument); | 42 return profile_->GetPrefs()->GetBoolean(prefs::kNtpCollapsedSnapshotDocument); |
| 58 } | 43 } |
| 59 | 44 |
| 60 void NewTabPagePrefs::SetSnapshotDocumentCollapsed( | 45 void NewTabPagePrefs::SetSnapshotDocumentCollapsed( |
| 61 JNIEnv* env, | 46 JNIEnv* env, |
| 62 const JavaParamRef<jobject>& obj, | 47 const JavaParamRef<jobject>& obj, |
| 63 jboolean is_collapsed) { | 48 jboolean is_collapsed) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); | 98 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); |
| 114 if (is_collapsed) | 99 if (is_collapsed) |
| 115 update.Get()->SetBoolean(ConvertJavaStringToUTF8(env, session_tag), true); | 100 update.Get()->SetBoolean(ConvertJavaStringToUTF8(env, session_tag), true); |
| 116 else | 101 else |
| 117 update.Get()->Remove(ConvertJavaStringToUTF8(env, session_tag), NULL); | 102 update.Get()->Remove(ConvertJavaStringToUTF8(env, session_tag), NULL); |
| 118 } | 103 } |
| 119 | 104 |
| 120 // static | 105 // static |
| 121 void NewTabPagePrefs::RegisterProfilePrefs( | 106 void NewTabPagePrefs::RegisterProfilePrefs( |
| 122 user_prefs::PrefRegistrySyncable* registry) { | 107 user_prefs::PrefRegistrySyncable* registry) { |
| 123 registry->RegisterBooleanPref(prefs::kNtpCollapsedCurrentlyOpenTabs, false); | |
| 124 registry->RegisterBooleanPref(prefs::kNtpCollapsedSnapshotDocument, false); | 108 registry->RegisterBooleanPref(prefs::kNtpCollapsedSnapshotDocument, false); |
| 125 registry->RegisterBooleanPref(prefs::kNtpCollapsedRecentlyClosedTabs, false); | 109 registry->RegisterBooleanPref(prefs::kNtpCollapsedRecentlyClosedTabs, false); |
| 126 registry->RegisterBooleanPref(prefs::kNtpCollapsedSyncPromo, false); | 110 registry->RegisterBooleanPref(prefs::kNtpCollapsedSyncPromo, false); |
| 127 registry->RegisterDictionaryPref(prefs::kNtpCollapsedForeignSessions); | 111 registry->RegisterDictionaryPref(prefs::kNtpCollapsedForeignSessions); |
| 128 } | 112 } |
| 129 | 113 |
| 130 // static | 114 // static |
| 131 bool NewTabPagePrefs::RegisterNewTabPagePrefs(JNIEnv* env) { | 115 bool NewTabPagePrefs::RegisterNewTabPagePrefs(JNIEnv* env) { |
| 132 return RegisterNativesImpl(env); | 116 return RegisterNativesImpl(env); |
| 133 } | 117 } |
| OLD | NEW |