1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_WEBUI_RECENT_SITE_SETTINGS_HELPER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_RECENT_SITE_SETTINGS_HELPER_H_ 7 8 #include <vector> 9 10 #include "base/time/time.h" 11 #include "chrome/browser/ui/webui/site_settings_helper.h" 12 #include "components/content_settings/core/common/content_settings.h" 13 #include "components/content_settings/core/common/content_settings_types.h" 14 #include "url/gurl.h" 15 16 class Profile; 17 18 namespace site_settings { 19 20 struct TimestampedSetting { 21 base::Time timestamp; 22 ContentSettingsType content_type; 23 ContentSetting content_setting; 24 site_settings::SiteSettingSource setting_source; 25 26 TimestampedSetting(); 27 TimestampedSetting(const TimestampedSetting& other); 28 TimestampedSetting& operator=(const TimestampedSetting& other) = default; 29 TimestampedSetting(TimestampedSetting&& other) = default; 30 TimestampedSetting(base::Time timestamp, 31 ContentSettingsType content_type, 32 ContentSetting content_setting, 33 site_settings::SiteSettingSource setting_source); 34 ~TimestampedSetting(); 35 }; 36 37 struct RecentSitePermissions { 38 GURL origin; 39 bool incognito; 40 std::vector<TimestampedSetting> settings; 41 42 RecentSitePermissions(); 43 RecentSitePermissions(const RecentSitePermissions& other); 44 RecentSitePermissions& operator=(const RecentSitePermissions& other) = 45 default; 46 RecentSitePermissions(RecentSitePermissions&& other); 47 RecentSitePermissions(GURL origin, 48 bool incognito, 49 std::vector<TimestampedSetting> settings); 50 ~RecentSitePermissions(); 51 }; 52 53 // Returns a list containing the most recent permission changes for the 54 // provided content types grouped by origin/profile (incognito, regular) 55 // combinations. Limited to |max_sources| origin/profile pairings and ordered 56 // from most recently adjusted site to least recently. Includes permissions 57 // changed by embargo, but not those changed by enterprise policy. 58 std::vector<RecentSitePermissions> GetRecentSitePermissions( 59 Profile* profile, 60 std::vector<ContentSettingsType> content_types, 61 size_t max_sources); 62 63 } // namespace site_settings 64 65 #endif // CHROME_BROWSER_UI_WEBUI_RECENT_SITE_SETTINGS_HELPER_H_ 66