OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.dom_distiller; | 5 package org.chromium.chrome.browser.dom_distiller; |
6 | 6 |
7 import org.chromium.content_public.browser.WebContentsObserver; | 7 import org.chromium.content_public.browser.WebContentsObserver; |
8 | 8 |
9 /** | 9 /** |
10 * This class tracks the per-tab state of reader mode. | 10 * This class tracks the per-tab state of reader mode. |
(...skipping 12 matching lines...) Expand all Loading... | |
23 // back from distiller and the user has already loaded a new URL. | 23 // back from distiller and the user has already loaded a new URL. |
24 private String mCurrentUrl; | 24 private String mCurrentUrl; |
25 | 25 |
26 // The distillability heuristics now use a callback to notify the manager th at a page can | 26 // The distillability heuristics now use a callback to notify the manager th at a page can |
27 // be distilled. This flag is used to detect if the callback is set for this tab. | 27 // be distilled. This flag is used to detect if the callback is set for this tab. |
28 private boolean mIsCallbackSet; | 28 private boolean mIsCallbackSet; |
29 | 29 |
30 // Used to flag the the panel was shown and recorded by UMA. | 30 // Used to flag the the panel was shown and recorded by UMA. |
31 private boolean mShowPanelRecorded; | 31 private boolean mShowPanelRecorded; |
32 | 32 |
33 // The time that the user started viewing Reader Mode content. | |
34 private long mViewStartTimeMs; | |
35 | |
36 // Whether or not the current tab is a Reader Mode page. | |
37 private boolean mIsViewingReaderModePage; | |
38 | |
33 /** | 39 /** |
34 * @param observer The WebContentsObserver for the tab this object represent s. | 40 * @param observer The WebContentsObserver for the tab this object represent s. |
35 */ | 41 */ |
36 public void setWebContentsObserver(WebContentsObserver observer) { | 42 public void setWebContentsObserver(WebContentsObserver observer) { |
37 mWebContentsObserver = observer; | 43 mWebContentsObserver = observer; |
38 } | 44 } |
39 | 45 |
40 /** | 46 /** |
41 * @return The WebContentsObserver for the tab this object represents. | 47 * @return The WebContentsObserver for the tab this object represents. |
42 */ | 48 */ |
43 public WebContentsObserver getWebContentsObserver() { | 49 public WebContentsObserver getWebContentsObserver() { |
44 return mWebContentsObserver; | 50 return mWebContentsObserver; |
45 } | 51 } |
46 | 52 |
47 /** | 53 /** |
54 * A notification that the user started viewing Reader Mode. | |
55 */ | |
56 public void onStartedReaderMode() { | |
57 mIsViewingReaderModePage = true; | |
58 mViewStartTimeMs = System.currentTimeMillis(); | |
wychen
2017/05/17 07:24:12
Monotonic time like elapsedRealtime() should be be
mdjones
2017/05/17 16:52:14
Done.
| |
59 } | |
60 | |
61 /** | |
62 * A notification that the user is no longer viewing Reader Mode. This could be because of a | |
63 * navigation away from the page, switching tabs, or closing the browser. | |
64 * @return The amount of time in ms that the user spent viewing Reader Mode. | |
65 */ | |
66 public long onExitReaderMode() { | |
67 mIsViewingReaderModePage = false; | |
68 return System.currentTimeMillis() - mViewStartTimeMs; | |
69 } | |
70 | |
71 /** | |
72 * @return Whether or not the user is on a Reader Mode page. | |
73 */ | |
74 public boolean isViewingReaderModePage() { | |
75 return mIsViewingReaderModePage; | |
76 } | |
77 | |
78 /** | |
48 * @param status The status of reader mode for this object's tab. | 79 * @param status The status of reader mode for this object's tab. |
49 */ | 80 */ |
50 public void setStatus(int status) { | 81 public void setStatus(int status) { |
51 mStatus = status; | 82 mStatus = status; |
52 } | 83 } |
53 | 84 |
54 /** | 85 /** |
55 * @return The reader mode status for this object's tab. | 86 * @return The reader mode status for this object's tab. |
56 */ | 87 */ |
57 public int getStatus() { | 88 public int getStatus() { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 | 140 |
110 /** | 141 /** |
111 * @param isRecorded True if the action has been recorded. | 142 * @param isRecorded True if the action has been recorded. |
112 */ | 143 */ |
113 public void setIsPanelShowRecorded(boolean isRecorded) { | 144 public void setIsPanelShowRecorded(boolean isRecorded) { |
114 mShowPanelRecorded = isRecorded; | 145 mShowPanelRecorded = isRecorded; |
115 } | 146 } |
116 | 147 |
117 } | 148 } |
118 | 149 |
OLD | NEW |