| OLD | NEW |
| 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 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 17 #error "This file requires ARC support." |
| 18 #endif |
| 19 |
| 16 namespace new_tab_page_uma { | 20 namespace new_tab_page_uma { |
| 17 | 21 |
| 18 bool IsCurrentlyOnNTP(ios::ChromeBrowserState* browserState) { | 22 bool IsCurrentlyOnNTP(ios::ChromeBrowserState* browserState) { |
| 19 TabModel* tabModel = GetLastActiveTabModelForChromeBrowserState(browserState); | 23 TabModel* tabModel = GetLastActiveTabModelForChromeBrowserState(browserState); |
| 20 return tabModel.currentTab && | 24 return tabModel.currentTab && |
| 21 tabModel.currentTab.url == GURL(kChromeUINewTabURL); | 25 tabModel.currentTab.url == GURL(kChromeUINewTabURL); |
| 22 } | 26 } |
| 23 | 27 |
| 24 void RecordAction(ios::ChromeBrowserState* browserState, ActionType type) { | 28 void RecordAction(ios::ChromeBrowserState* browserState, ActionType type) { |
| 25 DCHECK(browserState); | 29 DCHECK(browserState); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 40 RecordAction(browserState, ACTION_SEARCHED_USING_OMNIBOX); | 44 RecordAction(browserState, ACTION_SEARCHED_USING_OMNIBOX); |
| 41 } else { | 45 } else { |
| 42 if (google_util::IsGoogleHomePageUrl(GURL(url))) { | 46 if (google_util::IsGoogleHomePageUrl(GURL(url))) { |
| 43 RecordAction(browserState, ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE); | 47 RecordAction(browserState, ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE); |
| 44 } else { | 48 } else { |
| 45 RecordAction(browserState, ACTION_NAVIGATED_USING_OMNIBOX); | 49 RecordAction(browserState, ACTION_NAVIGATED_USING_OMNIBOX); |
| 46 } | 50 } |
| 47 } | 51 } |
| 48 } | 52 } |
| 49 } | 53 } |
| OLD | NEW |