Commit 6e0965ae authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

[iOS] Move observation of browser states for breadcrumbs

Observing Browserstates should not happen in BrowserViewWrangler as that
object primarily handles UI configuration. Additionally,
BrowserViewWrangler is a scene-scoped object in the multi-window design
of Chrome which would break breadcrumb collection once a window is
closed.

Bug: None
Change-Id: I36f6b4556457c45c74ec836658a75d9eb3f78b71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008440
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733779}
parent f6e0fb39
...@@ -186,6 +186,7 @@ source_set("app_internal") { ...@@ -186,6 +186,7 @@ source_set("app_internal") {
"//ios/chrome/browser/content_settings", "//ios/chrome/browser/content_settings",
"//ios/chrome/browser/crash_report", "//ios/chrome/browser/crash_report",
"//ios/chrome/browser/crash_report:crash_report_internal", "//ios/chrome/browser/crash_report:crash_report_internal",
"//ios/chrome/browser/crash_report/breadcrumbs:feature_flags",
"//ios/chrome/browser/download", "//ios/chrome/browser/download",
"//ios/chrome/browser/external_files", "//ios/chrome/browser/external_files",
"//ios/chrome/browser/favicon", "//ios/chrome/browser/favicon",
......
...@@ -72,8 +72,10 @@ ...@@ -72,8 +72,10 @@
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/chrome_url_util.h" #import "ios/chrome/browser/chrome_url_util.h"
#include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h" #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "ios/chrome/browser/crash_report/breadcrumbs/features.h"
#include "ios/chrome/browser/crash_report/breakpad_helper.h" #include "ios/chrome/browser/crash_report/breakpad_helper.h"
#include "ios/chrome/browser/crash_report/crash_loop_detection_util.h" #include "ios/chrome/browser/crash_report/crash_loop_detection_util.h"
#include "ios/chrome/browser/crash_report/crash_report_helper.h"
#include "ios/chrome/browser/download/download_directory_util.h" #include "ios/chrome/browser/download/download_directory_util.h"
#import "ios/chrome/browser/external_files/external_file_remover_factory.h" #import "ios/chrome/browser/external_files/external_file_remover_factory.h"
#import "ios/chrome/browser/external_files/external_file_remover_impl.h" #import "ios/chrome/browser/external_files/external_file_remover_impl.h"
...@@ -586,6 +588,11 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -586,6 +588,11 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// Initialize and set the main browser state. // Initialize and set the main browser state.
[self initializeBrowserState:chromeBrowserState]; [self initializeBrowserState:chromeBrowserState];
self.mainBrowserState = chromeBrowserState; self.mainBrowserState = chromeBrowserState;
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
breakpad::MonitorBreadcrumbsForBrowserState(self.mainBrowserState);
}
[self.browserViewWrangler shutdown]; [self.browserViewWrangler shutdown];
self.browserViewWrangler = [[BrowserViewWrangler alloc] self.browserViewWrangler = [[BrowserViewWrangler alloc]
initWithBrowserState:self.mainBrowserState initWithBrowserState:self.mainBrowserState
...@@ -786,6 +793,14 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -786,6 +793,14 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[_spotlightManager shutdown]; [_spotlightManager shutdown];
_spotlightManager = nil; _spotlightManager = nil;
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
if (self.mainBrowserState->HasOffTheRecordChromeBrowserState()) {
breakpad::StopMonitoringBreadcrumbsForBrowserState(
self.mainBrowserState->GetOffTheRecordChromeBrowserState());
}
breakpad::StopMonitoringBreadcrumbsForBrowserState(self.mainBrowserState);
}
// Invariant: The UI is stopped before the model is shutdown. // Invariant: The UI is stopped before the model is shutdown.
DCHECK(!_mainCoordinator); DCHECK(!_mainCoordinator);
[self.browserViewWrangler shutdown]; [self.browserViewWrangler shutdown];
......
...@@ -41,6 +41,9 @@ source_set("scene") { ...@@ -41,6 +41,9 @@ source_set("scene") {
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browsing_data", "//ios/chrome/browser/browsing_data",
"//ios/chrome/browser/crash_report", "//ios/chrome/browser/crash_report",
"//ios/chrome/browser/crash_report:crash_report_internal",
"//ios/chrome/browser/crash_report/breadcrumbs",
"//ios/chrome/browser/crash_report/breadcrumbs:feature_flags",
"//ios/chrome/browser/main", "//ios/chrome/browser/main",
"//ios/chrome/browser/ntp:features", "//ios/chrome/browser/ntp:features",
"//ios/chrome/browser/payments", "//ios/chrome/browser/payments",
...@@ -87,8 +90,6 @@ source_set("main") { ...@@ -87,8 +90,6 @@ source_set("main") {
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browsing_data", "//ios/chrome/browser/browsing_data",
"//ios/chrome/browser/crash_report:crash_report_internal", "//ios/chrome/browser/crash_report:crash_report_internal",
"//ios/chrome/browser/crash_report/breadcrumbs",
"//ios/chrome/browser/crash_report/breadcrumbs:feature_flags",
"//ios/chrome/browser/device_sharing", "//ios/chrome/browser/device_sharing",
"//ios/chrome/browser/download", "//ios/chrome/browser/download",
"//ios/chrome/browser/main", "//ios/chrome/browser/main",
......
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/crash_report/breadcrumbs/breadcrumb_manager_browser_agent.h"
#include "ios/chrome/browser/crash_report/breadcrumbs/features.h"
#include "ios/chrome/browser/crash_report/crash_report_helper.h" #include "ios/chrome/browser/crash_report/crash_report_helper.h"
#import "ios/chrome/browser/device_sharing/device_sharing_manager.h" #import "ios/chrome/browser/device_sharing/device_sharing_manager.h"
#import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/main/browser.h"
...@@ -165,9 +163,6 @@ ...@@ -165,9 +163,6 @@
(id<BrowserStateStorageSwitching>)storageSwitcher { (id<BrowserStateStorageSwitching>)storageSwitcher {
if ((self = [super init])) { if ((self = [super init])) {
_browserState = browserState; _browserState = browserState;
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
breakpad::MonitorBreadcrumbsForBrowserState(_browserState);
}
_applicationCommandEndpoint = applicationCommandEndpoint; _applicationCommandEndpoint = applicationCommandEndpoint;
_browsingDataCommandEndpoint = browsingDataCommandEndpoint; _browsingDataCommandEndpoint = browsingDataCommandEndpoint;
_appURLLoadingService = appURLLoadingService; _appURLLoadingService = appURLLoadingService;
...@@ -269,10 +264,6 @@ ...@@ -269,10 +264,6 @@
if (_mainBrowser.get()) { if (_mainBrowser.get()) {
TabModel* tabModel = self.mainBrowser->GetTabModel(); TabModel* tabModel = self.mainBrowser->GetTabModel();
WebStateList* webStateList = self.mainBrowser->GetWebStateList(); WebStateList* webStateList = self.mainBrowser->GetWebStateList();
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
BreadcrumbManagerBrowserAgent::FromBrowser(self.mainBrowser)
->SetLoggingEnabled(false);
}
breakpad::StopMonitoringTabStateForWebStateList(webStateList); breakpad::StopMonitoringTabStateForWebStateList(webStateList);
breakpad::StopMonitoringURLsForWebStateList(webStateList); breakpad::StopMonitoringURLsForWebStateList(webStateList);
[tabModel disconnect]; [tabModel disconnect];
...@@ -288,10 +279,6 @@ ...@@ -288,10 +279,6 @@
if (_otrBrowser.get()) { if (_otrBrowser.get()) {
TabModel* tabModel = self.otrBrowser->GetTabModel(); TabModel* tabModel = self.otrBrowser->GetTabModel();
WebStateList* webStateList = self.otrBrowser->GetWebStateList(); WebStateList* webStateList = self.otrBrowser->GetWebStateList();
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
BreadcrumbManagerBrowserAgent::FromBrowser(self.otrBrowser)
->SetLoggingEnabled(false);
}
breakpad::StopMonitoringTabStateForWebStateList(webStateList); breakpad::StopMonitoringTabStateForWebStateList(webStateList);
[tabModel disconnect]; [tabModel disconnect];
_activeWebStateObservationForwarders[webStateList] = nullptr; _activeWebStateObservationForwarders[webStateList] = nullptr;
...@@ -365,10 +352,6 @@ ...@@ -365,10 +352,6 @@
// Stop watching the OTR webStateList's state for crashes. // Stop watching the OTR webStateList's state for crashes.
breakpad::StopMonitoringTabStateForWebStateList( breakpad::StopMonitoringTabStateForWebStateList(
self.otrBrowser->GetWebStateList()); self.otrBrowser->GetWebStateList());
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
breakpad::StopMonitoringBreadcrumbsForBrowserState(
self.otrBrowser->GetBrowserState());
}
// At this stage, a new incognitoBrowserCoordinator shouldn't be lazily // At this stage, a new incognitoBrowserCoordinator shouldn't be lazily
// constructed by calling the property getter. // constructed by calling the property getter.
...@@ -429,13 +412,6 @@ ...@@ -429,13 +412,6 @@
[self setMainBrowser:nullptr]; [self setMainBrowser:nullptr];
[self setOtrBrowser:nullptr]; [self setOtrBrowser:nullptr];
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
if (_browserState->HasOffTheRecordChromeBrowserState()) {
breakpad::StopMonitoringBreadcrumbsForBrowserState(
_browserState->GetOffTheRecordChromeBrowserState());
}
breakpad::StopMonitoringBreadcrumbsForBrowserState(_browserState);
}
_browserState = nullptr; _browserState = nullptr;
} }
...@@ -447,9 +423,6 @@ ...@@ -447,9 +423,6 @@
ios::ChromeBrowserState* otrBrowserState = ios::ChromeBrowserState* otrBrowserState =
_browserState->GetOffTheRecordChromeBrowserState(); _browserState->GetOffTheRecordChromeBrowserState();
DCHECK(otrBrowserState); DCHECK(otrBrowserState);
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
breakpad::MonitorBreadcrumbsForBrowserState(otrBrowserState);
}
std::unique_ptr<Browser> browser = Browser::Create(otrBrowserState); std::unique_ptr<Browser> browser = Browser::Create(otrBrowserState);
BrowserList* browserList = BrowserList* browserList =
......
...@@ -24,7 +24,10 @@ ...@@ -24,7 +24,10 @@
#include "ios/chrome/browser/browsing_data/browsing_data_remover_factory.h" #include "ios/chrome/browser/browsing_data/browsing_data_remover_factory.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/chrome_url_util.h" #import "ios/chrome/browser/chrome_url_util.h"
#include "ios/chrome/browser/crash_report/breadcrumbs/breadcrumb_manager_browser_agent.h"
#include "ios/chrome/browser/crash_report/breadcrumbs/features.h"
#include "ios/chrome/browser/crash_report/breakpad_helper.h" #include "ios/chrome/browser/crash_report/breakpad_helper.h"
#include "ios/chrome/browser/crash_report/crash_report_helper.h"
#include "ios/chrome/browser/main/browser.h" #include "ios/chrome/browser/main/browser.h"
#include "ios/chrome/browser/ntp/features.h" #include "ios/chrome/browser/ntp/features.h"
#include "ios/chrome/browser/payments/ios_payment_instrument_launcher.h" #include "ios/chrome/browser/payments/ios_payment_instrument_launcher.h"
...@@ -1291,8 +1294,21 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1291,8 +1294,21 @@ enum class EnterTabSwitcherSnapshotResult {
// will be destroyed. // will be destroyed.
[self.mainController.tabSwitcher setOtrBrowser:nil]; [self.mainController.tabSwitcher setOtrBrowser:nil];
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
BreadcrumbManagerBrowserAgent::FromBrowser(self.incognitoInterface.browser)
->SetLoggingEnabled(false);
breakpad::StopMonitoringBreadcrumbsForBrowserState(
self.incognitoInterface.browserState);
}
[self.mainController.browserViewWrangler destroyAndRebuildIncognitoBrowser]; [self.mainController.browserViewWrangler destroyAndRebuildIncognitoBrowser];
if (base::FeatureList::IsEnabled(kLogBreadcrumbs)) {
breakpad::MonitorBreadcrumbsForBrowserState(
self.incognitoInterface.browserState);
}
if (otrBVCIsCurrent) { if (otrBVCIsCurrent) {
[self activateBVCAndMakeCurrentBVCPrimary]; [self activateBVCAndMakeCurrentBVCPrimary];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment