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 package org.chromium.chrome.browser.ntp; | 5 package org.chromium.chrome.browser.ntp; |
6 | 6 |
7 import org.chromium.chrome.browser.ntp.ForeignSessionHelper.ForeignSession; | 7 import org.chromium.chrome.browser.ntp.ForeignSessionHelper.ForeignSession; |
8 import org.chromium.chrome.browser.profiles.Profile; | 8 import org.chromium.chrome.browser.profiles.Profile; |
9 | 9 |
10 /** | 10 /** |
11 * This class allows Java code to read and modify preferences related to the NTP | 11 * Allows Java code to read and modify preferences related to the {@link RecentT
absPage}. |
12 */ | 12 */ |
13 class NewTabPagePrefs { | 13 class RecentTabsPagePrefs { |
14 private long mNativeNewTabPagePrefs; | 14 private long mNativePrefs; |
15 | 15 |
16 /** | 16 /** |
17 * Initialize this class with the given profile. | 17 * Initialize this class with the given profile. |
18 * @param profile Profile that will be used for syncing. | 18 * @param profile Profile that will be used for syncing. |
19 */ | 19 */ |
20 NewTabPagePrefs(Profile profile) { | 20 RecentTabsPagePrefs(Profile profile) { |
21 mNativeNewTabPagePrefs = nativeInit(profile); | 21 mNativePrefs = nativeInit(profile); |
22 } | 22 } |
23 | 23 |
24 /** | 24 /** |
25 * Clean up the C++ side of this class. After the call, this class instance
shouldn't be used. | 25 * Clean up the C++ side of this class. After the call, this class instance
shouldn't be used. |
26 */ | 26 */ |
27 void destroy() { | 27 void destroy() { |
28 assert mNativeNewTabPagePrefs != 0; | 28 assert mNativePrefs != 0; |
29 nativeDestroy(mNativeNewTabPagePrefs); | 29 nativeDestroy(mNativePrefs); |
30 mNativeNewTabPagePrefs = 0; | 30 mNativePrefs = 0; |
31 } | 31 } |
32 | 32 |
33 /** | 33 /** |
34 * Sets whether the list of snapshot documents is collapsed (vs expanded) on
the Recent Tabs | 34 * Sets whether the list of snapshot documents is collapsed (vs expanded) on
the Recent Tabs |
35 * page. | 35 * page. |
36 * @param isCollapsed Whether we want the snapshot documents list to be coll
apsed. | 36 * @param isCollapsed Whether we want the snapshot documents list to be coll
apsed. |
37 */ | 37 */ |
38 void setSnapshotDocumentCollapsed(boolean isCollapsed) { | 38 void setSnapshotDocumentCollapsed(boolean isCollapsed) { |
39 nativeSetSnapshotDocumentCollapsed(mNativeNewTabPagePrefs, isCollapsed); | 39 nativeSetSnapshotDocumentCollapsed(mNativePrefs, isCollapsed); |
40 } | 40 } |
41 | 41 |
42 /** | 42 /** |
43 * Gets whether the list of snapshot documents is collapsed (vs expanded) on | 43 * Gets whether the list of snapshot documents is collapsed (vs expanded) on |
44 * the Recent Tabs page. | 44 * the Recent Tabs page. |
45 * @return Whether the list of snapshot documents is collapsed (vs expanded)
on | 45 * @return Whether the list of snapshot documents is collapsed (vs expanded)
on |
46 * the Recent Tabs page. | 46 * the Recent Tabs page. |
47 */ | 47 */ |
48 boolean getSnapshotDocumentCollapsed() { | 48 boolean getSnapshotDocumentCollapsed() { |
49 return nativeGetSnapshotDocumentCollapsed(mNativeNewTabPagePrefs); | 49 return nativeGetSnapshotDocumentCollapsed(mNativePrefs); |
50 } | 50 } |
51 | 51 |
52 /** | 52 /** |
53 * Sets whether the list of recently closed tabs is collapsed (vs expanded)
on the Recent Tabs | 53 * Sets whether the list of recently closed tabs is collapsed (vs expanded)
on the Recent Tabs |
54 * page. | 54 * page. |
55 * @param isCollapsed Whether we want the recently closed tabs list to be co
llapsed. | 55 * @param isCollapsed Whether we want the recently closed tabs list to be co
llapsed. |
56 */ | 56 */ |
57 void setRecentlyClosedTabsCollapsed(boolean isCollapsed) { | 57 void setRecentlyClosedTabsCollapsed(boolean isCollapsed) { |
58 nativeSetRecentlyClosedTabsCollapsed(mNativeNewTabPagePrefs, isCollapsed
); | 58 nativeSetRecentlyClosedTabsCollapsed(mNativePrefs, isCollapsed); |
59 } | 59 } |
60 | 60 |
61 /** | 61 /** |
62 * Gets whether the list of recently closed tabs is collapsed (vs expanded)
on | 62 * Gets whether the list of recently closed tabs is collapsed (vs expanded)
on |
63 * the Recent Tabs page. | 63 * the Recent Tabs page. |
64 * @return Whether the list of recently closed tabs is collapsed (vs expande
d) on | 64 * @return Whether the list of recently closed tabs is collapsed (vs expande
d) on |
65 * the Recent Tabs page. | 65 * the Recent Tabs page. |
66 */ | 66 */ |
67 boolean getRecentlyClosedTabsCollapsed() { | 67 boolean getRecentlyClosedTabsCollapsed() { |
68 return nativeGetRecentlyClosedTabsCollapsed(mNativeNewTabPagePrefs); | 68 return nativeGetRecentlyClosedTabsCollapsed(mNativePrefs); |
69 } | 69 } |
70 | 70 |
71 /** | 71 /** |
72 * Sets whether sync promo is collapsed (vs expanded) on the Recent Tabs pag
e. | 72 * Sets whether sync promo is collapsed (vs expanded) on the Recent Tabs pag
e. |
73 * @param isCollapsed Whether we want the sync promo to be collapsed. | 73 * @param isCollapsed Whether we want the sync promo to be collapsed. |
74 */ | 74 */ |
75 void setSyncPromoCollapsed(boolean isCollapsed) { | 75 void setSyncPromoCollapsed(boolean isCollapsed) { |
76 nativeSetSyncPromoCollapsed(mNativeNewTabPagePrefs, isCollapsed); | 76 nativeSetSyncPromoCollapsed(mNativePrefs, isCollapsed); |
77 } | 77 } |
78 | 78 |
79 /** | 79 /** |
80 * Gets whether sync promo is collapsed (vs expanded) on the Recent Tabs pag
e. | 80 * Gets whether sync promo is collapsed (vs expanded) on the Recent Tabs pag
e. |
81 * @return Whether the sync promo is collapsed (vs expanded) on the Recent T
abs page. | 81 * @return Whether the sync promo is collapsed (vs expanded) on the Recent T
abs page. |
82 */ | 82 */ |
83 boolean getSyncPromoCollapsed() { | 83 boolean getSyncPromoCollapsed() { |
84 return nativeGetSyncPromoCollapsed(mNativeNewTabPagePrefs); | 84 return nativeGetSyncPromoCollapsed(mNativePrefs); |
85 } | 85 } |
86 | 86 |
87 /** | 87 /** |
88 * Sets whether the given foreign session is collapsed (vs expanded) on the
Recent Tabs page. | 88 * Sets whether the given foreign session is collapsed (vs expanded) on the
Recent Tabs page. |
89 * @param session Session to set collapsed or expanded. | 89 * @param session Session to set collapsed or expanded. |
90 * @param isCollapsed Whether we want the foreign session to be collapsed. | 90 * @param isCollapsed Whether we want the foreign session to be collapsed. |
91 */ | 91 */ |
92 void setForeignSessionCollapsed(ForeignSession session, boolean isCollapsed)
{ | 92 void setForeignSessionCollapsed(ForeignSession session, boolean isCollapsed)
{ |
93 nativeSetForeignSessionCollapsed(mNativeNewTabPagePrefs, session.tag, is
Collapsed); | 93 nativeSetForeignSessionCollapsed(mNativePrefs, session.tag, isCollapsed)
; |
94 } | 94 } |
95 | 95 |
96 /** | 96 /** |
97 * Gets whether the given foreign session is collapsed (vs expanded) on the
Recent Tabs page. | 97 * Gets whether the given foreign session is collapsed (vs expanded) on the
Recent Tabs page. |
98 * @param session Session to fetch collapsed state. | 98 * @param session Session to fetch collapsed state. |
99 * @return Whether the given foreign session is collapsed (vs expanded) on t
he Recent Tabs page. | 99 * @return Whether the given foreign session is collapsed (vs expanded) on t
he Recent Tabs page. |
100 */ | 100 */ |
101 boolean getForeignSessionCollapsed(ForeignSession session) { | 101 boolean getForeignSessionCollapsed(ForeignSession session) { |
102 return nativeGetForeignSessionCollapsed(mNativeNewTabPagePrefs, session.
tag); | 102 return nativeGetForeignSessionCollapsed(mNativePrefs, session.tag); |
103 } | 103 } |
104 | 104 |
105 private static native long nativeInit(Profile profile); | 105 private static native long nativeInit(Profile profile); |
106 private static native void nativeDestroy(long nativeNewTabPagePrefs); | 106 private static native void nativeDestroy(long nativeRecentTabsPagePrefs); |
107 private static native void nativeSetSnapshotDocumentCollapsed( | 107 private static native void nativeSetSnapshotDocumentCollapsed( |
108 long nativeNewTabPagePrefs, boolean isCollapsed); | 108 long nativeRecentTabsPagePrefs, boolean isCollapsed); |
109 private static native boolean nativeGetSnapshotDocumentCollapsed( | 109 private static native boolean nativeGetSnapshotDocumentCollapsed( |
110 long nativeNewTabPagePrefs); | 110 long nativeRecentTabsPagePrefs); |
111 private static native void nativeSetRecentlyClosedTabsCollapsed( | 111 private static native void nativeSetRecentlyClosedTabsCollapsed( |
112 long nativeNewTabPagePrefs, boolean isCollapsed); | 112 long nativeRecentTabsPagePrefs, boolean isCollapsed); |
113 private static native boolean nativeGetRecentlyClosedTabsCollapsed( | 113 private static native boolean nativeGetRecentlyClosedTabsCollapsed( |
114 long nativeNewTabPagePrefs); | 114 long nativeRecentTabsPagePrefs); |
115 private static native void nativeSetSyncPromoCollapsed(long nativeNewTabPage
Prefs, | 115 private static native void nativeSetSyncPromoCollapsed( |
116 boolean isCollapsed); | 116 long nativeRecentTabsPagePrefs, boolean isCollapsed); |
117 private static native boolean nativeGetSyncPromoCollapsed(long nativeNewTabP
agePrefs); | 117 private static native boolean nativeGetSyncPromoCollapsed(long nativeRecentT
absPagePrefs); |
118 private static native void nativeSetForeignSessionCollapsed( | 118 private static native void nativeSetForeignSessionCollapsed( |
119 long nativeNewTabPagePrefs, String sessionTag, boolean isCollapsed); | 119 long nativeRecentTabsPagePrefs, String sessionTag, boolean isCollaps
ed); |
120 private static native boolean nativeGetForeignSessionCollapsed( | 120 private static native boolean nativeGetForeignSessionCollapsed( |
121 long nativeNewTabPagePrefs, String sessionTag); | 121 long nativeRecentTabsPagePrefs, String sessionTag); |
122 } | 122 } |
OLD | NEW |