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

Side by Side Diff: chrome/browser/chromeos/hats/hats_notification_controller.cc

Issue 2170113002: Adds a notification origin URL to solve minor bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds a notification origin URL to solve minor bug Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chromeos/hats/hats_notification_controller.h" 5 #include "chrome/browser/chromeos/hats/hats_notification_controller.h"
6 6
7 #include "ash/common/system/system_notifier.h" 7 #include "ash/common/system/system_notifier.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/hats/hats_dialog.h" 10 #include "chrome/browser/chromeos/hats/hats_dialog.h"
(...skipping 10 matching lines...) Expand all
21 #include "grit/ash_strings.h" 21 #include "grit/ash_strings.h"
22 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/message_center/message_center.h" 25 #include "ui/message_center/message_center.h"
26 #include "ui/message_center/notification_types.h" 26 #include "ui/message_center/notification_types.h"
27 #include "ui/strings/grit/ui_strings.h" 27 #include "ui/strings/grit/ui_strings.h"
28 28
29 namespace { 29 namespace {
30 30
31 const char kNotificationOriginUrl[] = "chrome://hats";
32
31 // Returns true if the given |profile| interacted with HaTS by either 33 // Returns true if the given |profile| interacted with HaTS by either
32 // dismissing the notification or taking the survey within a given threshold 34 // dismissing the notification or taking the survey within a given threshold
33 // days |threshold_days|. 35 // days |threshold_days|.
34 bool DidShowSurveyToProfileRecently(Profile* profile, int threshold_days) { 36 bool DidShowSurveyToProfileRecently(Profile* profile, int threshold_days) {
35 int64_t serialized_timestamp = 37 int64_t serialized_timestamp =
36 profile->GetPrefs()->GetInt64(prefs::kHatsLastInteractionTimestamp); 38 profile->GetPrefs()->GetInt64(prefs::kHatsLastInteractionTimestamp);
37 39
38 base::Time previous_interaction_timestamp = 40 base::Time previous_interaction_timestamp =
39 base::Time::FromInternalValue(serialized_timestamp); 41 base::Time::FromInternalValue(serialized_timestamp);
40 return (previous_interaction_timestamp + 42 return (previous_interaction_timestamp +
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 UpdateLastInteractionTime(); 91 UpdateLastInteractionTime();
90 return; 92 return;
91 } 93 }
92 94
93 // Add self as an observer to be notified when an internet connection is 95 // Add self as an observer to be notified when an internet connection is
94 // available. 96 // available.
95 network_portal_detector::GetInstance()->AddAndFireObserver(this); 97 network_portal_detector::GetInstance()->AddAndFireObserver(this);
96 } 98 }
97 99
98 // static 100 // static
99 // TODO(malaykeshav): Add check for @google accounts.
100 bool HatsNotificationController::ShouldShowSurveyToProfile(Profile* profile) { 101 bool HatsNotificationController::ShouldShowSurveyToProfile(Profile* profile) {
101 // Do not show the survey if the HaTS feature is disabled for the device. This 102 // Do not show the survey if the HaTS feature is disabled for the device. This
102 // flag is controlled by finch and is enabled only when the device has been 103 // flag is controlled by finch and is enabled only when the device has been
103 // selected for the survey. 104 // selected for the survey.
104 if (!base::FeatureList::IsEnabled(features::kHappininessTrackingSystem)) 105 if (!base::FeatureList::IsEnabled(features::kHappininessTrackingSystem))
105 return false; 106 return false;
106 107
107 // Do not show survey if this is a guest session. 108 // Do not show survey if this is a guest session.
108 if (profile->IsGuestSession()) 109 if (profile->IsGuestSession())
109 return false; 110 return false;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return new Notification( 179 return new Notification(
179 message_center::NOTIFICATION_TYPE_SIMPLE, 180 message_center::NOTIFICATION_TYPE_SIMPLE,
180 l10n_util::GetStringUTF16(IDS_ASH_HATS_NOTIFICATION_TITLE), 181 l10n_util::GetStringUTF16(IDS_ASH_HATS_NOTIFICATION_TITLE),
181 l10n_util::GetStringUTF16(IDS_ASH_HATS_NOTIFICATION_BODY), 182 l10n_util::GetStringUTF16(IDS_ASH_HATS_NOTIFICATION_BODY),
182 // TODO(malaykeshav): Change this to actual HaTS icon. 183 // TODO(malaykeshav): Change this to actual HaTS icon.
183 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 184 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
184 IDR_SCREENSHOT_NOTIFICATION_ICON), 185 IDR_SCREENSHOT_NOTIFICATION_ICON),
185 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, 186 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
186 ash::system_notifier::kNotifierHats), 187 ash::system_notifier::kNotifierHats),
187 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_HATS_NAME), 188 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_HATS_NAME),
188 GURL() /* Send an empty invalid url */, kNotificationId, optional, this); 189 GURL(kNotificationOriginUrl), kNotificationId, optional, this);
189 } 190 }
190 191
191 void HatsNotificationController::UpdateLastInteractionTime() { 192 void HatsNotificationController::UpdateLastInteractionTime() {
192 PrefService* pref_service = profile_->GetPrefs(); 193 PrefService* pref_service = profile_->GetPrefs();
193 pref_service->SetInt64(prefs::kHatsLastInteractionTimestamp, 194 pref_service->SetInt64(prefs::kHatsLastInteractionTimestamp,
194 base::Time::Now().ToInternalValue()); 195 base::Time::Now().ToInternalValue());
195 } 196 }
196 197
197 } // namespace chromeos 198 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698