1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h"
7 #include "base/callback.h"
8 #include "base/memory/weak_ptr.h"
9 #include "base/metrics/statistics_recorder.h"
10 #include "base/values.h"
11 #include "components/user_manager/user.h"
12 #include "components/user_manager/user_manager.h"
14 namespace extensions
{
16 class FeedbackServiceImpl
17 : public FeedbackService
,
18 public base::SupportsWeakPtr
<FeedbackServiceImpl
> {
20 FeedbackServiceImpl();
21 ~FeedbackServiceImpl() override
;
23 std::string
GetUserEmail() override
;
24 void GetHistograms(std::string
* histograms
) override
;
27 // Overridden from FeedbackService:
28 base::WeakPtr
<FeedbackService
> GetWeakPtr() override
;
30 DISALLOW_COPY_AND_ASSIGN(FeedbackServiceImpl
);
33 FeedbackService
* FeedbackService::CreateInstance() {
34 return new FeedbackServiceImpl
;
37 FeedbackServiceImpl::FeedbackServiceImpl() {
40 FeedbackServiceImpl::~FeedbackServiceImpl() {
43 std::string
FeedbackServiceImpl::GetUserEmail() {
44 const user_manager::UserManager
* manager
= user_manager::UserManager::Get();
45 const user_manager::User
* user
= manager
? manager
->GetActiveUser() : NULL
;
46 return user
? user
->display_email() : std::string();
49 void FeedbackServiceImpl::GetHistograms(std::string
* histograms
) {
50 *histograms
= base::StatisticsRecorder::ToJSON(std::string());
53 base::WeakPtr
<FeedbackService
> FeedbackServiceImpl::GetWeakPtr() {
57 } // namespace extensions