| 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 : public FeedbackService { |
| 19 public: |
| 20 FeedbackServiceImpl(); |
| 21 virtual ~FeedbackServiceImpl(); |
| 22 |
| 23 virtual std::string GetUserEmail() OVERRIDE; |
| 24 virtual void GetSystemInformation( |
| 25 const GetSystemInformationCallback& callback) OVERRIDE; |
| 26 |
| 27 private: |
| 28 // Overridden from FeedbackService: |
| 29 virtual base::WeakPtr<FeedbackService> GetWeakPtr() OVERRIDE; |
| 30 |
| 31 base::WeakPtrFactory<FeedbackServiceImpl> weak_ptr_factory_; |
| 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(FeedbackServiceImpl); |
| 34 }; |
| 35 |
| 36 FeedbackService* FeedbackService::CreateInstance() { |
| 37 return new FeedbackServiceImpl; |
| 38 } |
| 39 |
| 40 FeedbackServiceImpl::FeedbackServiceImpl() : weak_ptr_factory_(this) { |
| 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 weak_ptr_factory_.GetWeakPtr(); |
| 68 } |
| 69 |
| 70 } // namespace extensions |
| OLD | NEW |