| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_pages.h" | 5 #include "chrome/browser/ui/chrome_pages.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; | 102 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; |
| 103 if (!browser) { | 103 if (!browser) { |
| 104 displayer.reset( | 104 displayer.reset( |
| 105 new ScopedTabbedBrowserDisplayer(profile, host_desktop_type)); | 105 new ScopedTabbedBrowserDisplayer(profile, host_desktop_type)); |
| 106 browser = displayer->browser(); | 106 browser = displayer->browser(); |
| 107 } | 107 } |
| 108 ShowSingletonTab(browser, url); | 108 ShowSingletonTab(browser, url); |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool IsSettingsWindowEnabled() { | |
| 112 return CommandLine::ForCurrentProcess()->HasSwitch( | |
| 113 ::switches::kEnableSettingsWindow); | |
| 114 } | |
| 115 | |
| 116 } // namespace | 111 } // namespace |
| 117 | 112 |
| 118 void ShowBookmarkManager(Browser* browser) { | 113 void ShowBookmarkManager(Browser* browser) { |
| 119 content::RecordAction(UserMetricsAction("ShowBookmarkManager")); | 114 content::RecordAction(UserMetricsAction("ShowBookmarkManager")); |
| 120 content::RecordAction(UserMetricsAction("ShowBookmarks")); | 115 content::RecordAction(UserMetricsAction("ShowBookmarks")); |
| 121 ShowSingletonTabOverwritingNTP( | 116 ShowSingletonTabOverwritingNTP( |
| 122 browser, | 117 browser, |
| 123 GetSingletonTabNavigateParams(browser, GURL(kChromeUIBookmarksURL))); | 118 GetSingletonTabNavigateParams(browser, GURL(kChromeUIBookmarksURL))); |
| 124 } | 119 } |
| 125 | 120 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return false; | 222 return false; |
| 228 GURL url(web_contents->GetURL()); | 223 GURL url(web_contents->GetURL()); |
| 229 return url.SchemeIs(scheme.c_str()); | 224 return url.SchemeIs(scheme.c_str()); |
| 230 } | 225 } |
| 231 | 226 |
| 232 void ShowSettings(Browser* browser) { | 227 void ShowSettings(Browser* browser) { |
| 233 ShowSettingsSubPage(browser, std::string()); | 228 ShowSettingsSubPage(browser, std::string()); |
| 234 } | 229 } |
| 235 | 230 |
| 236 void ShowSettingsSubPage(Browser* browser, const std::string& sub_page) { | 231 void ShowSettingsSubPage(Browser* browser, const std::string& sub_page) { |
| 237 if (IsSettingsWindowEnabled()) { | 232 if (::switches::SettingsWindowEnabled()) { |
| 238 ShowSettingsSubPageForProfile(browser->profile(), sub_page); | 233 ShowSettingsSubPageForProfile(browser->profile(), sub_page); |
| 239 return; | 234 return; |
| 240 } | 235 } |
| 241 ShowSettingsSubPageInTabbedBrowser(browser, sub_page); | 236 ShowSettingsSubPageInTabbedBrowser(browser, sub_page); |
| 242 } | 237 } |
| 243 | 238 |
| 244 void ShowSettingsSubPageForProfile(Profile* profile, | 239 void ShowSettingsSubPageForProfile(Profile* profile, |
| 245 const std::string& sub_page) { | 240 const std::string& sub_page) { |
| 246 if (IsSettingsWindowEnabled()) { | 241 if (::switches::SettingsWindowEnabled()) { |
| 247 content::RecordAction(base::UserMetricsAction("ShowOptions")); | 242 content::RecordAction(base::UserMetricsAction("ShowOptions")); |
| 248 SettingsWindowManager::GetInstance()->ShowChromePageForProfile( | 243 SettingsWindowManager::GetInstance()->ShowChromePageForProfile( |
| 249 profile, GetSettingsUrl(sub_page)); | 244 profile, GetSettingsUrl(sub_page)); |
| 250 return; | 245 return; |
| 251 } | 246 } |
| 252 Browser* browser = | 247 Browser* browser = |
| 253 chrome::FindTabbedBrowser(profile, false, HOST_DESKTOP_TYPE_NATIVE); | 248 chrome::FindTabbedBrowser(profile, false, HOST_DESKTOP_TYPE_NATIVE); |
| 254 if (!browser) { | 249 if (!browser) { |
| 255 browser = new Browser( | 250 browser = new Browser( |
| 256 Browser::CreateParams(profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 251 Browser::CreateParams(profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 317 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); |
| 323 browser = displayer->browser(); | 318 browser = displayer->browser(); |
| 324 } | 319 } |
| 325 | 320 |
| 326 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); | 321 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); |
| 327 DCHECK_GT(browser->tab_strip_model()->count(), 0); | 322 DCHECK_GT(browser->tab_strip_model()->count(), 0); |
| 328 } | 323 } |
| 329 } | 324 } |
| 330 | 325 |
| 331 } // namespace chrome | 326 } // namespace chrome |
| OLD | NEW |