Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_UI_TAB_MODEL_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_UI_TAB_MODEL_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_UI_TAB_MODEL_H_ | 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_UI_TAB_MODEL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 SessionID::id_type tab_id) const; | 52 SessionID::id_type tab_id) const; |
| 53 | 53 |
| 54 // Reports a tab closure for the tab with |tab_id| to the DataUseTabModel on | 54 // Reports a tab closure for the tab with |tab_id| to the DataUseTabModel on |
| 55 // IO thread. The tab could either have been closed or evicted from the memory | 55 // IO thread. The tab could either have been closed or evicted from the memory |
| 56 // by Android. | 56 // by Android. |
| 57 void ReportTabClosure(SessionID::id_type tab_id); | 57 void ReportTabClosure(SessionID::id_type tab_id); |
| 58 | 58 |
| 59 // Reports a custom tab navigation to the DataUseTabModel on the IO thread. | 59 // Reports a custom tab navigation to the DataUseTabModel on the IO thread. |
| 60 // Includes the |tab_id|, |url|, and |package_name| for the navigation. | 60 // Includes the |tab_id|, |url|, and |package_name| for the navigation. |
| 61 void ReportCustomTabInitialNavigation(SessionID::id_type tab_id, | 61 void ReportCustomTabInitialNavigation(SessionID::id_type tab_id, |
| 62 const std::string& url, | 62 const std::string& package_name, |
| 63 const std::string& package_name); | 63 const std::string& url); |
| 64 | 64 |
| 65 // Returns true if data use tracking has been started for the tab with id | 65 // Returns true if data use tracking has been started for the tab with id |
| 66 // |tab_id|. Calling this function resets the state of the tab. | 66 // |tab_id|. Calling this function resets the state of the tab. |
| 67 bool HasDataUseTrackingStarted(SessionID::id_type tab_id); | 67 bool HasDataUseTrackingStarted(SessionID::id_type tab_id); |
| 68 | 68 |
| 69 // Returns true if data use tracking has ended for the tab with id |tab_id|. | 69 // Returns true if data use tracking has ended for the tab with id |tab_id|. |
| 70 // Calling this function resets the state of the tab. | 70 // Calling this function resets the state of the tab. |
| 71 bool HasDataUseTrackingEnded(SessionID::id_type tab_id); | 71 bool HasDataUseTrackingEnded(SessionID::id_type tab_id); |
| 72 | 72 |
| 73 // Sets the pointer to DataUseTabModel. |data_use_tab_model| is owned by the | 73 // Sets the pointer to DataUseTabModel. |data_use_tab_model| is owned by the |
| 74 // caller. | 74 // caller. |
| 75 void SetDataUseTabModel(DataUseTabModel* data_use_tab_model); | 75 void SetDataUseTabModel(DataUseTabModel* data_use_tab_model); |
| 76 | 76 |
| 77 // Returns true if the tab with id |tab_id| is currently tracked, and | |
| 78 // starting the navigation to |url| with transition type |page_transition| | |
| 79 // would end tracking of data use. | |
| 80 bool WouldDataUseTrackingEnd(const std::string& url, | |
| 81 int page_transition, | |
| 82 SessionID::id_type tab_id) const; | |
| 83 | |
| 84 // Notifies that user clicked "Continue" when the dialog box with data use | |
| 85 // warning was shown. Includes the |tab_id| on which the warning was shown. | |
|
megjablon
2015/12/28 20:32:06
Add to comment the reason this is necessary.
tbansal1
2015/12/28 23:55:52
Done.
| |
| 86 void UserClickedContinueOnDialogBox(SessionID::id_type tab_id); | |
| 87 | |
| 77 base::WeakPtr<DataUseUITabModel> GetWeakPtr(); | 88 base::WeakPtr<DataUseUITabModel> GetWeakPtr(); |
| 78 | 89 |
| 79 private: | 90 private: |
| 80 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ConvertTransitionType); | 91 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ConvertTransitionType); |
| 81 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, EntranceExitState); | 92 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, EntranceExitState); |
| 93 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, | |
| 94 EntranceExitStateWithDialogBox); | |
| 82 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest); | 95 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest); |
| 83 | 96 |
| 84 // DataUseTrackingEvent indicates the state of a tab. | 97 // DataUseTrackingEvent indicates the state of a tab. |
| 85 enum DataUseTrackingEvent { | 98 enum DataUseTrackingEvent { |
| 86 // Indicates that data use tracking has started. | 99 // Indicates that data use tracking has started. |
| 87 DATA_USE_TRACKING_STARTED, | 100 DATA_USE_TRACKING_STARTED, |
| 88 | 101 |
| 89 // Indicates that data use tracking has ended. | 102 // Indicates that data use tracking has ended. |
| 90 DATA_USE_TRACKING_ENDED, | 103 DATA_USE_TRACKING_ENDED, |
| 104 | |
| 105 // Indicates that user clicked "Continue" when the dialog box was shown. | |
| 106 DATA_USE_CONTINUE_CLICKED, | |
| 91 }; | 107 }; |
| 92 | 108 |
| 93 typedef base::hash_map<SessionID::id_type, DataUseTrackingEvent> TabEvents; | 109 typedef base::hash_map<SessionID::id_type, DataUseTrackingEvent> TabEvents; |
| 94 | 110 |
| 95 // DataUseTabModel::TabDataUseObserver implementation: | 111 // DataUseTabModel::TabDataUseObserver implementation: |
| 96 void NotifyTrackingStarting(SessionID::id_type tab_id) override; | 112 void NotifyTrackingStarting(SessionID::id_type tab_id) override; |
| 97 void NotifyTrackingEnding(SessionID::id_type tab_id) override; | 113 void NotifyTrackingEnding(SessionID::id_type tab_id) override; |
| 98 | 114 |
| 99 // Creates |event| for tab with id |tab_id| and value |event|, if there is no | 115 // Creates |event| for tab with id |tab_id| and value |event|, if there is no |
| 100 // existing entry for |tab_id|, and returns true. Otherwise, returns false | 116 // existing entry for |tab_id|, and returns true. Otherwise, returns false |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 126 base::WeakPtrFactory<DataUseUITabModel> weak_factory_; | 142 base::WeakPtrFactory<DataUseUITabModel> weak_factory_; |
| 127 | 143 |
| 128 DISALLOW_COPY_AND_ASSIGN(DataUseUITabModel); | 144 DISALLOW_COPY_AND_ASSIGN(DataUseUITabModel); |
| 129 }; | 145 }; |
| 130 | 146 |
| 131 } // namespace android | 147 } // namespace android |
| 132 | 148 |
| 133 } // namespace chrome | 149 } // namespace chrome |
| 134 | 150 |
| 135 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_UI_TAB_MODEL_H_ | 151 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_UI_TAB_MODEL_H_ |
| OLD | NEW |