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

Side by Side Diff: chrome/browser/ui/views/network_profile_bubble.cc

Issue 10406005: Update UMA histograms as discussed with jar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed enum naming. Created 8 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/network_profile_bubble.h" 5 #include "chrome/browser/ui/views/network_profile_bubble.h"
6 6
7 #include <wtsapi32.h> 7 #include <wtsapi32.h>
8 // Make sure we link the wtsapi lib file in. 8 // Make sure we link the wtsapi lib file in.
9 #pragma comment(lib, "wtsapi32.lib") 9 #pragma comment(lib, "wtsapi32.lib")
10 10
(...skipping 24 matching lines...) Expand all
35 namespace { 35 namespace {
36 36
37 // The duration of the silent period before we start nagging the user again. 37 // The duration of the silent period before we start nagging the user again.
38 const int kSilenceDurationDays = 100; 38 const int kSilenceDurationDays = 100;
39 39
40 // Bubble layout constants. 40 // Bubble layout constants.
41 const int kAnchorVerticalInset = 5; 41 const int kAnchorVerticalInset = 5;
42 const int kInset = 2; 42 const int kInset = 2;
43 const int kNotificationBubbleWidth = 250; 43 const int kNotificationBubbleWidth = 250;
44 44
45 // The name of the UMA histogram collecting our stats.
46 const char kMetricNetworkedProfileCheck[] = "NetworkedProfile.Check";
47
48 enum MetricNetworkedProfileCheck {
49 // Check was suppressed by command line flag.
50 METRIC_CHECK_SUPPRESSED,
51 // WTSQuerySessionInformation call failed.
52 METRIC_CHECK_FAILED,
53 // File access in profile dir failed.
54 METRIC_CHECK_IO_FAILED,
55
56 // Profile on a network share detected.
57 METRIC_PROFILE_ON_NETWORK,
58 // Profile not on a network share detected.
59 METRIC_PROFILE_NOT_ON_NETWORK,
60
61 // Check was suppressed because of remote session.
62 METRIC_REMOTE_SESSION,
63
64 // User has clicked learn more on the notification bubble.
65 METRIC_LEARN_MORE_CLICKED,
66 // User has clicked OK on the notification bubble.
67 METRIC_ACKNOWLEDGED,
68
69 METRIC_NETWORKED_PROFILE_CHECK_SIZE // Must be the last.
70 };
71
45 // Implementation of BrowserList::Observer used to wait for a browser window. 72 // Implementation of BrowserList::Observer used to wait for a browser window.
46 class BrowserListObserver : public BrowserList::Observer { 73 class BrowserListObserver : public BrowserList::Observer {
47 private: 74 private:
48 virtual ~BrowserListObserver(); 75 virtual ~BrowserListObserver();
49 76
50 // Overridden from BrowserList::Observer: 77 // Overridden from BrowserList::Observer:
51 virtual void OnBrowserAdded(const Browser* browser) OVERRIDE; 78 virtual void OnBrowserAdded(const Browser* browser) OVERRIDE;
52 virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE; 79 virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE;
53 virtual void OnBrowserSetLastActive(const Browser* browser) OVERRIDE; 80 virtual void OnBrowserSetLastActive(const Browser* browser) OVERRIDE;
54 }; 81 };
(...skipping 29 matching lines...) Expand all
84 // share as we don't officially support this setup yet. 111 // share as we don't officially support this setup yet.
85 // However we don't want to bother users on Cytrix setups as those have no 112 // However we don't want to bother users on Cytrix setups as those have no
86 // real choice and their admins must be well aware of the risks associated. 113 // real choice and their admins must be well aware of the risks associated.
87 // Also the command line flag --no-network-profile-warning can stop this 114 // Also the command line flag --no-network-profile-warning can stop this
88 // warning from popping up. In this case we can skip the check to make the 115 // warning from popping up. In this case we can skip the check to make the
89 // start faster. 116 // start faster.
90 // Collect a lot of stats along the way to see which cases do occur in the 117 // Collect a lot of stats along the way to see which cases do occur in the
91 // wild often enough. 118 // wild often enough.
92 if (CommandLine::ForCurrentProcess()->HasSwitch( 119 if (CommandLine::ForCurrentProcess()->HasSwitch(
93 switches::kNoNetworkProfileWarning)) { 120 switches::kNoNetworkProfileWarning)) {
94 UMA_HISTOGRAM_COUNTS("NetworkedProfile.CheckSuppressed", 1); 121 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
jar (doing other things) 2012/05/16 16:57:43 nit: Not a big deal.... but when you have to repea
pastarmovj 2012/05/18 09:48:52 Done.
122 METRIC_CHECK_SUPPRESSED,
123 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
95 return; 124 return;
96 } 125 }
97 126
98 LPWSTR buffer = NULL; 127 LPWSTR buffer = NULL;
99 DWORD buffer_length = 0; 128 DWORD buffer_length = 0;
100 // Checking for RDP is cheaper than checking for a network drive so do this 129 // Checking for RDP is cheaper than checking for a network drive so do this
101 // one first. 130 // one first.
102 if (!WTSQuerySessionInformation(WTS_CURRENT_SERVER, WTS_CURRENT_SESSION, 131 if (!WTSQuerySessionInformation(WTS_CURRENT_SERVER, WTS_CURRENT_SESSION,
103 WTSClientProtocolType, 132 WTSClientProtocolType,
104 &buffer, &buffer_length)) { 133 &buffer, &buffer_length)) {
105 UMA_HISTOGRAM_COUNTS("NetworkedProfile.CheckFailed", 1); 134 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
135 METRIC_CHECK_FAILED,
136 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
106 return; 137 return;
107 } 138 }
108 139
109 unsigned short* type = reinterpret_cast<unsigned short*>(buffer); 140 unsigned short* type = reinterpret_cast<unsigned short*>(buffer);
110 // Zero means local session and we should warn the users if they have 141 // Zero means local session and we should warn the users if they have
111 // their profile on a network share. 142 // their profile on a network share.
112 if (*type == 0) { 143 if (*type == 0) {
113 bool profile_on_network = false; 144 bool profile_on_network = false;
114 if (!profile_path.empty()) { 145 if (!profile_path.empty()) {
115 FilePath temp_file; 146 FilePath temp_file;
116 // Try to create some non-empty temp file in the profile dir and use 147 // Try to create some non-empty temp file in the profile dir and use
117 // it to check if there is a reparse-point free path to it. 148 // it to check if there is a reparse-point free path to it.
118 if (file_util::CreateTemporaryFileInDir(profile_path, &temp_file) && 149 if (file_util::CreateTemporaryFileInDir(profile_path, &temp_file) &&
119 file_util::WriteFile(temp_file, ".", 1)) { 150 file_util::WriteFile(temp_file, ".", 1)) {
120 FilePath normalized_temp_file; 151 FilePath normalized_temp_file;
121 if (!file_util::NormalizeFilePath(temp_file, &normalized_temp_file)) 152 if (!file_util::NormalizeFilePath(temp_file, &normalized_temp_file))
122 profile_on_network = true; 153 profile_on_network = true;
123 } else { 154 } else {
124 UMA_HISTOGRAM_COUNTS("NetworkedProfile.CheckIOFailed", 1); 155 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
156 METRIC_CHECK_IO_FAILED,
157 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
125 } 158 }
126 file_util::Delete(temp_file, false); 159 file_util::Delete(temp_file, false);
127 } 160 }
128 if (profile_on_network) { 161 if (profile_on_network) {
129 UMA_HISTOGRAM_COUNTS("NetworkedProfile.ProfileOnNetwork", 1); 162 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
163 METRIC_PROFILE_ON_NETWORK,
164 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
130 content::BrowserThread::PostTask( 165 content::BrowserThread::PostTask(
131 content::BrowserThread::UI, FROM_HERE, 166 content::BrowserThread::UI, FROM_HERE,
132 base::Bind(&NetworkProfileBubble::NotifyNetworkProfileDetected)); 167 base::Bind(&NetworkProfileBubble::NotifyNetworkProfileDetected));
133 } else { 168 } else {
134 UMA_HISTOGRAM_COUNTS("NetworkedProfile.ProfileNotOnNetwork", 1); 169 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
170 METRIC_PROFILE_NOT_ON_NETWORK,
171 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
135 } 172 }
136 } else { 173 } else {
137 UMA_HISTOGRAM_COUNTS("NetworkedProfile.RemoteSession", 1); 174 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
175 METRIC_REMOTE_SESSION,
176 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
138 } 177 }
139 178
140 WTSFreeMemory(buffer); 179 WTSFreeMemory(buffer);
141 } 180 }
142 181
143 // static 182 // static
144 bool NetworkProfileBubble::ShouldCheckNetworkProfile(PrefService* prefs) { 183 bool NetworkProfileBubble::ShouldCheckNetworkProfile(PrefService* prefs) {
145 if (prefs->GetInteger(prefs::kNetworkProfileWarningsLeft)) 184 if (prefs->GetInteger(prefs::kNetworkProfileWarningsLeft))
146 return !notification_shown_; 185 return !notification_shown_;
147 int64 last_check = prefs->GetInt64(prefs::kNetworkProfileLastWarningTime); 186 int64 last_check = prefs->GetInt64(prefs::kNetworkProfileLastWarningTime);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 265 }
227 266
228 gfx::Rect NetworkProfileBubble::GetAnchorRect() { 267 gfx::Rect NetworkProfileBubble::GetAnchorRect() {
229 // Compensate for padding in anchor. 268 // Compensate for padding in anchor.
230 gfx::Rect rect(BubbleDelegateView::GetAnchorRect()); 269 gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
231 rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0); 270 rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0);
232 return rect; 271 return rect;
233 } 272 }
234 273
235 void NetworkProfileBubble::LinkClicked(views::Link* source, int event_flags) { 274 void NetworkProfileBubble::LinkClicked(views::Link* source, int event_flags) {
236 UMA_HISTOGRAM_COUNTS("NetworkedProfile.LearnMoreClicked", 1); 275 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
276 METRIC_LEARN_MORE_CLICKED,
277 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
237 Browser* browser = BrowserList::GetLastActive(); 278 Browser* browser = BrowserList::GetLastActive();
238 if (browser) { 279 if (browser) {
239 WindowOpenDisposition disposition = 280 WindowOpenDisposition disposition =
240 event_utils::DispositionFromEventFlags(event_flags); 281 event_utils::DispositionFromEventFlags(event_flags);
241 content::OpenURLParams params( 282 content::OpenURLParams params(
242 GURL("https://sites.google.com/a/chromium.org/dev/administrators/" 283 GURL("https://sites.google.com/a/chromium.org/dev/administrators/"
243 "common-problems-and-solutions#network_profile"), 284 "common-problems-and-solutions#network_profile"),
244 content::Referrer(), 285 content::Referrer(),
245 disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition, 286 disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition,
246 content::PAGE_TRANSITION_LINK, false); 287 content::PAGE_TRANSITION_LINK, false);
247 browser->OpenURL(params); 288 browser->OpenURL(params);
248 // If the user interacted with the bubble we don't reduce the number of 289 // If the user interacted with the bubble we don't reduce the number of
249 // warnings left. 290 // warnings left.
250 PrefService* prefs = browser->profile()->GetPrefs(); 291 PrefService* prefs = browser->profile()->GetPrefs();
251 int left_warnings = prefs->GetInteger(prefs::kNetworkProfileWarningsLeft); 292 int left_warnings = prefs->GetInteger(prefs::kNetworkProfileWarningsLeft);
252 prefs->SetInteger(prefs::kNetworkProfileWarningsLeft, ++left_warnings); 293 prefs->SetInteger(prefs::kNetworkProfileWarningsLeft, ++left_warnings);
253 } 294 }
254 GetWidget()->Close(); 295 GetWidget()->Close();
255 } 296 }
256 297
257 void NetworkProfileBubble::ButtonPressed(views::Button* sender, 298 void NetworkProfileBubble::ButtonPressed(views::Button* sender,
258 const views::Event& event) { 299 const views::Event& event) {
259 UMA_HISTOGRAM_COUNTS("NetworkedProfile.Acknowledged", 1); 300 UMA_HISTOGRAM_ENUMERATION(kMetricNetworkedProfileCheck,
301 METRIC_ACKNOWLEDGED,
302 METRIC_NETWORKED_PROFILE_CHECK_SIZE);
260 303
261 GetWidget()->Close(); 304 GetWidget()->Close();
262 } 305 }
263 306
264 // static 307 // static
265 void NetworkProfileBubble::NotifyNetworkProfileDetected() { 308 void NetworkProfileBubble::NotifyNetworkProfileDetected() {
266 if (BrowserList::GetLastActive() != NULL) 309 if (BrowserList::GetLastActive() != NULL)
267 ShowNotification(BrowserList::GetLastActive()); 310 ShowNotification(BrowserList::GetLastActive());
268 else 311 else
269 BrowserList::AddObserver(new BrowserListObserver()); 312 BrowserList::AddObserver(new BrowserListObserver());
270 } 313 }
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