| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/android/ntp/content_suggestions_notifier_service.h" | 5 #include "chrome/browser/android/ntp/content_suggestions_notifier_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/android/application_status_listener.h" | 9 #include "base/android/application_status_listener.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "chrome/browser/android/ntp/content_suggestions_notification_helper.h" | 12 #include "chrome/browser/android/ntp/content_suggestions_notification_helper.h" |
| 13 #include "chrome/browser/notifications/notification.h" | 13 #include "chrome/browser/notifications/notification.h" |
| 14 #include "chrome/browser/notifications/notification_handler.h" | 14 #include "chrome/browser/notifications/notification_handler.h" |
| 15 #include "chrome/browser/ntp_snippets/ntp_snippets_features.h" | |
| 16 #include "chrome/browser/ntp_snippets/ntp_snippets_metrics.h" | 15 #include "chrome/browser/ntp_snippets/ntp_snippets_metrics.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 20 #include "components/ntp_snippets/content_suggestions_service.h" | 19 #include "components/ntp_snippets/content_suggestions_service.h" |
| 20 #include "components/ntp_snippets/features.h" |
| 21 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
| 22 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| 23 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
| 24 #include "components/variations/variations_associated_data.h" | 24 #include "components/variations/variations_associated_data.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 27 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
| 28 #include "ui/gfx/image/image_skia_operations.h" | 28 #include "ui/gfx/image/image_skia_operations.h" |
| 29 | 29 |
| 30 using ntp_snippets::Category; | 30 using ntp_snippets::Category; |
| 31 using ntp_snippets::CategoryStatus; | 31 using ntp_snippets::CategoryStatus; |
| 32 using ntp_snippets::ContentSuggestion; | 32 using ntp_snippets::ContentSuggestion; |
| 33 using ntp_snippets::ContentSuggestionsNotificationHelper; | 33 using ntp_snippets::ContentSuggestionsNotificationHelper; |
| 34 using ntp_snippets::ContentSuggestionsService; | 34 using ntp_snippets::ContentSuggestionsService; |
| 35 using ntp_snippets::KnownCategories; | 35 using ntp_snippets::KnownCategories; |
| 36 using params::ntp_snippets::kNotificationsDailyLimit; | 36 using ntp_snippets::kNotificationsDailyLimit; |
| 37 using params::ntp_snippets::kNotificationsDefaultDailyLimit; | 37 using ntp_snippets::kNotificationsDefaultDailyLimit; |
| 38 using params::ntp_snippets::kNotificationsDefaultPriority; | 38 using ntp_snippets::kNotificationsDefaultPriority; |
| 39 using params::ntp_snippets::kNotificationsFeature; | 39 using ntp_snippets::kNotificationsFeature; |
| 40 using params::ntp_snippets::kNotificationsKeepWhenFrontmostParam; | 40 using ntp_snippets::kNotificationsKeepWhenFrontmostParam; |
| 41 using params::ntp_snippets::kNotificationsOpenToNTPParam; | 41 using ntp_snippets::kNotificationsOpenToNTPParam; |
| 42 using params::ntp_snippets::kNotificationsPriorityParam; | 42 using ntp_snippets::kNotificationsPriorityParam; |
| 43 using params::ntp_snippets::kNotificationsTextParam; | 43 using ntp_snippets::kNotificationsTextParam; |
| 44 using params::ntp_snippets::kNotificationsTextValueAndMore; | 44 using ntp_snippets::kNotificationsTextValueAndMore; |
| 45 using params::ntp_snippets::kNotificationsTextValueSnippet; | 45 using ntp_snippets::kNotificationsTextValueSnippet; |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 const char kNotificationIDWithinCategory[] = | 49 const char kNotificationIDWithinCategory[] = |
| 50 "ContentSuggestionsNotificationIDWithinCategory"; | 50 "ContentSuggestionsNotificationIDWithinCategory"; |
| 51 | 51 |
| 52 gfx::Image CropSquare(const gfx::Image& image) { | 52 gfx::Image CropSquare(const gfx::Image& image) { |
| 53 if (image.IsEmpty()) { | 53 if (image.IsEmpty()) { |
| 54 return image; | 54 return image; |
| 55 } | 55 } |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 void ContentSuggestionsNotifierService::UpdateObserverRegistrationState() { | 287 void ContentSuggestionsNotifierService::UpdateObserverRegistrationState() { |
| 288 if (observer_ && !IsEnabled()) { | 288 if (observer_ && !IsEnabled()) { |
| 289 suggestions_service_->RemoveObserver(observer_.get()); | 289 suggestions_service_->RemoveObserver(observer_.get()); |
| 290 observer_.reset(); | 290 observer_.reset(); |
| 291 } else if (IsEnabled() && !observer_) { | 291 } else if (IsEnabled() && !observer_) { |
| 292 observer_.reset(new NotifyingObserver(suggestions_service_, profile_)); | 292 observer_.reset(new NotifyingObserver(suggestions_service_, profile_)); |
| 293 suggestions_service_->AddObserver(observer_.get()); | 293 suggestions_service_->AddObserver(observer_.get()); |
| 294 } | 294 } |
| 295 } | 295 } |
| OLD | NEW |