| 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/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
| 17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "base/version.h" | 19 #include "base/version.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/net/url_request_mock_util.h" | 22 #include "chrome/browser/net/url_request_mock_util.h" |
| 23 #include "chrome/browser/profiles/chrome_version_service.h" | 23 #include "chrome/browser/profiles/chrome_version_service.h" |
| 24 #include "chrome/browser/profiles/profile_impl.h" | 24 #include "chrome/browser/profiles/profile_impl.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 28 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
| 29 #include "chrome/common/chrome_version_info.h" | |
| 30 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/test/base/in_process_browser_test.h" | 30 #include "chrome/test/base/in_process_browser_test.h" |
| 32 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
| 33 #include "components/bookmarks/browser/startup_task_runner_service.h" | 32 #include "components/bookmarks/browser/startup_task_runner_service.h" |
| 33 #include "components/version_info/version_info.h" |
| 34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
| 36 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
| 37 #include "net/test/url_request/url_request_failed_job.h" | 37 #include "net/test/url_request/url_request_failed_job.h" |
| 38 #include "net/url_request/url_fetcher.h" | 38 #include "net/url_request/url_fetcher.h" |
| 39 #include "net/url_request/url_fetcher_delegate.h" | 39 #include "net/url_request/url_fetcher_delegate.h" |
| 40 #include "net/url_request/url_request_context_getter.h" | 40 #include "net/url_request/url_request_context_getter.h" |
| 41 #include "net/url_request/url_request_status.h" | 41 #include "net/url_request/url_request_status.h" |
| 42 #include "testing/gmock/include/gmock/gmock.h" | 42 #include "testing/gmock/include/gmock/gmock.h" |
| 43 #include "testing/gtest/include/gtest/gtest.h" | 43 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // Creates a prefs file in the given directory. | 102 // Creates a prefs file in the given directory. |
| 103 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) { | 103 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) { |
| 104 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename)); | 104 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename)); |
| 105 std::string data("{}"); | 105 std::string data("{}"); |
| 106 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size())); | 106 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size())); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void CheckChromeVersion(Profile *profile, bool is_new) { | 109 void CheckChromeVersion(Profile *profile, bool is_new) { |
| 110 std::string created_by_version; | 110 std::string created_by_version; |
| 111 if (is_new) { | 111 if (is_new) { |
| 112 chrome::VersionInfo version_info; | 112 created_by_version = version_info::GetVersionNumber(); |
| 113 created_by_version = version_info.Version(); | |
| 114 } else { | 113 } else { |
| 115 created_by_version = "1.0.0.0"; | 114 created_by_version = "1.0.0.0"; |
| 116 } | 115 } |
| 117 std::string pref_version = | 116 std::string pref_version = |
| 118 ChromeVersionService::GetVersion(profile->GetPrefs()); | 117 ChromeVersionService::GetVersion(profile->GetPrefs()); |
| 119 // Assert that created_by_version pref gets set to current version. | 118 // Assert that created_by_version pref gets set to current version. |
| 120 EXPECT_EQ(created_by_version, pref_version); | 119 EXPECT_EQ(created_by_version, pref_version); |
| 121 } | 120 } |
| 122 | 121 |
| 123 void FlushTaskRunner(base::SequencedTaskRunner* runner) { | 122 void FlushTaskRunner(base::SequencedTaskRunner* runner) { |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 543 |
| 545 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 544 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
| 546 URLFetcherUsingExtensionContextDuringIncognitoTeardown) { | 545 URLFetcherUsingExtensionContextDuringIncognitoTeardown) { |
| 547 Browser* incognito_browser = | 546 Browser* incognito_browser = |
| 548 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); | 547 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); |
| 549 | 548 |
| 550 RunURLFetcherActiveDuringIncognitoTeardownTest( | 549 RunURLFetcherActiveDuringIncognitoTeardownTest( |
| 551 incognito_browser, | 550 incognito_browser, |
| 552 incognito_browser->profile()->GetRequestContextForExtensions()); | 551 incognito_browser->profile()->GetRequestContextForExtensions()); |
| 553 } | 552 } |
| OLD | NEW |