Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h

Issue 2716333002: Implement important sites dialog for desktop. (Closed)
Patch Set: replace task observer in -Bridge and -Handler with a callback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 15 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
16 #include "components/browser_sync/profile_sync_service.h" 16 #include "components/browser_sync/profile_sync_service.h"
17 #include "components/browsing_data/core/counters/browsing_data_counter.h" 17 #include "components/browsing_data/core/counters/browsing_data_counter.h"
18 18
19 namespace base { 19 namespace base {
20 class ListValue; 20 class ListValue;
21 } 21 }
22 22
23 namespace content { 23 namespace content {
24 class WebUI; 24 class WebUI;
25 class BrowsingDataFilterBuilder;
Dan Beam 2017/05/05 17:52:51 alpha
dullweber 2017/05/09 08:56:39 I sorted the declarations
25 } 26 }
26 27
27 namespace settings { 28 namespace settings {
28 29
29 // Chrome browser startup settings handler. 30 // Chrome browser startup settings handler.
30 class ClearBrowsingDataHandler : public SettingsPageUIHandler, 31 class ClearBrowsingDataHandler : public SettingsPageUIHandler,
31 public syncer::SyncServiceObserver { 32 public syncer::SyncServiceObserver {
32 public: 33 public:
33 explicit ClearBrowsingDataHandler(content::WebUI* webui); 34 explicit ClearBrowsingDataHandler(content::WebUI* webui);
34 ~ClearBrowsingDataHandler() override; 35 ~ClearBrowsingDataHandler() override;
35 36
36 // WebUIMessageHandler implementation. 37 // WebUIMessageHandler implementation.
37 void RegisterMessages() override; 38 void RegisterMessages() override;
38 void OnJavascriptAllowed() override; 39 void OnJavascriptAllowed() override;
39 void OnJavascriptDisallowed() override; 40 void OnJavascriptDisallowed() override;
40 41
41 private: 42 private:
42 // Observes one |remover| task initiated from ClearBrowsingDataHandler.
43 // Calls |callback| when the task is finished.
44 class TaskObserver;
45
46 // Clears browsing data, called by Javascript. 43 // Clears browsing data, called by Javascript.
47 void HandleClearBrowsingData(const base::ListValue* value); 44 void HandleClearBrowsingData(const base::ListValue* value);
48 45
46 // Parses a ListValue with important site information and creates a
47 // BrowsingDataFilterBuilder.
48 std::unique_ptr<content::BrowsingDataFilterBuilder> ProcessImportantSites(
49 const base::ListValue* important_sites);
50
49 // Called when a clearing task finished. |webui_callback_id| is provided 51 // Called when a clearing task finished. |webui_callback_id| is provided
50 // by the WebUI action that initiated it. 52 // by the WebUI action that initiated it.
51 void OnClearingTaskFinished(const std::string& webui_callback_id); 53 void OnClearingTaskFinished(const std::string& webui_callback_id);
52 54
55 // Fetches important sites, called by Javascript.
56 void HandleFetchImportantSites(const base::ListValue* value);
57
53 // 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.
54 void HandleInitialize(const base::ListValue* args); 59 void HandleInitialize(const base::ListValue* args);
55 60
56 // Implementation of SyncServiceObserver. 61 // Implementation of SyncServiceObserver.
57 void OnStateChanged(syncer::SyncService* sync) override; 62 void OnStateChanged(syncer::SyncService* sync) override;
58 63
59 // Updates the footer of the dialog when the sync state changes. 64 // Updates the footer of the dialog when the sync state changes.
60 void UpdateSyncState(); 65 void UpdateSyncState();
61 66
62 // Finds out whether we should show notice about other forms of history stored 67 // Finds out whether we should show notice about other forms of history stored
(...skipping 15 matching lines...) Expand all
78 // Updates a counter text according to the |result|. 83 // Updates a counter text according to the |result|.
79 void UpdateCounterText( 84 void UpdateCounterText(
80 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result); 85 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result);
81 86
82 // Cached profile corresponding to the WebUI of this handler. 87 // Cached profile corresponding to the WebUI of this handler.
83 Profile* profile_; 88 Profile* profile_;
84 89
85 // Counters that calculate the data volume for individual data types. 90 // Counters that calculate the data volume for individual data types.
86 std::vector<std::unique_ptr<browsing_data::BrowsingDataCounter>> counters_; 91 std::vector<std::unique_ptr<browsing_data::BrowsingDataCounter>> counters_;
87 92
88 // Observes the currently active data clearing task.
89 std::unique_ptr<TaskObserver> task_observer_;
90
91 // ProfileSyncService to observe sync state changes. 93 // ProfileSyncService to observe sync state changes.
92 browser_sync::ProfileSyncService* sync_service_; 94 browser_sync::ProfileSyncService* sync_service_;
93 ScopedObserver<browser_sync::ProfileSyncService, syncer::SyncServiceObserver> 95 ScopedObserver<browser_sync::ProfileSyncService, syncer::SyncServiceObserver>
94 sync_service_observer_; 96 sync_service_observer_;
95 97
96 // Whether the sentence about other forms of history stored in user's account 98 // Whether the sentence about other forms of history stored in user's account
97 // should be displayed in the footer. This value is retrieved asynchronously, 99 // should be displayed in the footer. This value is retrieved asynchronously,
98 // so we cache it here. 100 // so we cache it here.
99 bool show_history_footer_; 101 bool show_history_footer_;
100 102
101 // Whether we should show a dialog informing the user about other forms of 103 // Whether we should show a dialog informing the user about other forms of
102 // history stored in their account after the history deletion is finished. 104 // history stored in their account after the history deletion is finished.
103 bool show_history_deletion_dialog_; 105 bool show_history_deletion_dialog_;
104 106
105 // A weak pointer factory for asynchronous calls referencing this class. 107 // A weak pointer factory for asynchronous calls referencing this class.
msramek 2017/05/05 15:41:55 Please document when the pointers are invalidated.
dullweber 2017/05/09 08:56:39 Done.
106 base::WeakPtrFactory<ClearBrowsingDataHandler> weak_ptr_factory_; 108 base::WeakPtrFactory<ClearBrowsingDataHandler> weak_ptr_factory_;
107 109
108 DISALLOW_COPY_AND_ASSIGN(ClearBrowsingDataHandler); 110 DISALLOW_COPY_AND_ASSIGN(ClearBrowsingDataHandler);
109 }; 111 };
110 112
111 } // namespace settings 113 } // namespace settings
112 114
113 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER _H_ 115 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_CLEAR_BROWSING_DATA_HANDLER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698