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

Side by Side Diff: chrome/browser/banners/app_banner_settings_helper.cc

Issue 919843003: Clear app banner data when history is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/banners/app_banner_settings_helper.h" 5 #include "chrome/browser/banners/app_banner_settings_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 app_dict = new base::DictionaryValue(); 72 app_dict = new base::DictionaryValue();
73 origin_dict->SetWithoutPathExpansion(key_name, make_scoped_ptr(app_dict)); 73 origin_dict->SetWithoutPathExpansion(key_name, make_scoped_ptr(app_dict));
74 } 74 }
75 } 75 }
76 76
77 return app_dict; 77 return app_dict;
78 } 78 }
79 79
80 } // namespace 80 } // namespace
81 81
82 void AppBannerSettingsHelper::ClearHistoryForURLs(
83 Profile* profile,
84 const std::set<GURL>& origin_urls) {
85 HostContentSettingsMap* settings = profile->GetHostContentSettingsMap();
86 for (const auto& origin_url : origin_urls) {
Bernhard Bauer 2015/02/13 10:05:06 Using GURL instead of auto here is clearer, and no
benwells 2015/02/15 22:56:05 Done.
87 ContentSettingsPattern pattern(ContentSettingsPattern::FromURL(origin_url));
88 if (!pattern.IsValid())
89 continue;
90
91 settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(),
92 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(),
93 nullptr);
94 }
95 }
96
82 void AppBannerSettingsHelper::RecordBannerEvent( 97 void AppBannerSettingsHelper::RecordBannerEvent(
83 content::WebContents* web_contents, 98 content::WebContents* web_contents,
84 const GURL& origin_url, 99 const GURL& origin_url,
85 const std::string& package_name_or_start_url, 100 const std::string& package_name_or_start_url,
86 AppBannerEvent event, 101 AppBannerEvent event,
87 base::Time time) { 102 base::Time time) {
88 Profile* profile = 103 Profile* profile =
89 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 104 Profile::FromBrowserContext(web_contents->GetBrowserContext());
90 if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url || 105 if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url ||
91 package_name_or_start_url.empty()) { 106 package_name_or_start_url.empty()) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 GetAppDict(origin_dict.get(), package_name_or_start_url); 336 GetAppDict(origin_dict.get(), package_name_or_start_url);
322 if (!app_dict) 337 if (!app_dict)
323 return; 338 return;
324 339
325 // Update the setting and save it back. 340 // Update the setting and save it back.
326 app_dict->SetBoolean(kHasBlockedKey, true); 341 app_dict->SetBoolean(kHasBlockedKey, true);
327 settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), 342 settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(),
328 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), 343 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(),
329 origin_dict.release()); 344 origin_dict.release());
330 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698