| 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_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class WebUI; | 26 class WebUI; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace settings { | 29 namespace settings { |
| 30 | 30 |
| 31 // Chrome browser startup settings handler. | 31 // Chrome browser startup settings handler. |
| 32 class ClearBrowsingDataHandler : public SettingsPageUIHandler, | 32 class ClearBrowsingDataHandler : public SettingsPageUIHandler, |
| 33 public BrowsingDataRemover::Observer, | |
| 34 public sync_driver::SyncServiceObserver { | 33 public sync_driver::SyncServiceObserver { |
| 35 public: | 34 public: |
| 36 explicit ClearBrowsingDataHandler(content::WebUI* webui); | 35 explicit ClearBrowsingDataHandler(content::WebUI* webui); |
| 37 ~ClearBrowsingDataHandler() override; | 36 ~ClearBrowsingDataHandler() override; |
| 38 | 37 |
| 39 // WebUIMessageHandler implementation. | 38 // WebUIMessageHandler implementation. |
| 40 void RegisterMessages() override; | 39 void RegisterMessages() override; |
| 41 void OnJavascriptAllowed() override; | 40 void OnJavascriptAllowed() override; |
| 42 void OnJavascriptDisallowed() override; | 41 void OnJavascriptDisallowed() override; |
| 43 | 42 |
| 44 private: | 43 private: |
| 44 // Observes one |remover| task initiated from ClearBrowsingDataHandler. |
| 45 // Calls |callback| when the task is finished. |
| 46 class TaskObserver; |
| 47 |
| 45 // Clears browsing data, called by Javascript. | 48 // Clears browsing data, called by Javascript. |
| 46 void HandleClearBrowsingData(const base::ListValue* value); | 49 void HandleClearBrowsingData(const base::ListValue* value); |
| 47 | 50 |
| 48 // BrowsingDataRemover::Observer implementation. | 51 // Called when a clearing task finished. |webui_callback_id| is provided |
| 49 void OnBrowsingDataRemoving(bool is_removing) override; | 52 // by the WebUI action that initiated it. |
| 53 void OnClearingTaskFinished(const std::string& webui_callback_id); |
| 50 | 54 |
| 51 // Updates UI when the pref to allow clearing history changes. | 55 // Updates UI when the pref to allow clearing history changes. |
| 52 virtual void OnBrowsingHistoryPrefChanged(); | 56 virtual void OnBrowsingHistoryPrefChanged(); |
| 53 | 57 |
| 54 // Initializes the dialog UI. Called by JavaScript when the DOM is ready. | 58 // Initializes the dialog UI. Called by JavaScript when the DOM is ready. |
| 55 void HandleInitialize(const base::ListValue* args); | 59 void HandleInitialize(const base::ListValue* args); |
| 56 | 60 |
| 57 // Implementation of SyncServiceObserver. Updates the footer of the dialog | 61 // Implementation of SyncServiceObserver. Updates the footer of the dialog |
| 58 // when the sync state changes. | 62 // when the sync state changes. |
| 59 void OnStateChanged() override; | 63 void OnStateChanged() override; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 77 // Updates a counter text according to the |result|. | 81 // Updates a counter text according to the |result|. |
| 78 void UpdateCounterText( | 82 void UpdateCounterText( |
| 79 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result); | 83 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result); |
| 80 | 84 |
| 81 // Cached profile corresponding to the WebUI of this handler. | 85 // Cached profile corresponding to the WebUI of this handler. |
| 82 Profile* profile_; | 86 Profile* profile_; |
| 83 | 87 |
| 84 // Counters that calculate the data volume for individual data types. | 88 // Counters that calculate the data volume for individual data types. |
| 85 std::vector<std::unique_ptr<browsing_data::BrowsingDataCounter>> counters_; | 89 std::vector<std::unique_ptr<browsing_data::BrowsingDataCounter>> counters_; |
| 86 | 90 |
| 91 // Observes the currently active data clearing task. |
| 92 std::unique_ptr<TaskObserver> task_observer_; |
| 93 |
| 87 // ProfileSyncService to observe sync state changes. | 94 // ProfileSyncService to observe sync state changes. |
| 88 ProfileSyncService* sync_service_; | 95 ProfileSyncService* sync_service_; |
| 89 ScopedObserver<ProfileSyncService, sync_driver::SyncServiceObserver> | 96 ScopedObserver<ProfileSyncService, sync_driver::SyncServiceObserver> |
| 90 sync_service_observer_; | 97 sync_service_observer_; |
| 91 | 98 |
| 92 // Observe the remover progress. | |
| 93 BrowsingDataRemover* remover_; | |
| 94 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> | |
| 95 remover_observer_; | |
| 96 | |
| 97 // The WebUI callback ID of the last performClearBrowserData request. There | |
| 98 // can only be one such request in-flight. | |
| 99 std::string webui_callback_id_; | |
| 100 | |
| 101 // Used to listen for pref changes to allow / disallow deleting browsing data. | 99 // Used to listen for pref changes to allow / disallow deleting browsing data. |
| 102 PrefChangeRegistrar profile_pref_registrar_; | 100 PrefChangeRegistrar profile_pref_registrar_; |
| 103 | 101 |
| 104 // Whether the sentence about other forms of history stored in user's account | 102 // Whether the sentence about other forms of history stored in user's account |
| 105 // should be displayed in the footer. This value is retrieved asynchronously, | 103 // should be displayed in the footer. This value is retrieved asynchronously, |
| 106 // so we cache it here. | 104 // so we cache it here. |
| 107 bool show_history_footer_; | 105 bool show_history_footer_; |
| 108 | 106 |
| 109 // Whether we should show a dialog informing the user about other forms of | 107 // Whether we should show a dialog informing the user about other forms of |
| 110 // history stored in their account after the history deletion is finished. | 108 // history stored in their account after the history deletion is finished. |
| 111 bool show_history_deletion_dialog_; | 109 bool show_history_deletion_dialog_; |
| 112 | 110 |
| 113 // A weak pointer factory for asynchronous calls referencing this class. | 111 // A weak pointer factory for asynchronous calls referencing this class. |
| 114 base::WeakPtrFactory<ClearBrowsingDataHandler> weak_ptr_factory_; | 112 base::WeakPtrFactory<ClearBrowsingDataHandler> weak_ptr_factory_; |
| 115 | 113 |
| 116 DISALLOW_COPY_AND_ASSIGN(ClearBrowsingDataHandler); | 114 DISALLOW_COPY_AND_ASSIGN(ClearBrowsingDataHandler); |
| 117 }; | 115 }; |
| 118 | 116 |
| 119 } // namespace settings | 117 } // namespace settings |
| 120 | 118 |
| 121 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER
_H_ | 119 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER
_H_ |
| OLD | NEW |