Chromium Code Reviews| Index: chrome/browser/ui/settings_window_manager.cc |
| diff --git a/chrome/browser/ui/settings_window_manager.cc b/chrome/browser/ui/settings_window_manager.cc |
| index c60d5aed54553007f0d27ccf234972e00a87785d..f6a1754e565923713c1178102845ffdb65ff7266 100644 |
| --- a/chrome/browser/ui/settings_window_manager.cc |
| +++ b/chrome/browser/ui/settings_window_manager.cc |
| @@ -54,17 +54,21 @@ void SettingsWindowManager::ShowChromePageForProfile(Profile* profile, |
| } |
| // No existing browser window, create one. |
| - NavigateParams params(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| - params.disposition = NEW_POPUP; |
| - params.trusted_source = true; |
| - params.window_action = NavigateParams::SHOW_WINDOW; |
| - params.user_gesture = true; |
| - params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| - chrome::Navigate(¶ms); |
| - settings_session_map_[profile] = params.browser->session_id().id(); |
| + navigate_params_.reset( |
| + new NavigateParams(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK)); |
| + navigate_params_->disposition = NEW_POPUP; |
| + navigate_params_->trusted_source = true; |
| + navigate_params_->window_action = NavigateParams::SHOW_WINDOW; |
| + navigate_params_->user_gesture = true; |
| + navigate_params_->path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| + chrome::Navigate(navigate_params_.get()); |
| + settings_session_map_[profile] = navigate_params_->browser->session_id().id(); |
| + // Once we set settings_session_map_, reset |navigate_params_| so that we do |
| + // not hold on to a structure with stale pointers. |
| + navigate_params_.reset(); |
| FOR_EACH_OBSERVER(SettingsWindowManagerObserver, |
| - observers_, OnNewSettingsWindow(params.browser)); |
| + observers_, OnNewSettingsWindow(navigate_params_->browser)); |
| } |
| Browser* SettingsWindowManager::FindBrowserForProfile(Profile* profile) { |
| @@ -75,6 +79,10 @@ Browser* SettingsWindowManager::FindBrowserForProfile(Profile* profile) { |
| } |
| bool SettingsWindowManager::IsSettingsBrowser(Browser* browser) const { |
| + // This may get called from chrome::Navigate, so first test to see if this |
| + // is the browser we are crrently navigating to. |
| + if (navigate_params_ && navigate_params_->browser == browser) |
|
sky
2014/09/25 23:36:52
Dependencies like this are fragile and result in N
|
| + return true; |
| ProfileSessionMap::const_iterator iter = |
| settings_session_map_.find(browser->profile()); |
| return (iter != settings_session_map_.end() && |