OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/javascript_dialogs/javascript_dialog_tab_helper.h" | 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" |
6 | 6 |
7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "chrome/browser/engagement/site_engagement_service.h" | 9 #include "chrome/browser/engagement/site_engagement_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const base::string16& default_prompt_text, | 46 const base::string16& default_prompt_text, |
47 const DialogClosedCallback& callback, | 47 const DialogClosedCallback& callback, |
48 bool* did_suppress_message) { | 48 bool* did_suppress_message) { |
49 SiteEngagementService* site_engagement_service = SiteEngagementService::Get( | 49 SiteEngagementService* site_engagement_service = SiteEngagementService::Get( |
50 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | 50 Profile::FromBrowserContext(web_contents->GetBrowserContext())); |
51 double engagement_score = site_engagement_service->GetScore(origin_url); | 51 double engagement_score = site_engagement_service->GetScore(origin_url); |
52 UMA_HISTOGRAM_PERCENTAGE("JSDialogs.SiteEngagementOfDialogs", | 52 UMA_HISTOGRAM_PERCENTAGE("JSDialogs.SiteEngagementOfDialogs", |
53 engagement_score); | 53 engagement_score); |
54 int32_t message_length = static_cast<int32_t>(message_text.length()); | 54 int32_t message_length = static_cast<int32_t>(message_text.length()); |
55 if (engagement_score == 0) { | 55 if (engagement_score == 0) { |
56 UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfCharacters.EngagementNone", | 56 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementNone", |
57 message_length); | 57 message_length); |
58 } else if (engagement_score < 1) { | 58 } else if (engagement_score < 1) { |
59 UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfCharacters.EngagementLessThanOne", | 59 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementLessThanOne", |
60 message_length); | 60 message_length); |
61 } else if (engagement_score < 5) { | 61 } else if (engagement_score < 5) { |
62 UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfCharacters.EngagementOneToFive", | 62 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementOneToFive", |
63 message_length); | 63 message_length); |
64 } else { | 64 } else { |
65 UMA_HISTOGRAM_COUNTS("JSDialogs.CountOfCharacters.EngagementHigher", | 65 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.EngagementHigher", |
66 message_length); | 66 message_length); |
67 } | 67 } |
68 | 68 |
69 if (IsEnabled()) { | 69 if (IsEnabled()) { |
70 NOTREACHED() << "auto-dismissing dialog code does not yet exist"; | 70 NOTREACHED() << "auto-dismissing dialog code does not yet exist"; |
71 } else { | 71 } else { |
72 AppModalDialogManager()->RunJavaScriptDialog( | 72 AppModalDialogManager()->RunJavaScriptDialog( |
73 web_contents, origin_url, message_type, message_text, | 73 web_contents, origin_url, message_type, message_text, |
74 default_prompt_text, callback, did_suppress_message); | 74 default_prompt_text, callback, did_suppress_message); |
75 } | 75 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 void JavaScriptDialogTabHelper::ResetDialogState( | 126 void JavaScriptDialogTabHelper::ResetDialogState( |
127 content::WebContents* web_contents) { | 127 content::WebContents* web_contents) { |
128 // Reset any app-modal dialog state that may exist. | 128 // Reset any app-modal dialog state that may exist. |
129 if (!IsEnabled()) | 129 if (!IsEnabled()) |
130 return AppModalDialogManager()->ResetDialogState(web_contents); | 130 return AppModalDialogManager()->ResetDialogState(web_contents); |
131 | 131 |
132 // More work here for the auto-dismissing dialogs. | 132 // More work here for the auto-dismissing dialogs. |
133 } | 133 } |
OLD | NEW |