 Chromium Code Reviews
 Chromium Code Reviews Issue 1017193002:
  [App banners] Be less strict about navigations  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1017193002:
  [App banners] Be less strict about navigations  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: chrome/browser/banners/app_banner_settings_helper.cc | 
| diff --git a/chrome/browser/banners/app_banner_settings_helper.cc b/chrome/browser/banners/app_banner_settings_helper.cc | 
| index 2506f3e2aef4c58f9e29e68cbca418f6d225bcb9..499bb31ec66e39cb0d610d4123f85b4914fc5600 100644 | 
| --- a/chrome/browser/banners/app_banner_settings_helper.cc | 
| +++ b/chrome/browser/banners/app_banner_settings_helper.cc | 
| @@ -45,9 +45,6 @@ const char* kBannerEventKeys[] = { | 
| "didAddToHomescreenEvent", | 
| }; | 
| -// Dictionary key to use whether the banner has been blocked. | 
| -const char kHasBlockedKey[] = "hasBlocked"; | 
| - | 
| scoped_ptr<base::DictionaryValue> GetOriginDict( | 
| HostContentSettingsMap* settings, | 
| const GURL& origin_url) { | 
| @@ -82,6 +79,12 @@ base::DictionaryValue* GetAppDict(base::DictionaryValue* origin_dict, | 
| } // namespace | 
| +bool AppBannerSettingsHelper::URLsAreForTheSamePage(const GURL& first, | 
| + const GURL& second) { | 
| + return first.GetWithEmptyPath() == second.GetWithEmptyPath() | 
| + && first.path() == second.path() && first.query() == second.query(); | 
| 
benwells
2015/03/19 07:18:55
Formatting nit: the && should be on the previous l
 
gone
2015/03/19 19:01:35
Ah, the fun differences between C++ and Java style
 
gone
2015/03/19 19:01:35
Done.
 
benwells
2015/03/20 00:44:33
git cl format is your friend.
 | 
| +} | 
| + | 
| void AppBannerSettingsHelper::ClearHistoryForURLs( | 
| Profile* profile, | 
| const std::set<GURL>& origin_urls) { | 
| @@ -105,10 +108,8 @@ void AppBannerSettingsHelper::RecordBannerEvent( | 
| base::Time time) { | 
| Profile* profile = | 
| Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 
| - if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url || | 
| - package_name_or_start_url.empty()) { | 
| + if (profile->IsOffTheRecord() || package_name_or_start_url.empty()) | 
| return; | 
| - } | 
| ContentSettingsPattern pattern(ContentSettingsPattern::FromURL(origin_url)); | 
| if (!pattern.IsValid()) | 
| @@ -297,67 +298,3 @@ base::Time AppBannerSettingsHelper::GetSingleBannerEvent( | 
| return base::Time::FromInternalValue(internal_time); | 
| } | 
| - | 
| -bool AppBannerSettingsHelper::IsAllowed( | 
| 
benwells
2015/03/19 07:18:55
Thanks for removing this dead stuff, I'd forgotten
 | 
| - content::WebContents* web_contents, | 
| - const GURL& origin_url, | 
| - const std::string& package_name_or_start_url) { | 
| - Profile* profile = | 
| - Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 
| - if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url || | 
| - package_name_or_start_url.empty()) { | 
| - return false; | 
| - } | 
| - | 
| - HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); | 
| - scoped_ptr<base::DictionaryValue> origin_dict = | 
| - GetOriginDict(settings, origin_url); | 
| - | 
| - if (!origin_dict) | 
| - return true; | 
| - | 
| - base::DictionaryValue* app_dict = | 
| - GetAppDict(origin_dict.get(), package_name_or_start_url); | 
| - if (!app_dict) | 
| - return true; | 
| - | 
| - bool has_blocked; | 
| - if (!app_dict->GetBoolean(kHasBlockedKey, &has_blocked)) | 
| - return true; | 
| - | 
| - return !has_blocked; | 
| -} | 
| - | 
| -void AppBannerSettingsHelper::Block( | 
| - content::WebContents* web_contents, | 
| - const GURL& origin_url, | 
| - const std::string& package_name_or_start_url) { | 
| - Profile* profile = | 
| - Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 
| - if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url || | 
| - package_name_or_start_url.empty()) { | 
| - return; | 
| - } | 
| - | 
| - ContentSettingsPattern pattern(ContentSettingsPattern::FromURL(origin_url)); | 
| - if (!pattern.IsValid()) | 
| - return; | 
| - | 
| - HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); | 
| - scoped_ptr<base::DictionaryValue> origin_dict = | 
| - GetOriginDict(settings, origin_url); | 
| - | 
| - if (!origin_dict) | 
| - return; | 
| - | 
| - base::DictionaryValue* app_dict = | 
| - GetAppDict(origin_dict.get(), package_name_or_start_url); | 
| - if (!app_dict) | 
| - return; | 
| - | 
| - // Update the setting and save it back. | 
| - app_dict->SetBoolean(kHasBlockedKey, true); | 
| - settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), | 
| - CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), | 
| - origin_dict.release()); | 
| -} |