| 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/first_run/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return GURL(in); | 319 return GURL(in); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void ConvertStringVectorToGURLVector( | 322 void ConvertStringVectorToGURLVector( |
| 323 const std::vector<std::string>& src, | 323 const std::vector<std::string>& src, |
| 324 std::vector<GURL>* ret) { | 324 std::vector<GURL>* ret) { |
| 325 ret->resize(src.size()); | 325 ret->resize(src.size()); |
| 326 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); | 326 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool IsOnWelcomePage(content::WebContents* contents) { | |
| 330 // We have to check both the GetURL() similar to the other checks below, but | |
| 331 // also the original request url because the welcome page we use is a | |
| 332 // redirect. | |
| 333 // TODO(crbug.com/651465): Remove this once kUseConsolidatedStartupFlow is on | |
| 334 // by default. | |
| 335 const GURL deprecated_welcome_page( | |
| 336 l10n_util::GetStringUTF8(IDS_WELCOME_PAGE_URL)); | |
| 337 if (contents->GetURL() == deprecated_welcome_page || | |
| 338 (contents->GetController().GetVisibleEntry() && | |
| 339 contents->GetController().GetVisibleEntry()->GetOriginalRequestURL() == | |
| 340 deprecated_welcome_page)) { | |
| 341 return true; | |
| 342 } | |
| 343 | |
| 344 const GURL welcome_page(chrome::kChromeUIWelcomeURL); | |
| 345 const GURL welcome_page_win10(chrome::kChromeUIWelcomeWin10URL); | |
| 346 const GURL current = contents->GetURL().GetWithEmptyPath(); | |
| 347 return current == welcome_page || current == welcome_page_win10; | |
| 348 } | |
| 349 | |
| 350 // Show the first run search engine bubble at the first appropriate opportunity. | 329 // Show the first run search engine bubble at the first appropriate opportunity. |
| 351 // This bubble may be delayed by other UI, like global errors and sync promos. | 330 // This bubble may be delayed by other UI, like global errors and sync promos. |
| 352 class FirstRunBubbleLauncher : public content::NotificationObserver { | 331 class FirstRunBubbleLauncher : public content::NotificationObserver { |
| 353 public: | 332 public: |
| 354 // Show the bubble at the first appropriate opportunity. This function | 333 // Show the bubble at the first appropriate opportunity. This function |
| 355 // instantiates a FirstRunBubbleLauncher, which manages its own lifetime. | 334 // instantiates a FirstRunBubbleLauncher, which manages its own lifetime. |
| 356 static void ShowFirstRunBubbleSoon(); | 335 static void ShowFirstRunBubbleSoon(); |
| 357 | 336 |
| 358 private: | 337 private: |
| 359 FirstRunBubbleLauncher(); | 338 FirstRunBubbleLauncher(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 content::WebContents* contents = | 390 content::WebContents* contents = |
| 412 browser->tab_strip_model()->GetActiveWebContents(); | 391 browser->tab_strip_model()->GetActiveWebContents(); |
| 413 | 392 |
| 414 // Suppress the first run bubble if a Gaia sign in page or the sync setup | 393 // Suppress the first run bubble if a Gaia sign in page or the sync setup |
| 415 // page is showing. | 394 // page is showing. |
| 416 if (contents && (contents->GetURL().GetOrigin().spec() == | 395 if (contents && (contents->GetURL().GetOrigin().spec() == |
| 417 chrome::kChromeUIChromeSigninURL || | 396 chrome::kChromeUIChromeSigninURL || |
| 418 gaia::IsGaiaSignonRealm(contents->GetURL().GetOrigin()) || | 397 gaia::IsGaiaSignonRealm(contents->GetURL().GetOrigin()) || |
| 419 contents->GetURL() == | 398 contents->GetURL() == |
| 420 chrome::GetSettingsUrl(chrome::kSyncSetupSubPage) || | 399 chrome::GetSettingsUrl(chrome::kSyncSetupSubPage) || |
| 421 IsOnWelcomePage(contents))) { | 400 first_run::IsOnWelcomePage(contents))) { |
| 422 return; | 401 return; |
| 423 } | 402 } |
| 424 | 403 |
| 425 if (contents && contents->GetURL().SchemeIs(content::kChromeUIScheme)) { | 404 if (contents && contents->GetURL().SchemeIs(content::kChromeUIScheme)) { |
| 426 #if defined(OS_WIN) | 405 #if defined(OS_WIN) |
| 427 // Suppress the first run bubble if 'make chrome metro' flow is showing. | 406 // Suppress the first run bubble if 'make chrome metro' flow is showing. |
| 428 if (contents->GetURL().host_piece() == chrome::kChromeUIMetroFlowHost) | 407 if (contents->GetURL().host_piece() == chrome::kChromeUIMetroFlowHost) |
| 429 return; | 408 return; |
| 430 #endif | 409 #endif |
| 431 | 410 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 void SetShouldShowWelcomePage() { | 687 void SetShouldShowWelcomePage() { |
| 709 g_should_show_welcome_page = true; | 688 g_should_show_welcome_page = true; |
| 710 } | 689 } |
| 711 | 690 |
| 712 bool ShouldShowWelcomePage() { | 691 bool ShouldShowWelcomePage() { |
| 713 bool retval = g_should_show_welcome_page; | 692 bool retval = g_should_show_welcome_page; |
| 714 g_should_show_welcome_page = false; | 693 g_should_show_welcome_page = false; |
| 715 return retval; | 694 return retval; |
| 716 } | 695 } |
| 717 | 696 |
| 697 bool IsOnWelcomePage(content::WebContents* contents) { |
| 698 // We have to check both the GetURL() similar to the other checks below, but |
| 699 // also the original request url because the welcome page we use is a |
| 700 // redirect. |
| 701 // TODO(crbug.com/651465): Remove this once kUseConsolidatedStartupFlow is on |
| 702 // by default. |
| 703 const GURL deprecated_welcome_page( |
| 704 l10n_util::GetStringUTF8(IDS_WELCOME_PAGE_URL)); |
| 705 if (contents->GetURL() == deprecated_welcome_page || |
| 706 (contents->GetController().GetVisibleEntry() && |
| 707 contents->GetController().GetVisibleEntry()->GetOriginalRequestURL() == |
| 708 deprecated_welcome_page)) { |
| 709 return true; |
| 710 } |
| 711 |
| 712 const GURL welcome_page(chrome::kChromeUIWelcomeURL); |
| 713 const GURL welcome_page_win10(chrome::kChromeUIWelcomeWin10URL); |
| 714 const GURL current = contents->GetURL().GetWithEmptyPath(); |
| 715 return current == welcome_page || current == welcome_page_win10; |
| 716 } |
| 717 |
| 718 void SetShouldDoPersonalDataManagerFirstRun() { | 718 void SetShouldDoPersonalDataManagerFirstRun() { |
| 719 g_should_do_autofill_personal_data_manager_first_run = true; | 719 g_should_do_autofill_personal_data_manager_first_run = true; |
| 720 } | 720 } |
| 721 | 721 |
| 722 bool ShouldDoPersonalDataManagerFirstRun() { | 722 bool ShouldDoPersonalDataManagerFirstRun() { |
| 723 bool retval = g_should_do_autofill_personal_data_manager_first_run; | 723 bool retval = g_should_do_autofill_personal_data_manager_first_run; |
| 724 g_should_do_autofill_personal_data_manager_first_run = false; | 724 g_should_do_autofill_personal_data_manager_first_run = false; |
| 725 return retval; | 725 return retval; |
| 726 } | 726 } |
| 727 | 727 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 SetShouldDoPersonalDataManagerFirstRun(); | 859 SetShouldDoPersonalDataManagerFirstRun(); |
| 860 | 860 |
| 861 internal::DoPostImportPlatformSpecificTasks(profile); | 861 internal::DoPostImportPlatformSpecificTasks(profile); |
| 862 } | 862 } |
| 863 | 863 |
| 864 uint16_t auto_import_state() { | 864 uint16_t auto_import_state() { |
| 865 return g_auto_import_state; | 865 return g_auto_import_state; |
| 866 } | 866 } |
| 867 | 867 |
| 868 } // namespace first_run | 868 } // namespace first_run |
| OLD | NEW |