OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | |
9 #include <algorithm> | 8 #include <algorithm> |
10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "chrome/browser/banners/app_banner_data_fetcher.h" | 14 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
15 #include "chrome/browser/banners/app_banner_metrics.h" | 15 #include "chrome/browser/banners/app_banner_metrics.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "components/content_settings/core/browser/host_content_settings_map.h" | 20 #include "components/content_settings/core/browser/host_content_settings_map.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // format, or it is the same as the current date but with a lower | 329 // format, or it is the same as the current date but with a lower |
330 // engagement, so remove it. | 330 // engagement, so remove it. |
331 it = could_show_list->Erase(it, nullptr); | 331 it = could_show_list->Erase(it, nullptr); |
332 } | 332 } |
333 | 333 |
334 // Dates are stored in their raw form (i.e. not local dates) to be resilient | 334 // Dates are stored in their raw form (i.e. not local dates) to be resilient |
335 // to time zone changes. | 335 // to time zone changes. |
336 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 336 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
337 value->SetDouble(kBannerTimeKey, time.ToInternalValue()); | 337 value->SetDouble(kBannerTimeKey, time.ToInternalValue()); |
338 value->SetDouble(kBannerEngagementKey, engagement); | 338 value->SetDouble(kBannerEngagementKey, engagement); |
339 could_show_list->Append(value.Pass()); | 339 could_show_list->Append(std::move(value)); |
340 | 340 |
341 settings->SetWebsiteSettingDefaultScope(origin_url, GURL(), | 341 settings->SetWebsiteSettingDefaultScope(origin_url, GURL(), |
342 CONTENT_SETTINGS_TYPE_APP_BANNER, | 342 CONTENT_SETTINGS_TYPE_APP_BANNER, |
343 std::string(), origin_dict.release()); | 343 std::string(), origin_dict.release()); |
344 } | 344 } |
345 | 345 |
346 bool AppBannerSettingsHelper::ShouldShowBanner( | 346 bool AppBannerSettingsHelper::ShouldShowBanner( |
347 content::WebContents* web_contents, | 347 content::WebContents* web_contents, |
348 const GURL& origin_url, | 348 const GURL& origin_url, |
349 const std::string& package_name_or_start_url, | 349 const std::string& package_name_or_start_url, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 521 |
522 // Use truncating integer division here. | 522 // Use truncating integer division here. |
523 return time.LocalMidnight() + | 523 return time.LocalMidnight() + |
524 base::TimeDelta::FromMinutes((total_minutes / minutes) * minutes); | 524 base::TimeDelta::FromMinutes((total_minutes / minutes) * minutes); |
525 } | 525 } |
526 | 526 |
527 void AppBannerSettingsHelper::UpdateFromFieldTrial() { | 527 void AppBannerSettingsHelper::UpdateFromFieldTrial() { |
528 UpdateEngagementWeights(); | 528 UpdateEngagementWeights(); |
529 UpdateMinutesBetweenVisits(); | 529 UpdateMinutesBetweenVisits(); |
530 } | 530 } |
OLD | NEW |