Revert 285173 "Removed InProcessBrowserTest::CleanUpOnMainThread()"
[chromium-blink-merge.git] / chrome / browser / extensions / api / feedback_private / feedback_service_nonchromeos.cc
blob72f8e94239d61650bedeb7c50e02872c5969b2d1
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 "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/browser/signin/signin_manager_factory.h"
12 #include "components/signin/core/browser/signin_manager.h"
14 namespace extensions {
16 class FeedbackServiceImpl
17 : public FeedbackService,
18 public base::SupportsWeakPtr<FeedbackServiceImpl> {
19 public:
20 FeedbackServiceImpl();
21 virtual ~FeedbackServiceImpl();
23 virtual std::string GetUserEmail() OVERRIDE;
24 virtual void GetHistograms(std::string* histograms) OVERRIDE;
26 private:
27 // Overridden from FeedbackService:
28 virtual 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 Profile* profile = ProfileManager::GetLastUsedProfile();
45 if (!profile)
46 return std::string();
48 SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
49 if (!signin)
50 return std::string();
52 return signin->GetAuthenticatedUsername();
55 void FeedbackServiceImpl::GetHistograms(std::string* histograms) {
58 base::WeakPtr<FeedbackService> FeedbackServiceImpl::GetWeakPtr() {
59 return AsWeakPtr();
62 } // namespace extensions