| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 10 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 13 #include "components/browser_sync/browser/profile_sync_service.h" |
| 13 #include "components/prefs/pref_member.h" | 14 #include "components/prefs/pref_member.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class ListValue; | 17 class ListValue; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class WebUI; | 21 class WebUI; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace settings { | 24 namespace settings { |
| 24 | 25 |
| 25 // Chrome browser startup settings handler. | 26 // Chrome browser startup settings handler. |
| 26 class ClearBrowsingDataHandler : public SettingsPageUIHandler, | 27 class ClearBrowsingDataHandler : public SettingsPageUIHandler, |
| 27 public BrowsingDataRemover::Observer { | 28 public BrowsingDataRemover::Observer, |
| 29 public sync_driver::SyncServiceObserver { |
| 28 public: | 30 public: |
| 29 explicit ClearBrowsingDataHandler(content::WebUI* webui); | 31 explicit ClearBrowsingDataHandler(content::WebUI* webui); |
| 30 ~ClearBrowsingDataHandler() override; | 32 ~ClearBrowsingDataHandler() override; |
| 31 | 33 |
| 32 // OptionsPageUIHandler: | 34 // WebUIMessageHandler implementation. |
| 33 void RegisterMessages() override; | 35 void RegisterMessages() override; |
| 34 | 36 |
| 35 private: | 37 private: |
| 36 // Clears browsing data, called by Javascript. | 38 // Clears browsing data, called by Javascript. |
| 37 void HandleClearBrowsingData(const base::ListValue* value); | 39 void HandleClearBrowsingData(const base::ListValue* value); |
| 38 | 40 |
| 39 // BrowsingDataRemover::Observer implementation. | 41 // BrowsingDataRemover::Observer implementation. |
| 40 // Re-enables clear button once all requested data has been removed. | 42 // Re-enables clear button once all requested data has been removed. |
| 41 void OnBrowsingDataRemoverDone() override; | 43 void OnBrowsingDataRemoverDone() override; |
| 42 | 44 |
| 43 // Updates UI when the pref to allow clearing history changes. | 45 // Updates UI when the pref to allow clearing history changes. |
| 44 virtual void OnBrowsingHistoryPrefChanged(); | 46 virtual void OnBrowsingHistoryPrefChanged(); |
| 45 | 47 |
| 48 // Initializes the footer of the dialog. Called by JavaScript when the DOM |
| 49 // is attached. |
| 50 void InitializeFooter(const base::ListValue* args); |
| 51 |
| 52 // Implementation of SyncServiceObserver. Updates the footer of the dialog |
| 53 // when the sync state changes. |
| 54 void OnStateChanged() override; |
| 55 |
| 56 // Finds out whether we should show notice about other forms of history stored |
| 57 // in user's account. |
| 58 void RefreshHistoryNotice(); |
| 59 |
| 60 // Called as an asynchronous response to |RefreshHistoryNotice()|. Shows or |
| 61 // hides the footer about other forms of history stored in user's account. |
| 62 void UpdateHistoryNotice(bool show); |
| 63 |
| 64 // ProfileSyncService to observe sync state changes. |
| 65 ProfileSyncService* sync_service_; |
| 66 |
| 46 // If non-null it means removal is in progress. | 67 // If non-null it means removal is in progress. |
| 47 BrowsingDataRemover* remover_; | 68 BrowsingDataRemover* remover_; |
| 48 | 69 |
| 49 // The WebUI callback ID of the last performClearBrowserData request. There | 70 // The WebUI callback ID of the last performClearBrowserData request. There |
| 50 // can only be one such request in-flight. | 71 // can only be one such request in-flight. |
| 51 std::string webui_callback_id_; | 72 std::string webui_callback_id_; |
| 52 | 73 |
| 53 // Keeps track of whether clearing LSO data is supported. | 74 // Keeps track of whether clearing LSO data is supported. |
| 54 BooleanPrefMember clear_plugin_lso_data_enabled_; | 75 BooleanPrefMember clear_plugin_lso_data_enabled_; |
| 55 | 76 |
| 56 // Keeps track of whether Pepper Flash is enabled and thus Flapper-specific | 77 // Keeps track of whether Pepper Flash is enabled and thus Flapper-specific |
| 57 // settings and removal options (e.g. Content Licenses) are available. | 78 // settings and removal options (e.g. Content Licenses) are available. |
| 58 BooleanPrefMember pepper_flash_settings_enabled_; | 79 BooleanPrefMember pepper_flash_settings_enabled_; |
| 59 | 80 |
| 60 // Keeps track of whether deleting browsing history and downloads is allowed. | 81 // Keeps track of whether deleting browsing history and downloads is allowed. |
| 61 BooleanPrefMember allow_deleting_browser_history_; | 82 BooleanPrefMember allow_deleting_browser_history_; |
| 62 | 83 |
| 84 // Whether the sentence about other forms of history stored in user's account |
| 85 // should be displayed in the footer. This value is retrieved asynchronously, |
| 86 // so we cache it here. |
| 87 bool should_show_history_footer_; |
| 88 |
| 89 // A weak pointer factory for asynchronous calls referencing this class. |
| 90 base::WeakPtrFactory<ClearBrowsingDataHandler> weak_ptr_factory_; |
| 91 |
| 63 DISALLOW_COPY_AND_ASSIGN(ClearBrowsingDataHandler); | 92 DISALLOW_COPY_AND_ASSIGN(ClearBrowsingDataHandler); |
| 64 }; | 93 }; |
| 65 | 94 |
| 66 } // namespace settings | 95 } // namespace settings |
| 67 | 96 |
| 68 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER
_H_ | 97 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER
_H_ |
| OLD | NEW |