| 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_model.h" | 5 #include "chrome/browser/android/data_usage/data_use_tab_model.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 if (!is_control_app_installed_) | 258 if (!is_control_app_installed_) |
| 259 return; | 259 return; |
| 260 data_use_matcher_->RegisterURLRegexes(app_package_name, domain_path_regex, | 260 data_use_matcher_->RegisterURLRegexes(app_package_name, domain_path_regex, |
| 261 label); | 261 label); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void DataUseTabModel::OnControlAppInstallStateChange( | 264 void DataUseTabModel::OnControlAppInstallStateChange( |
| 265 bool is_control_app_installed) { | 265 bool is_control_app_installed) { |
| 266 DCHECK(thread_checker_.CalledOnValidThread()); | 266 DCHECK(thread_checker_.CalledOnValidThread()); |
| 267 DCHECK_NE(is_control_app_installed_, is_control_app_installed); | 267 DCHECK_NE(is_control_app_installed_, is_control_app_installed); |
| 268 // If external control app is installed now, rules will be fetched on the next | 268 |
| 269 // navigation event. | |
| 270 is_control_app_installed_ = is_control_app_installed; | 269 is_control_app_installed_ = is_control_app_installed; |
| 271 std::vector<std::string> empty; | 270 std::vector<std::string> empty; |
| 272 if (!is_control_app_installed_) // Clear rules. | 271 if (!is_control_app_installed_) { |
| 272 // Clear rules. |
| 273 data_use_matcher_->RegisterURLRegexes(empty, empty, empty); | 273 data_use_matcher_->RegisterURLRegexes(empty, empty, empty); |
| 274 } else { |
| 275 // Fetch the matching rules when the app is installed. |
| 276 data_use_matcher_->FetchMatchingRules(); |
| 277 } |
| 274 } | 278 } |
| 275 | 279 |
| 276 base::TimeTicks DataUseTabModel::NowTicks() const { | 280 base::TimeTicks DataUseTabModel::NowTicks() const { |
| 277 DCHECK(thread_checker_.CalledOnValidThread()); | 281 DCHECK(thread_checker_.CalledOnValidThread()); |
| 278 return tick_clock_->NowTicks(); | 282 return tick_clock_->NowTicks(); |
| 279 } | 283 } |
| 280 | 284 |
| 281 bool DataUseTabModel::IsCustomTabPackageMatch(SessionID::id_type tab_id) const { | 285 bool DataUseTabModel::IsCustomTabPackageMatch(SessionID::id_type tab_id) const { |
| 282 DCHECK(thread_checker_.CalledOnValidThread()); | 286 DCHECK(thread_checker_.CalledOnValidThread()); |
| 283 TabEntryMap::const_iterator tab_entry_iterator = active_tabs_.find(tab_id); | 287 TabEntryMap::const_iterator tab_entry_iterator = active_tabs_.find(tab_id); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 NowTicks() - | 455 NowTicks() - |
| 452 oldest_tab_entry_iterator->second.GetLatestStartOrEndTime(), | 456 oldest_tab_entry_iterator->second.GetLatestStartOrEndTime(), |
| 453 base::TimeDelta::FromMinutes(1), base::TimeDelta::FromHours(1), 50); | 457 base::TimeDelta::FromMinutes(1), base::TimeDelta::FromHours(1), 50); |
| 454 active_tabs_.erase(oldest_tab_entry_iterator); | 458 active_tabs_.erase(oldest_tab_entry_iterator); |
| 455 } | 459 } |
| 456 } | 460 } |
| 457 | 461 |
| 458 } // namespace android | 462 } // namespace android |
| 459 | 463 |
| 460 } // namespace chrome | 464 } // namespace chrome |
| OLD | NEW |