OLD | NEW |
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_private_api.h" | 5 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 service_ = NULL; | 44 service_ = NULL; |
45 } | 45 } |
46 | 46 |
47 FeedbackService* FeedbackPrivateAPI::GetService() const { | 47 FeedbackService* FeedbackPrivateAPI::GetService() const { |
48 return service_; | 48 return service_; |
49 } | 49 } |
50 | 50 |
51 void FeedbackPrivateAPI::RequestFeedback( | 51 void FeedbackPrivateAPI::RequestFeedback( |
52 const std::string& description_template, | 52 const std::string& description_template, |
53 const std::string& category_tag, | 53 const std::string& category_tag, |
54 const GURL& page_url, | 54 const GURL& page_url) { |
55 const gfx::Rect& screen_size) { | |
56 if (profile_ && ExtensionSystem::Get(profile_)->event_router()) { | 55 if (profile_ && ExtensionSystem::Get(profile_)->event_router()) { |
57 FeedbackInfo info; | 56 FeedbackInfo info; |
58 info.description = description_template; | 57 info.description = description_template; |
59 info.category_tag = make_scoped_ptr(new std::string(category_tag)); | 58 info.category_tag = make_scoped_ptr(new std::string(category_tag)); |
60 info.page_url = make_scoped_ptr(new std::string(page_url.spec())); | 59 info.page_url = make_scoped_ptr(new std::string(page_url.spec())); |
61 info.system_information.reset(new SystemInformationList); | 60 info.system_information.reset(new SystemInformationList); |
62 // The manager is only available if tracing is enabled. | 61 // The manager is only available if tracing is enabled. |
63 if (TracingManager* manager = TracingManager::Get()) { | 62 if (TracingManager* manager = TracingManager::Get()) { |
64 info.trace_id.reset(new int(manager->RequestTrace())); | 63 info.trace_id.reset(new int(manager->RequestTrace())); |
65 } | 64 } |
66 | 65 |
67 FeedbackService::PopulateSystemInfo( | |
68 info.system_information.get(), FeedbackData::kScreensizeHeightKey, | |
69 base::IntToString(screen_size.height())); | |
70 FeedbackService::PopulateSystemInfo( | |
71 info.system_information.get(), FeedbackData::kScreensizeWidthKey, | |
72 base::IntToString(screen_size.width())); | |
73 | |
74 scoped_ptr<base::ListValue> args(new base::ListValue()); | 66 scoped_ptr<base::ListValue> args(new base::ListValue()); |
75 args->Append(info.ToValue().release()); | 67 args->Append(info.ToValue().release()); |
76 | 68 |
77 scoped_ptr<Event> event(new Event( | 69 scoped_ptr<Event> event(new Event( |
78 feedback_private::OnFeedbackRequested::kEventName, args.Pass())); | 70 feedback_private::OnFeedbackRequested::kEventName, args.Pass())); |
79 ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent( | 71 ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent( |
80 event.Pass()); | 72 event.Pass()); |
81 } | 73 } |
82 } | 74 } |
83 | 75 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 191 |
200 void FeedbackPrivateSendFeedbackFunction::OnCompleted( | 192 void FeedbackPrivateSendFeedbackFunction::OnCompleted( |
201 bool success) { | 193 bool success) { |
202 results_ = feedback_private::SendFeedback::Results::Create( | 194 results_ = feedback_private::SendFeedback::Results::Create( |
203 success ? feedback_private::STATUS_SUCCESS : | 195 success ? feedback_private::STATUS_SUCCESS : |
204 feedback_private::STATUS_DELAYED); | 196 feedback_private::STATUS_DELAYED); |
205 SendResponse(true); | 197 SendResponse(true); |
206 } | 198 } |
207 | 199 |
208 } // namespace extensions | 200 } // namespace extensions |
OLD | NEW |