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" |
11 #include "chrome/browser/download/download_shelf.h" | 11 #include "chrome/browser/download/download_shelf.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
16 #include "chrome/browser/ui/browser_navigator.h" | 16 #include "chrome/browser/ui/browser_navigator.h" |
17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/extensions/app_launch_params.h" | 18 #include "chrome/browser/ui/extensions/app_launch_params.h" |
19 #include "chrome/browser/ui/extensions/application_launch.h" | 19 #include "chrome/browser/ui/extensions/application_launch.h" |
20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
21 #include "chrome/browser/ui/settings_window_manager.h" | 21 #include "chrome/browser/ui/settings_window_manager.h" |
22 #include "chrome/browser/ui/singleton_tabs.h" | 22 #include "chrome/browser/ui/singleton_tabs.h" |
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
24 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 24 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "components/signin/core/common/profile_management_switches.h" |
27 #include "content/public/browser/user_metrics.h" | 28 #include "content/public/browser/user_metrics.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "extensions/common/constants.h" | 30 #include "extensions/common/constants.h" |
30 #include "google_apis/gaia/gaia_urls.h" | 31 #include "google_apis/gaia/gaia_urls.h" |
31 #include "net/base/url_util.h" | 32 #include "net/base/url_util.h" |
32 #include "ui/base/window_open_disposition.h" | 33 #include "ui/base/window_open_disposition.h" |
33 | 34 |
34 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
35 #include "chrome/browser/enumerate_modules_model_win.h" | 36 #include "chrome/browser/enumerate_modules_model_win.h" |
36 #endif | 37 #endif |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; | 322 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
322 ShowSingletonTabOverwritingNTP(browser, params); | 323 ShowSingletonTabOverwritingNTP(browser, params); |
323 } | 324 } |
324 | 325 |
325 void ShowSearchEngineSettings(Browser* browser) { | 326 void ShowSearchEngineSettings(Browser* browser) { |
326 content::RecordAction(UserMetricsAction("EditSearchEngines")); | 327 content::RecordAction(UserMetricsAction("EditSearchEngines")); |
327 ShowSettingsSubPage(browser, kSearchEnginesSubPage); | 328 ShowSettingsSubPage(browser, kSearchEnginesSubPage); |
328 } | 329 } |
329 | 330 |
330 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 331 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
331 void ShowBrowserSignin(Browser* browser, signin::Source source) { | 332 void ShowBrowserSignin(Browser* browser, signin_metrics::Source source) { |
332 Profile* original_profile = browser->profile()->GetOriginalProfile(); | 333 Profile* original_profile = browser->profile()->GetOriginalProfile(); |
333 SigninManagerBase* manager = | 334 SigninManagerBase* manager = |
334 SigninManagerFactory::GetForProfile(original_profile); | 335 SigninManagerFactory::GetForProfile(original_profile); |
335 DCHECK(manager->IsSigninAllowed()); | 336 DCHECK(manager->IsSigninAllowed()); |
336 // If we're signed in, just show settings. | 337 // If we're signed in, just show settings. |
337 if (manager->IsAuthenticated()) { | 338 if (manager->IsAuthenticated()) { |
338 ShowSettings(browser); | 339 ShowSettings(browser); |
339 } else { | 340 } else { |
340 // If the browser's profile is an incognito profile, make sure to use | 341 // If the browser's profile is an incognito profile, make sure to use |
341 // a browser window from the original profile. The user cannot sign in | 342 // a browser window from the original profile. The user cannot sign in |
342 // from an incognito window. | 343 // from an incognito window. |
343 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; | 344 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; |
344 if (browser->profile()->IsOffTheRecord()) { | 345 if (browser->profile()->IsOffTheRecord()) { |
345 displayer.reset(new ScopedTabbedBrowserDisplayer( | 346 displayer.reset(new ScopedTabbedBrowserDisplayer( |
346 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 347 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); |
347 browser = displayer->browser(); | 348 browser = displayer->browser(); |
348 } | 349 } |
349 | 350 |
350 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); | 351 signin_metrics::LogSigninSource(source); |
351 DCHECK_GT(browser->tab_strip_model()->count(), 0); | 352 |
| 353 if (switches::IsNewAvatarMenu()) { |
| 354 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 355 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, |
| 356 signin::ManageAccountsParams()); |
| 357 } else { |
| 358 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); |
| 359 DCHECK_GT(browser->tab_strip_model()->count(), 0); |
| 360 } |
352 } | 361 } |
353 } | 362 } |
354 #endif | 363 #endif |
355 | 364 |
356 } // namespace chrome | 365 } // namespace chrome |
OLD | NEW |