Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: chrome/browser/extensions/api/feedback_private/feedback_service_chromeos.cc

Issue 438963004: Avoid a segfault in FeedbackServiceImpl::GetUserEmail(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sprinkle some consts around Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" 5 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/chromeos/login/users/user_manager.h" 11 #include "chrome/browser/chromeos/login/users/user_manager.h"
12 #include "components/user_manager/user.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 15
15 class FeedbackServiceImpl 16 class FeedbackServiceImpl
16 : public FeedbackService, 17 : public FeedbackService,
17 public base::SupportsWeakPtr<FeedbackServiceImpl> { 18 public base::SupportsWeakPtr<FeedbackServiceImpl> {
18 public: 19 public:
19 FeedbackServiceImpl(); 20 FeedbackServiceImpl();
20 virtual ~FeedbackServiceImpl(); 21 virtual ~FeedbackServiceImpl();
21 22
(...skipping 11 matching lines...) Expand all
33 return new FeedbackServiceImpl; 34 return new FeedbackServiceImpl;
34 } 35 }
35 36
36 FeedbackServiceImpl::FeedbackServiceImpl() { 37 FeedbackServiceImpl::FeedbackServiceImpl() {
37 } 38 }
38 39
39 FeedbackServiceImpl::~FeedbackServiceImpl() { 40 FeedbackServiceImpl::~FeedbackServiceImpl() {
40 } 41 }
41 42
42 std::string FeedbackServiceImpl::GetUserEmail() { 43 std::string FeedbackServiceImpl::GetUserEmail() {
43 chromeos::UserManager* manager = chromeos::UserManager::Get(); 44 const chromeos::UserManager* manager = chromeos::UserManager::Get();
44 if (!manager) 45 const user_manager::User* user = manager ? manager->GetLoggedInUser() : NULL;
Daniel Erat 2014/08/01 20:38:19 should i also change this to call GetActiveUser()
45 return std::string(); 46 return user ? user->display_email() : std::string();
46 else
47 return manager->GetLoggedInUser()->display_email();
48 } 47 }
49 48
50 void FeedbackServiceImpl::GetHistograms(std::string* histograms) { 49 void FeedbackServiceImpl::GetHistograms(std::string* histograms) {
51 *histograms = base::StatisticsRecorder::ToJSON(std::string()); 50 *histograms = base::StatisticsRecorder::ToJSON(std::string());
52 } 51 }
53 52
54 base::WeakPtr<FeedbackService> FeedbackServiceImpl::GetWeakPtr() { 53 base::WeakPtr<FeedbackService> FeedbackServiceImpl::GetWeakPtr() {
55 return AsWeakPtr(); 54 return AsWeakPtr();
56 } 55 }
57 56
58 } // namespace extensions 57 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698