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: ios/chrome/browser/metrics/new_tab_page_uma.mm

Issue 2615003002: Use ChromeBrowserStateManager instead of BrowserListIOS. (Closed)
Patch Set: Fix ios_chrome_perftests. Created 3 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
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.h" 7 #include "base/metrics/histogram.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/ui/browser_list_ios.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* browserState) {
19 Tab* currentTab = 19 TabModel* tabModel = GetLastActiveTabModelForChromeBrowserState(browserState);
20 [[BrowserListIOS::GetLastActiveWithBrowserState(browserState) tabModel] 20 return tabModel.currentTab &&
21 currentTab]; 21 tabModel.currentTab.url == GURL(kChromeUINewTabURL);
22 return currentTab && currentTab.url == GURL(kChromeUINewTabURL);
23 } 22 }
24 23
25 void RecordAction(ios::ChromeBrowserState* browserState, ActionType type) { 24 void RecordAction(ios::ChromeBrowserState* browserState, ActionType type) {
26 DCHECK(browserState); 25 DCHECK(browserState);
27 if (!IsCurrentlyOnNTP(browserState) || browserState->IsOffTheRecord()) 26 if (!IsCurrentlyOnNTP(browserState) || browserState->IsOffTheRecord())
28 return; 27 return;
29 base::HistogramBase* counter = base::Histogram::FactoryGet( 28 base::HistogramBase* counter = base::Histogram::FactoryGet(
30 "NewTabPage.ActioniOS", 0, NUM_ACTION_TYPES, NUM_ACTION_TYPES + 1, 29 "NewTabPage.ActioniOS", 0, NUM_ACTION_TYPES, NUM_ACTION_TYPES + 1,
31 base::HistogramBase::kUmaTargetedHistogramFlag); 30 base::HistogramBase::kUmaTargetedHistogramFlag);
32 counter->Add(type); 31 counter->Add(type);
33 } 32 }
34 33
35 void RecordActionFromOmnibox(ios::ChromeBrowserState* browserState, 34 void RecordActionFromOmnibox(ios::ChromeBrowserState* browserState,
36 const GURL& url, 35 const GURL& url,
37 ui::PageTransition transition) { 36 ui::PageTransition transition) {
38 ui::PageTransition coreTransition = static_cast<ui::PageTransition>( 37 ui::PageTransition coreTransition = static_cast<ui::PageTransition>(
39 transition & ui::PAGE_TRANSITION_CORE_MASK); 38 transition & ui::PAGE_TRANSITION_CORE_MASK);
40 if (PageTransitionCoreTypeIs(coreTransition, ui::PAGE_TRANSITION_GENERATED)) { 39 if (PageTransitionCoreTypeIs(coreTransition, ui::PAGE_TRANSITION_GENERATED)) {
41 RecordAction(browserState, ACTION_SEARCHED_USING_OMNIBOX); 40 RecordAction(browserState, ACTION_SEARCHED_USING_OMNIBOX);
42 } else { 41 } else {
43 if (google_util::IsGoogleHomePageUrl(GURL(url))) { 42 if (google_util::IsGoogleHomePageUrl(GURL(url))) {
44 RecordAction(browserState, ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE); 43 RecordAction(browserState, ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE);
45 } else { 44 } else {
46 RecordAction(browserState, ACTION_NAVIGATED_USING_OMNIBOX); 45 RecordAction(browserState, ACTION_NAVIGATED_USING_OMNIBOX);
47 } 46 }
48 } 47 }
49 } 48 }
50 } 49 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client.mm ('k') | ios/chrome/browser/omaha/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698