OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" |
7 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" | 8 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" |
8 #include "chrome/browser/feedback/feedback_dialog_utils.h" | 9 #include "chrome/browser/feedback/feedback_dialog_utils.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/chrome_pages.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.h" | 14 #include "chrome/browser/ui/webui/md_feedback/md_feedback_dialog_controller.h" |
13 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
14 | 16 |
15 namespace chrome { | 17 namespace chrome { |
16 | 18 |
17 void ShowFeedbackPage(Browser* browser, | 19 void ShowFeedbackPage(Browser* browser, |
| 20 FeedbackSource source, |
18 const std::string& description_template, | 21 const std::string& description_template, |
19 const std::string& category_tag) { | 22 const std::string& category_tag) { |
20 GURL page_url; | 23 GURL page_url; |
21 if (browser) { | 24 if (browser) { |
22 page_url = GetTargetTabUrl(browser->session_id().id(), | 25 page_url = GetTargetTabUrl(browser->session_id().id(), |
23 browser->tab_strip_model()->active_index()); | 26 browser->tab_strip_model()->active_index()); |
24 } | 27 } |
25 | 28 |
26 Profile* profile = GetFeedbackProfile(browser); | 29 Profile* profile = GetFeedbackProfile(browser); |
27 if (!profile) { | 30 if (!profile) { |
28 LOG(ERROR) << "Cannot invoke feedback: No profile found!"; | 31 LOG(ERROR) << "Cannot invoke feedback: No profile found!"; |
29 return; | 32 return; |
30 } | 33 } |
31 | 34 |
| 35 // Record an UMA histogram to know the most frequent feedback request source. |
| 36 UMA_HISTOGRAM_ENUMERATION("Feedback.RequestSource", source, |
| 37 kFeedbackSourceCount); |
| 38 |
32 if (::switches::MdFeedbackEnabled()) { | 39 if (::switches::MdFeedbackEnabled()) { |
33 MdFeedbackDialogController::GetInstance()->Show(profile); | 40 MdFeedbackDialogController::GetInstance()->Show(profile); |
34 return; | 41 return; |
35 } | 42 } |
36 | 43 |
37 extensions::FeedbackPrivateAPI* api = | 44 extensions::FeedbackPrivateAPI* api = |
38 extensions::FeedbackPrivateAPI::GetFactoryInstance()->Get(profile); | 45 extensions::FeedbackPrivateAPI::GetFactoryInstance()->Get(profile); |
39 | 46 |
40 api->RequestFeedback(description_template, | 47 api->RequestFeedback(description_template, |
41 category_tag, | 48 category_tag, |
42 page_url); | 49 page_url); |
43 } | 50 } |
44 | 51 |
45 } // namespace chrome | 52 } // namespace chrome |
OLD | NEW |