| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; | 72 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| 73 ShowSingletonTabOverwritingNTP(browser, params); | 73 ShowSingletonTabOverwritingNTP(browser, params); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Shows either the help app or the appropriate help page for |source|. If | 76 // Shows either the help app or the appropriate help page for |source|. If |
| 77 // |browser| is NULL and the help page is used (vs the app), the help page is | 77 // |browser| is NULL and the help page is used (vs the app), the help page is |
| 78 // shown in the last active browser. If there is no such browser, a new browser | 78 // shown in the last active browser. If there is no such browser, a new browser |
| 79 // is created. | 79 // is created. |
| 80 void ShowHelpImpl(Browser* browser, | 80 void ShowHelpImpl(Browser* browser, |
| 81 Profile* profile, | 81 Profile* profile, |
| 82 HostDesktopType host_desktop_type, | 82 ui::HostDesktopType host_desktop_type, |
| 83 HelpSource source) { | 83 HelpSource source) { |
| 84 content::RecordAction(UserMetricsAction("ShowHelpTab")); | 84 content::RecordAction(UserMetricsAction("ShowHelpTab")); |
| 85 #if defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD) | 85 #if defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD) |
| 86 const extensions::Extension* extension = | 86 const extensions::Extension* extension = |
| 87 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 87 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
| 88 genius_app::kGeniusAppId, | 88 genius_app::kGeniusAppId, |
| 89 extensions::ExtensionRegistry::EVERYTHING); | 89 extensions::ExtensionRegistry::EVERYTHING); |
| 90 extensions::AppLaunchSource app_launch_source(extensions::SOURCE_UNTRACKED); | 90 extensions::AppLaunchSource app_launch_source(extensions::SOURCE_UNTRACKED); |
| 91 switch (source) { | 91 switch (source) { |
| 92 case HELP_SOURCE_KEYBOARD: | 92 case HELP_SOURCE_KEYBOARD: |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 content::RecordAction(UserMetricsAction("AboutConflicts")); | 196 content::RecordAction(UserMetricsAction("AboutConflicts")); |
| 197 ShowSingletonTab(browser, GURL(kChromeUIConflictsURL)); | 197 ShowSingletonTab(browser, GURL(kChromeUIConflictsURL)); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void ShowHelp(Browser* browser, HelpSource source) { | 200 void ShowHelp(Browser* browser, HelpSource source) { |
| 201 ShowHelpImpl( | 201 ShowHelpImpl( |
| 202 browser, browser->profile(), browser->host_desktop_type(), source); | 202 browser, browser->profile(), browser->host_desktop_type(), source); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void ShowHelpForProfile(Profile* profile, | 205 void ShowHelpForProfile(Profile* profile, |
| 206 HostDesktopType host_desktop_type, | 206 ui::HostDesktopType host_desktop_type, |
| 207 HelpSource source) { | 207 HelpSource source) { |
| 208 ShowHelpImpl(NULL, profile, host_desktop_type, source); | 208 ShowHelpImpl(NULL, profile, host_desktop_type, source); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void ShowPolicy(Browser* browser) { | 211 void ShowPolicy(Browser* browser) { |
| 212 ShowSingletonTab(browser, GURL(kChromeUIPolicyURL)); | 212 ShowSingletonTab(browser, GURL(kChromeUIPolicyURL)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ShowSlow(Browser* browser) { | 215 void ShowSlow(Browser* browser) { |
| 216 #if defined(OS_CHROMEOS) | 216 #if defined(OS_CHROMEOS) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 void ShowSettingsSubPageForProfile(Profile* profile, | 272 void ShowSettingsSubPageForProfile(Profile* profile, |
| 273 const std::string& sub_page) { | 273 const std::string& sub_page) { |
| 274 if (::switches::SettingsWindowEnabled()) { | 274 if (::switches::SettingsWindowEnabled()) { |
| 275 content::RecordAction(base::UserMetricsAction("ShowOptions")); | 275 content::RecordAction(base::UserMetricsAction("ShowOptions")); |
| 276 SettingsWindowManager::GetInstance()->ShowChromePageForProfile( | 276 SettingsWindowManager::GetInstance()->ShowChromePageForProfile( |
| 277 profile, GetSettingsUrl(sub_page)); | 277 profile, GetSettingsUrl(sub_page)); |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 Browser* browser = | 280 Browser* browser = |
| 281 chrome::FindTabbedBrowser(profile, false, HOST_DESKTOP_TYPE_NATIVE); | 281 chrome::FindTabbedBrowser(profile, false, ui::HOST_DESKTOP_TYPE_NATIVE); |
| 282 if (!browser) { | 282 if (!browser) { |
| 283 browser = new Browser( | 283 browser = new Browser( |
| 284 Browser::CreateParams(profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 284 Browser::CreateParams(profile, ui::HOST_DESKTOP_TYPE_NATIVE)); |
| 285 } | 285 } |
| 286 ShowSettingsSubPageInTabbedBrowser(browser, sub_page); | 286 ShowSettingsSubPageInTabbedBrowser(browser, sub_page); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void ShowSettingsSubPageInTabbedBrowser(Browser* browser, | 289 void ShowSettingsSubPageInTabbedBrowser(Browser* browser, |
| 290 const std::string& sub_page) { | 290 const std::string& sub_page) { |
| 291 content::RecordAction(UserMetricsAction("ShowOptions")); | 291 content::RecordAction(UserMetricsAction("ShowOptions")); |
| 292 GURL gurl = GetSettingsUrl(sub_page); | 292 GURL gurl = GetSettingsUrl(sub_page); |
| 293 NavigateParams params(GetSingletonTabNavigateParams(browser, gurl)); | 293 NavigateParams params(GetSingletonTabNavigateParams(browser, gurl)); |
| 294 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; | 294 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 SigninManagerFactory::GetForProfile(original_profile); | 353 SigninManagerFactory::GetForProfile(original_profile); |
| 354 DCHECK(manager->IsSigninAllowed()); | 354 DCHECK(manager->IsSigninAllowed()); |
| 355 // If the browser's profile is an incognito profile, make sure to use | 355 // If the browser's profile is an incognito profile, make sure to use |
| 356 // a browser window from the original profile. The user cannot sign in | 356 // a browser window from the original profile. The user cannot sign in |
| 357 // from an incognito window. | 357 // from an incognito window. |
| 358 bool switched_browser = false; | 358 bool switched_browser = false; |
| 359 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; | 359 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; |
| 360 if (browser->profile()->IsOffTheRecord()) { | 360 if (browser->profile()->IsOffTheRecord()) { |
| 361 switched_browser = true; | 361 switched_browser = true; |
| 362 displayer.reset(new ScopedTabbedBrowserDisplayer( | 362 displayer.reset(new ScopedTabbedBrowserDisplayer( |
| 363 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 363 original_profile, ui::HOST_DESKTOP_TYPE_NATIVE)); |
| 364 browser = displayer->browser(); | 364 browser = displayer->browser(); |
| 365 } | 365 } |
| 366 | 366 |
| 367 signin_metrics::LogSigninSource(source); | 367 signin_metrics::LogSigninSource(source); |
| 368 | 368 |
| 369 // Since the app launcher is a separate application, it might steal focus | 369 // Since the app launcher is a separate application, it might steal focus |
| 370 // away from Chrome, and accidentally close the avatar bubble. The same will | 370 // away from Chrome, and accidentally close the avatar bubble. The same will |
| 371 // happen if we had to switch browser windows to show the sign in page. In | 371 // happen if we had to switch browser windows to show the sign in page. In |
| 372 // this case, fallback to the full-tab signin page. | 372 // this case, fallback to the full-tab signin page. |
| 373 if (switches::IsNewAvatarMenu() && | 373 if (switches::IsNewAvatarMenu() && |
| (...skipping 15 matching lines...) Expand all Loading... |
| 389 SigninManagerFactory::GetForProfile(original_profile); | 389 SigninManagerFactory::GetForProfile(original_profile); |
| 390 DCHECK(manager->IsSigninAllowed()); | 390 DCHECK(manager->IsSigninAllowed()); |
| 391 if (manager->IsAuthenticated()) | 391 if (manager->IsAuthenticated()) |
| 392 ShowSettings(browser); | 392 ShowSettings(browser); |
| 393 else | 393 else |
| 394 ShowBrowserSignin(browser, source); | 394 ShowBrowserSignin(browser, source); |
| 395 } | 395 } |
| 396 #endif | 396 #endif |
| 397 | 397 |
| 398 } // namespace chrome | 398 } // namespace chrome |
| OLD | NEW |