OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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.h" |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 |
| 14 using extensions::api::feedback_private::SystemInformation; |
| 15 |
| 16 namespace extensions { |
| 17 |
| 18 class FeedbackServiceImpl |
| 19 : public FeedbackService, |
| 20 public base::SupportsWeakPtr<FeedbackServiceImpl> { |
| 21 public: |
| 22 FeedbackServiceImpl(); |
| 23 virtual ~FeedbackServiceImpl(); |
| 24 |
| 25 virtual std::string GetUserEmail() OVERRIDE; |
| 26 virtual void GetSystemInformation( |
| 27 const GetSystemInformationCallback& callback) OVERRIDE; |
| 28 |
| 29 private: |
| 30 // Overridden from FeedbackService: |
| 31 virtual base::WeakPtr<FeedbackService> GetWeakPtr() OVERRIDE; |
| 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(FeedbackServiceImpl); |
| 34 }; |
| 35 |
| 36 FeedbackService* FeedbackService::CreateInstance() { |
| 37 return new FeedbackServiceImpl; |
| 38 } |
| 39 |
| 40 FeedbackServiceImpl::FeedbackServiceImpl() { |
| 41 } |
| 42 |
| 43 FeedbackServiceImpl::~FeedbackServiceImpl() { |
| 44 } |
| 45 |
| 46 std::string FeedbackServiceImpl::GetUserEmail() { |
| 47 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 48 if (!profile) |
| 49 return std::string(); |
| 50 |
| 51 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); |
| 52 if (!signin) |
| 53 return std::string(); |
| 54 |
| 55 return signin->GetAuthenticatedUsername(); |
| 56 } |
| 57 |
| 58 void FeedbackServiceImpl::GetSystemInformation( |
| 59 const GetSystemInformationCallback& callback) { |
| 60 system_information_callback_ = callback; |
| 61 |
| 62 SystemInformationList sys_info_list; |
| 63 system_information_callback_.Run(sys_info_list); |
| 64 } |
| 65 |
| 66 base::WeakPtr<FeedbackService> FeedbackServiceImpl::GetWeakPtr() { |
| 67 return AsWeakPtr(); |
| 68 } |
| 69 |
| 70 } // namespace extensions |
OLD | NEW |