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

Side by Side Diff: ios/chrome/browser/metrics/new_tab_page_uma.mm

Issue 2819903002: Remove usage of Tab's |url| property from NewTabPageUMA utilities. (Closed)
Patch Set: lastCommitted => visible Created 3 years, 8 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
« 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 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 #import "ios/chrome/browser/metrics/new_tab_page_uma.h" 5 #import "ios/chrome/browser/metrics/new_tab_page_uma.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "components/google/core/browser/google_util.h" 8 #include "components/google/core/browser/google_util.h"
9 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 9 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
10 #include "ios/chrome/browser/chrome_url_constants.h" 10 #include "ios/chrome/browser/chrome_url_constants.h"
11 #import "ios/chrome/browser/tabs/tab.h" 11 #import "ios/chrome/browser/tabs/tab.h"
12 #import "ios/chrome/browser/tabs/tab_model.h" 12 #import "ios/chrome/browser/tabs/tab_model.h"
13 #import "ios/chrome/browser/tabs/tab_model_list.h" 13 #import "ios/chrome/browser/tabs/tab_model_list.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace new_tab_page_uma { 16 namespace new_tab_page_uma {
17 17
18 bool IsCurrentlyOnNTP(ios::ChromeBrowserState* browserState) { 18 bool IsCurrentlyOnNTP(ios::ChromeBrowserState* browser_state) {
19 TabModel* tabModel = GetLastActiveTabModelForChromeBrowserState(browserState); 19 TabModel* tab_model =
20 return tabModel.currentTab && 20 GetLastActiveTabModelForChromeBrowserState(browser_state);
21 tabModel.currentTab.url == GURL(kChromeUINewTabURL); 21 return tab_model.currentTab &&
22 tab_model.currentTab.visibleURL == GURL(kChromeUINewTabURL);
kkhorimoto 2017/04/14 20:34:33 The old behavior would return a non-NTP URL if the
Eugene But (OOO till 7-30) 2017/04/14 21:43:02 Should this be lastCommittedURL? I think that old
kkhorimoto 2017/05/31 22:58:33 For user-initiated loads, the web view will be sho
22 } 23 }
23 24
24 void RecordAction(ios::ChromeBrowserState* browserState, ActionType type) { 25 void RecordAction(ios::ChromeBrowserState* browserState, ActionType type) {
25 DCHECK(browserState); 26 DCHECK(browserState);
26 if (!IsCurrentlyOnNTP(browserState) || browserState->IsOffTheRecord()) 27 if (!IsCurrentlyOnNTP(browserState) || browserState->IsOffTheRecord())
27 return; 28 return;
28 base::HistogramBase* counter = base::Histogram::FactoryGet( 29 base::HistogramBase* counter = base::Histogram::FactoryGet(
29 "NewTabPage.ActioniOS", 0, NUM_ACTION_TYPES, NUM_ACTION_TYPES + 1, 30 "NewTabPage.ActioniOS", 0, NUM_ACTION_TYPES, NUM_ACTION_TYPES + 1,
30 base::HistogramBase::kUmaTargetedHistogramFlag); 31 base::HistogramBase::kUmaTargetedHistogramFlag);
31 counter->Add(type); 32 counter->Add(type);
32 } 33 }
33 34
34 void RecordActionFromOmnibox(ios::ChromeBrowserState* browserState, 35 void RecordActionFromOmnibox(ios::ChromeBrowserState* browserState,
35 const GURL& url, 36 const GURL& url,
36 ui::PageTransition transition) { 37 ui::PageTransition transition) {
37 ui::PageTransition coreTransition = static_cast<ui::PageTransition>( 38 ui::PageTransition coreTransition = static_cast<ui::PageTransition>(
38 transition & ui::PAGE_TRANSITION_CORE_MASK); 39 transition & ui::PAGE_TRANSITION_CORE_MASK);
39 if (PageTransitionCoreTypeIs(coreTransition, ui::PAGE_TRANSITION_GENERATED)) { 40 if (PageTransitionCoreTypeIs(coreTransition, ui::PAGE_TRANSITION_GENERATED)) {
40 RecordAction(browserState, ACTION_SEARCHED_USING_OMNIBOX); 41 RecordAction(browserState, ACTION_SEARCHED_USING_OMNIBOX);
41 } else { 42 } else {
42 if (google_util::IsGoogleHomePageUrl(GURL(url))) { 43 if (google_util::IsGoogleHomePageUrl(GURL(url))) {
43 RecordAction(browserState, ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE); 44 RecordAction(browserState, ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE);
44 } else { 45 } else {
45 RecordAction(browserState, ACTION_NAVIGATED_USING_OMNIBOX); 46 RecordAction(browserState, ACTION_NAVIGATED_USING_OMNIBOX);
46 } 47 }
47 } 48 }
48 } 49 }
49 } 50 }
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