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

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

Issue 2628273004: Revert of Use ChromeBrowserStateManager instead of BrowserListIOS. (Closed)
Patch Set: 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/tabs/tab_model_list.h" 13 #import "ios/chrome/browser/ui/browser_list_ios.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 TabModel* tabModel = GetLastActiveTabModelForChromeBrowserState(browserState); 19 Tab* currentTab =
20 return tabModel.currentTab && 20 [[BrowserListIOS::GetLastActiveWithBrowserState(browserState) tabModel]
21 tabModel.currentTab.url == GURL(kChromeUINewTabURL); 21 currentTab];
22 return currentTab && currentTab.url == GURL(kChromeUINewTabURL);
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 | « 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