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

Side by Side Diff: chrome/browser/managed_mode/managed_mode_navigation_observer.cc

Issue 12033021: Add UMA metrics and histograms for locally managed users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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
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/managed_mode/managed_mode_navigation_observer.h" 5 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/metrics/histogram.h"
9 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
11 #include "chrome/browser/api/infobars/infobar_service.h" 12 #include "chrome/browser/api/infobars/infobar_service.h"
12 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" 13 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h"
13 #include "chrome/browser/managed_mode/managed_mode.h" 14 #include "chrome/browser/managed_mode/managed_mode.h"
14 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" 15 #include "chrome/browser/managed_mode/managed_mode_interstitial.h"
15 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" 16 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
16 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" 17 #include "chrome/browser/managed_mode/managed_mode_url_filter.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h" 21 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/jstemplate_builder.h" 25 #include "chrome/common/jstemplate_builder.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
29 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/user_metrics.h"
30 #include "content/public/browser/web_contents_delegate.h" 32 #include "content/public/browser/web_contents_delegate.h"
31 #include "content/public/common/frame_navigate_params.h" 33 #include "content/public/common/frame_navigate_params.h"
32 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
33 #include "grit/locale_settings.h" 35 #include "grit/locale_settings.h"
34 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
35 37
36 using content::BrowserThread; 38 using content::BrowserThread;
39 using content::UserMetricsAction;
37 40
38 namespace { 41 namespace {
39 42
43 // For use in histograms.
44 enum PreviewInfobarCommand {
45 INFOBAR_ACCEPT,
46 INFOBAR_CANCEL,
47 INFOBAR_HISTOGRAM_BOUNDING_VALUE
48 };
49
40 class ManagedModeWarningInfobarDelegate : public ConfirmInfoBarDelegate { 50 class ManagedModeWarningInfobarDelegate : public ConfirmInfoBarDelegate {
41 public: 51 public:
42 // Creates a managed mode warning delegate and adds it to |infobar_service|. 52 // Creates a managed mode warning delegate and adds it to |infobar_service|.
43 // Returns the delegate if it was successfully added. 53 // Returns the delegate if it was successfully added.
44 static InfoBarDelegate* Create(InfoBarService* infobar_service, 54 static InfoBarDelegate* Create(InfoBarService* infobar_service,
45 int last_allowed_page); 55 int last_allowed_page);
46 56
47 private: 57 private:
48 explicit ManagedModeWarningInfobarDelegate(InfoBarService* infobar_service, 58 explicit ManagedModeWarningInfobarDelegate(InfoBarService* infobar_service,
49 int last_allowed_page); 59 int last_allowed_page);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 InfoBarButton button) const { 202 InfoBarButton button) const {
193 return l10n_util::GetStringUTF16( 203 return l10n_util::GetStringUTF16(
194 (button == BUTTON_OK) ? IDS_MANAGED_MODE_PREVIEW_ACCEPT 204 (button == BUTTON_OK) ? IDS_MANAGED_MODE_PREVIEW_ACCEPT
195 : IDS_MANAGED_MODE_GO_BACK_ACTION); 205 : IDS_MANAGED_MODE_GO_BACK_ACTION);
196 } 206 }
197 207
198 bool ManagedModePreviewInfobarDelegate::Accept() { 208 bool ManagedModePreviewInfobarDelegate::Accept() {
199 ManagedModeNavigationObserver* observer = 209 ManagedModeNavigationObserver* observer =
200 ManagedModeNavigationObserver::FromWebContents( 210 ManagedModeNavigationObserver::FromWebContents(
201 owner()->GetWebContents()); 211 owner()->GetWebContents());
212 UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand",
213 INFOBAR_ACCEPT,
214 INFOBAR_HISTOGRAM_BOUNDING_VALUE);
202 observer->AddSavedURLsToWhitelistAndClearState(); 215 observer->AddSavedURLsToWhitelistAndClearState();
203 return true; 216 return true;
204 } 217 }
205 218
206 bool ManagedModePreviewInfobarDelegate::Cancel() { 219 bool ManagedModePreviewInfobarDelegate::Cancel() {
220 UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand",
221 INFOBAR_CANCEL,
222 INFOBAR_HISTOGRAM_BOUNDING_VALUE);
207 GoBackToSafety(owner()->GetWebContents()); 223 GoBackToSafety(owner()->GetWebContents());
208 return false; 224 return false;
209 } 225 }
210 226
211 bool ManagedModePreviewInfobarDelegate::ShouldExpire( 227 bool ManagedModePreviewInfobarDelegate::ShouldExpire(
212 const content::LoadCommittedDetails& details) const { 228 const content::LoadCommittedDetails& details) const {
213 // ManagedModeNavigationObserver removes us below. 229 // ManagedModeNavigationObserver removes us below.
214 return false; 230 return false;
215 } 231 }
216 232
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (web_contents()->GetController().GetCurrentEntryIndex() < 360 if (web_contents()->GetController().GetCurrentEntryIndex() <
345 last_allowed_page_ || !CanTemporarilyNavigateHost(url)) { 361 last_allowed_page_ || !CanTemporarilyNavigateHost(url)) {
346 ClearObserverState(); 362 ClearObserverState();
347 } 363 }
348 } 364 }
349 365
350 void ManagedModeNavigationObserver::DidNavigateMainFrame( 366 void ManagedModeNavigationObserver::DidNavigateMainFrame(
351 const content::LoadCommittedDetails& details, 367 const content::LoadCommittedDetails& details,
352 const content::FrameNavigateParams& params) { 368 const content::FrameNavigateParams& params) {
353 369
370 content::RecordAction(UserMetricsAction("ManagedMode_MainFrameNavigation"));
371
354 ManagedModeURLFilter::FilteringBehavior behavior = 372 ManagedModeURLFilter::FilteringBehavior behavior =
355 url_filter_->GetFilteringBehaviorForURL(params.url); 373 url_filter_->GetFilteringBehaviorForURL(params.url);
356 374
375 UMA_HISTOGRAM_ENUMERATION("ManagedMode.FilteringBehavior",
376 behavior,
377 ManagedModeURLFilter::HISTOGRAM_BOUNDING_VALUE);
378
357 // If the user just saw an interstitial this is the final URL so it is 379 // If the user just saw an interstitial this is the final URL so it is
358 // recorded. Checking for filtering behavior here isn't useful because 380 // recorded. Checking for filtering behavior here isn't useful because
359 // although this specific URL can be allowed the hostname will be added which 381 // although this specific URL can be allowed the hostname will be added which
360 // is more general. The hostname will be checked later when it is 382 // is more general. The hostname will be checked later when it is
361 // added to the actual whitelist to see if it is already present. 383 // added to the actual whitelist to see if it is already present.
362 if (behavior == ManagedModeURLFilter::BLOCK && state_ != NOT_RECORDING_URLS) 384 if (behavior == ManagedModeURLFilter::BLOCK && state_ != NOT_RECORDING_URLS)
363 AddURLAsLastPattern(params.url); 385 AddURLAsLastPattern(params.url);
364 386
365 if (behavior == ManagedModeURLFilter::ALLOW && 387 if (behavior == ManagedModeURLFilter::ALLOW &&
366 state_ != RECORDING_URLS_BEFORE_PREVIEW) { 388 state_ != RECORDING_URLS_BEFORE_PREVIEW) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 case NOT_RECORDING_URLS: 479 case NOT_RECORDING_URLS:
458 // Check that the infobar is present. 480 // Check that the infobar is present.
459 DCHECK(preview_infobar_delegate_); 481 DCHECK(preview_infobar_delegate_);
460 break; 482 break;
461 } 483 }
462 } 484 }
463 485
464 if (behavior == ManagedModeURLFilter::ALLOW) 486 if (behavior == ManagedModeURLFilter::ALLOW)
465 last_allowed_page_ = web_contents()->GetController().GetCurrentEntryIndex(); 487 last_allowed_page_ = web_contents()->GetController().GetCurrentEntryIndex();
466 } 488 }
OLDNEW
« no previous file with comments | « chrome/browser/managed_mode/managed_mode_interstitial.cc ('k') | chrome/browser/managed_mode/managed_mode_url_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698