|
8 | 8 | #include <memory>
|
9 | 9 | #include <utility>
|
10 | 10 |
|
| 11 | +#include "brave/browser/ai_chat/ai_chat_service_factory.h" |
11 | 12 | #include "brave/browser/brave_news/brave_news_controller_factory.h"
|
| 13 | +#include "brave/components/ai_chat/core/browser/ai_chat_service.h" |
12 | 14 | #include "brave/components/ai_chat/core/browser/utils.h"
|
13 | 15 | #include "brave/components/ai_chat/core/common/features.h"
|
14 | 16 | #include "brave/components/brave_news/browser/brave_news_controller.h"
|
|
19 | 21 | #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
20 | 22 | #include "chrome/browser/profiles/profile.h"
|
21 | 23 | #include "chrome/common/buildflags.h"
|
| 24 | +#include "components/browsing_data/content/browsing_data_helper.h" |
22 | 25 | #include "components/content_settings/core/browser/host_content_settings_map.h"
|
| 26 | +#include "content/public/browser/browsing_data_remover.h" |
23 | 27 |
|
24 | 28 | BraveBrowsingDataRemoverDelegate::BraveBrowsingDataRemoverDelegate(
|
25 | 29 | content::BrowserContext* browser_context)
|
@@ -48,19 +52,42 @@ void BraveBrowsingDataRemoverDelegate::RemoveEmbedderData(
|
48 | 52 | ClearShieldsSettings(delete_begin, delete_end);
|
49 | 53 | }
|
50 | 54 |
|
51 |
| - // Brave News feed cache |
52 | 55 | if (remove_mask & chrome_browsing_data_remover::DATA_TYPE_HISTORY) {
|
| 56 | + // Brave News feed cache |
53 | 57 | if (auto* brave_news_controller =
|
54 | 58 | brave_news::BraveNewsControllerFactory::GetForBrowserContext(
|
55 | 59 | profile_)) {
|
56 | 60 | brave_news_controller->ClearHistory();
|
57 | 61 | }
|
| 62 | + // AI Chat history but only associated content, not neccessary if we |
| 63 | + // are also deleting entire AI Chat history. |
| 64 | + if (!(remove_mask & |
| 65 | + chrome_browsing_data_remover::DATA_TYPE_BRAVE_LEO_HISTORY)) { |
| 66 | + ai_chat::AIChatService* ai_chat_service = |
| 67 | + ai_chat::AIChatServiceFactory::GetForBrowserContext(profile_); |
| 68 | + if (ai_chat_service) { |
| 69 | + ai_chat_service->DeleteAssociatedWebContent(delete_begin, delete_end); |
| 70 | + } |
| 71 | + } |
58 | 72 | }
|
59 | 73 |
|
60 |
| - if (remove_mask & chrome_browsing_data_remover::DATA_TYPE_BRAVE_LEO_HISTORY && |
61 |
| - ai_chat::IsAIChatEnabled(profile_->GetPrefs()) && |
62 |
| - ai_chat::features::IsAIChatHistoryEnabled()) { |
63 |
| - ClearAiChatHistory(delete_begin, delete_end); |
| 74 | + if (remove_mask & chrome_browsing_data_remover::DATA_TYPE_BRAVE_LEO_HISTORY) { |
| 75 | + ai_chat::AIChatService* ai_chat_service = |
| 76 | + ai_chat::AIChatServiceFactory::GetForBrowserContext(profile_); |
| 77 | + if (ai_chat_service) { |
| 78 | + ai_chat_service->DeleteConversations(delete_begin, delete_end); |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + if ((remove_mask & content::BrowsingDataRemover::DATA_TYPE_COOKIES) || |
| 83 | + (remove_mask & chrome_browsing_data_remover::DATA_TYPE_HISTORY)) { |
| 84 | + HostContentSettingsMap::PatternSourcePredicate website_settings_filter = |
| 85 | + browsing_data::CreateWebsiteSettingsFilter(filter_builder); |
| 86 | + HostContentSettingsMap* host_content_settings_map = |
| 87 | + HostContentSettingsMapFactory::GetForProfile(profile_); |
| 88 | + host_content_settings_map->ClearSettingsForOneTypeWithPredicate( |
| 89 | + ContentSettingsType::BRAVE_SHIELDS_METADATA, delete_begin, delete_end, |
| 90 | + website_settings_filter); |
64 | 91 | }
|
65 | 92 | }
|
66 | 93 |
|
@@ -92,9 +119,3 @@ void BraveBrowsingDataRemoverDelegate::ClearShieldsSettings(
|
92 | 119 | }
|
93 | 120 | }
|
94 | 121 | }
|
95 |
| - |
96 |
| -void BraveBrowsingDataRemoverDelegate::ClearAiChatHistory(base::Time begin_time, |
97 |
| - base::Time end_time) { |
98 |
| - // Handler for the Brave Leo History clearing. |
99 |
| - // It is prepared for future implementation. |
100 |
| -} |
|
0 commit comments