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. 4 5 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" 6 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" 13 14 namespace extensions { 15 16 class FeedbackServiceImpl 17 : public FeedbackService, 18 public base::SupportsWeakPtr<FeedbackServiceImpl> { 19 public: 20 FeedbackServiceImpl(); 21 virtual ~FeedbackServiceImpl(); 22 23 virtual std::string GetUserEmail() OVERRIDE; 24 virtual void GetHistograms(std::string* histograms) OVERRIDE; 25 26 private: 27 // Overridden from FeedbackService: 28 virtual base::WeakPtr<FeedbackService> GetWeakPtr() OVERRIDE; 29 30 DISALLOW_COPY_AND_ASSIGN(FeedbackServiceImpl); 31 }; 32 33 FeedbackService* FeedbackService::CreateInstance() { 34 return new FeedbackServiceImpl; 35 } 36 37 FeedbackServiceImpl::FeedbackServiceImpl() { 38 } 39 40 FeedbackServiceImpl::~FeedbackServiceImpl() { 41 } 42 43 std::string FeedbackServiceImpl::GetUserEmail() { 44 Profile* profile = ProfileManager::GetLastUsedProfile(); 45 if (!profile) 46 return std::string(); 47 48 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); 49 if (!signin) 50 return std::string(); 51 52 return signin->GetAuthenticatedUsername(); 53 } 54 55 void FeedbackServiceImpl::GetHistograms(std::string* histograms) { 56 } 57 58 base::WeakPtr<FeedbackService> FeedbackServiceImpl::GetWeakPtr() { 59 return AsWeakPtr(); 60 } 61 62 } // namespace extensions 63