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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (sub_page.find(kInternetOptionsSubPage, 0) != std::string::npos) { | 205 if (sub_page.find(kInternetOptionsSubPage, 0) != std::string::npos) { |
206 std::string::size_type loc = sub_page.find("?", 0); | 206 std::string::size_type loc = sub_page.find("?", 0); |
207 std::string network_page = | 207 std::string network_page = |
208 loc != std::string::npos ? sub_page.substr(loc) : std::string(); | 208 loc != std::string::npos ? sub_page.substr(loc) : std::string(); |
209 url = std::string(kChromeUISettingsURL) + network_page; | 209 url = std::string(kChromeUISettingsURL) + network_page; |
210 } | 210 } |
211 #endif | 211 #endif |
212 return GURL(url); | 212 return GURL(url); |
213 } | 213 } |
214 | 214 |
215 bool IsSettingsWindow(const Browser* browser) { | |
216 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
217 switches::kEnableSettingsWindow)) | |
218 return false; | |
219 if (browser->is_type_tabbed()) | |
220 return false; | |
221 const content::WebContents* web_contents = | |
222 browser->tab_strip_model()->GetWebContentsAt(0); | |
223 if (!web_contents) | |
224 return false; | |
225 GURL url(web_contents->GetURL()); | |
226 return (url.SchemeIs(content::kChromeUIScheme) && | |
227 url.spec().find(chrome::kChromeUISettingsURL) == 0); | |
228 } | |
229 | |
230 void ShowSettings(Browser* browser) { | 215 void ShowSettings(Browser* browser) { |
231 ShowSettingsSubPage(browser, std::string()); | 216 ShowSettingsSubPage(browser, std::string()); |
232 } | 217 } |
233 | 218 |
234 void ShowSettingsSubPage(Browser* browser, const std::string& sub_page) { | 219 void ShowSettingsSubPage(Browser* browser, const std::string& sub_page) { |
235 if (CommandLine::ForCurrentProcess()->HasSwitch( | 220 if (CommandLine::ForCurrentProcess()->HasSwitch( |
236 ::switches::kEnableSettingsWindow)) { | 221 ::switches::kEnableSettingsWindow)) { |
237 SettingsWindowManager::GetInstance()->ShowForProfile(browser->profile(), | 222 SettingsWindowManager::GetInstance()->ShowForProfile(browser->profile(), |
238 sub_page); | 223 sub_page); |
239 return; | 224 return; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 306 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); |
322 browser = displayer->browser(); | 307 browser = displayer->browser(); |
323 } | 308 } |
324 | 309 |
325 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); | 310 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); |
326 DCHECK_GT(browser->tab_strip_model()->count(), 0); | 311 DCHECK_GT(browser->tab_strip_model()->count(), 0); |
327 } | 312 } |
328 } | 313 } |
329 | 314 |
330 } // namespace chrome | 315 } // namespace chrome |
OLD | NEW |