| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/data_usage/data_use_tab_helper.h" | 5 #include "chrome/browser/android/data_usage/data_use_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/android/data_usage/data_use_ui_tab_model.h" | 8 #include "chrome/browser/android/data_usage/data_use_ui_tab_model.h" |
| 9 #include "chrome/browser/android/data_usage/data_use_ui_tab_model_factory.h" | 9 #include "chrome/browser/android/data_usage/data_use_ui_tab_model_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 chrome::android::DataUseUITabModel* data_use_ui_tab_model = | 44 chrome::android::DataUseUITabModel* data_use_ui_tab_model = |
| 45 chrome::android::DataUseUITabModelFactory::GetForBrowserContext( | 45 chrome::android::DataUseUITabModelFactory::GetForBrowserContext( |
| 46 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); | 46 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); |
| 47 SessionID::id_type tab_id = SessionTabHelper::IdForTab(web_contents()); | 47 SessionID::id_type tab_id = SessionTabHelper::IdForTab(web_contents()); |
| 48 if (!data_use_ui_tab_model || tab_id < 0) | 48 if (!data_use_ui_tab_model || tab_id < 0) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 // The last committed navigation entry should correspond to the current | 51 // The last committed navigation entry should correspond to the current |
| 52 // navigation. This should not be null since the DidFinishNavigation | 52 // navigation. This should not be null since the DidFinishNavigation |
| 53 // callback is received for a committed navigation. | 53 // callback is received for a committed navigation. |
| 54 auto navigation_entry = navigation_handle->GetWebContents() | 54 auto* navigation_entry = navigation_handle->GetWebContents() |
| 55 ->GetController() | 55 ->GetController() |
| 56 .GetLastCommittedEntry(); | 56 .GetLastCommittedEntry(); |
| 57 DCHECK(navigation_entry); | 57 DCHECK(navigation_entry); |
| 58 DCHECK_EQ(navigation_handle->GetURL(), navigation_entry->GetURL()); | 58 DCHECK_EQ(navigation_handle->GetURL(), navigation_entry->GetURL()); |
| 59 data_use_ui_tab_model->ReportBrowserNavigation( | 59 data_use_ui_tab_model->ReportBrowserNavigation( |
| 60 navigation_handle->GetURL(), | 60 navigation_handle->GetURL(), |
| 61 ui::PageTransitionFromInt(navigation_handle->GetPageTransition()), tab_id, | 61 ui::PageTransitionFromInt(navigation_handle->GetPageTransition()), tab_id, |
| 62 navigation_entry); | 62 navigation_entry); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DataUseTabHelper::FrameDeleted( | 65 void DataUseTabHelper::FrameDeleted( |
| 66 content::RenderFrameHost* render_frame_host) { | 66 content::RenderFrameHost* render_frame_host) { |
| 67 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 67 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 68 | 68 |
| 69 // Check if it is a main frame. | 69 // Check if it is a main frame. |
| 70 if (render_frame_host->GetParent()) | 70 if (render_frame_host->GetParent()) |
| 71 return; | 71 return; |
| 72 | 72 |
| 73 // Notify the DataUseUITabModel. | 73 // Notify the DataUseUITabModel. |
| 74 chrome::android::DataUseUITabModel* data_use_ui_tab_model = | 74 chrome::android::DataUseUITabModel* data_use_ui_tab_model = |
| 75 chrome::android::DataUseUITabModelFactory::GetForBrowserContext( | 75 chrome::android::DataUseUITabModelFactory::GetForBrowserContext( |
| 76 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); | 76 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); |
| 77 SessionID::id_type tab_id = SessionTabHelper::IdForTab(web_contents()); | 77 SessionID::id_type tab_id = SessionTabHelper::IdForTab(web_contents()); |
| 78 if (data_use_ui_tab_model && tab_id >= 0) | 78 if (data_use_ui_tab_model && tab_id >= 0) |
| 79 data_use_ui_tab_model->ReportTabClosure(tab_id); | 79 data_use_ui_tab_model->ReportTabClosure(tab_id); |
| 80 } | 80 } |
| OLD | NEW |