OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/settings_window_manager.h" |
| 6 |
| 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/browser_navigator.h" |
| 11 #include "chrome/browser/ui/chrome_pages.h" |
| 12 #include "content/public/browser/user_metrics.h" |
| 13 |
| 14 namespace chrome { |
| 15 |
| 16 // static |
| 17 SettingsWindowManager* SettingsWindowManager::GetInstance() { |
| 18 return Singleton<SettingsWindowManager>::get(); |
| 19 } |
| 20 |
| 21 void SettingsWindowManager::ShowForProfile(Profile* profile, |
| 22 const std::string& sub_page) { |
| 23 content::RecordAction(base::UserMetricsAction("ShowOptions")); |
| 24 GURL gurl = chrome::GetSettingsUrl(sub_page); |
| 25 // Look for an existing browser window. |
| 26 ProfileSessionMap::iterator iter = settings_session_map_.find(profile); |
| 27 if (iter != settings_session_map_.end()) { |
| 28 Browser* browser = chrome::FindBrowserWithID(iter->second); |
| 29 if (browser) { |
| 30 DCHECK(browser->profile() == profile); |
| 31 NavigateParams params(browser, gurl, |
| 32 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 33 params.window_action = NavigateParams::SHOW_WINDOW; |
| 34 params.user_gesture = true; |
| 35 chrome::Navigate(¶ms); |
| 36 return; |
| 37 } |
| 38 } |
| 39 // No existing browser window, create one. |
| 40 NavigateParams params(profile, gurl, content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 41 params.disposition = NEW_POPUP; |
| 42 params.window_action = NavigateParams::SHOW_WINDOW; |
| 43 params.user_gesture = true; |
| 44 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| 45 chrome::Navigate(¶ms); |
| 46 settings_session_map_[profile] = params.browser->session_id().id(); |
| 47 } |
| 48 |
| 49 SettingsWindowManager::SettingsWindowManager() { |
| 50 } |
| 51 |
| 52 SettingsWindowManager::~SettingsWindowManager() { |
| 53 } |
| 54 |
| 55 } // namespace chrome |
OLD | NEW |