Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/ui/settings_window_manager.h" | 5 #include "chrome/browser/ui/settings_window_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 } | 47 } |
| 48 NavigateParams params(browser, gurl, | 48 NavigateParams params(browser, gurl, |
| 49 ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 49 ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 50 params.window_action = NavigateParams::SHOW_WINDOW; | 50 params.window_action = NavigateParams::SHOW_WINDOW; |
| 51 params.user_gesture = true; | 51 params.user_gesture = true; |
| 52 chrome::Navigate(¶ms); | 52 chrome::Navigate(¶ms); |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // No existing browser window, create one. | 56 // No existing browser window, create one. |
| 57 NavigateParams params(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 57 navigate_params_.reset( |
| 58 params.disposition = NEW_POPUP; | 58 new NavigateParams(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK)); |
| 59 params.trusted_source = true; | 59 navigate_params_->disposition = NEW_POPUP; |
| 60 params.window_action = NavigateParams::SHOW_WINDOW; | 60 navigate_params_->trusted_source = true; |
| 61 params.user_gesture = true; | 61 navigate_params_->window_action = NavigateParams::SHOW_WINDOW; |
| 62 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; | 62 navigate_params_->user_gesture = true; |
| 63 chrome::Navigate(¶ms); | 63 navigate_params_->path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| 64 settings_session_map_[profile] = params.browser->session_id().id(); | 64 chrome::Navigate(navigate_params_.get()); |
| 65 settings_session_map_[profile] = navigate_params_->browser->session_id().id(); | |
| 65 | 66 |
| 66 FOR_EACH_OBSERVER(SettingsWindowManagerObserver, | 67 FOR_EACH_OBSERVER(SettingsWindowManagerObserver, |
| 67 observers_, OnNewSettingsWindow(params.browser)); | 68 observers_, OnNewSettingsWindow(navigate_params_->browser)); |
|
Mr4D (OOO till 08-26)
2014/09/25 21:18:34
At this time you could destroy the navigate_params
stevenjb
2014/09/25 21:36:58
Good suggestion now that I think about it, will do
| |
| 68 } | 69 } |
| 69 | 70 |
| 70 Browser* SettingsWindowManager::FindBrowserForProfile(Profile* profile) { | 71 Browser* SettingsWindowManager::FindBrowserForProfile(Profile* profile) { |
| 71 ProfileSessionMap::iterator iter = settings_session_map_.find(profile); | 72 ProfileSessionMap::iterator iter = settings_session_map_.find(profile); |
| 72 if (iter != settings_session_map_.end()) | 73 if (iter != settings_session_map_.end()) |
| 73 return chrome::FindBrowserWithID(iter->second); | 74 return chrome::FindBrowserWithID(iter->second); |
| 74 return NULL; | 75 return NULL; |
| 75 } | 76 } |
| 76 | 77 |
| 77 bool SettingsWindowManager::IsSettingsBrowser(Browser* browser) const { | 78 bool SettingsWindowManager::IsSettingsBrowser(Browser* browser) const { |
| 79 // This may get called from chrome::Navigate, so first test to see if this | |
| 80 // is the browser we most recently navigate to. | |
|
Mr4D (OOO till 08-26)
2014/09/25 21:18:34
.. most recently navigated to.
stevenjb
2014/09/25 21:36:58
Done.
| |
| 81 if (navigate_params_ && navigate_params_->browser == browser) | |
|
Mr4D (OOO till 08-26)
2014/09/25 21:18:34
Don't really like this, but I do not see a good ot
stevenjb
2014/09/25 21:36:58
Right, pretty much the same conclusion I came to.
| |
| 82 return true; | |
| 78 ProfileSessionMap::const_iterator iter = | 83 ProfileSessionMap::const_iterator iter = |
| 79 settings_session_map_.find(browser->profile()); | 84 settings_session_map_.find(browser->profile()); |
| 80 return (iter != settings_session_map_.end() && | 85 return (iter != settings_session_map_.end() && |
| 81 iter->second == browser->session_id().id()); | 86 iter->second == browser->session_id().id()); |
| 82 } | 87 } |
| 83 | 88 |
| 84 SettingsWindowManager::SettingsWindowManager() { | 89 SettingsWindowManager::SettingsWindowManager() { |
| 85 } | 90 } |
| 86 | 91 |
| 87 SettingsWindowManager::~SettingsWindowManager() { | 92 SettingsWindowManager::~SettingsWindowManager() { |
| 88 } | 93 } |
| 89 | 94 |
| 90 } // namespace chrome | 95 } // namespace chrome |
| OLD | NEW |