OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ios/chrome/browser/first_run/first_run.h" | 5 #include "ios/chrome/browser/first_run/first_run.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | |
8 | |
9 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
11 #include "base/path_service.h" | 9 #include "base/path_service.h" |
12 #include "components/pref_registry/pref_registry_syncable.h" | 10 #include "components/pref_registry/pref_registry_syncable.h" |
13 #include "ios/chrome/browser/chrome_paths.h" | 11 #include "ios/chrome/browser/chrome_paths.h" |
14 | 12 |
15 namespace { | 13 namespace { |
16 | 14 |
17 // The absence of kSentinelFile file will tell us it is a first run. | 15 // The absence of kSentinelFile file will tell us it is a first run. |
18 const char kSentinelFile[] = "First Run"; | 16 const base::FilePath::CharType kSentinelFile[] = FILE_PATH_LITERAL("First Run"); |
19 | 17 |
20 // RLZ ping delay pref name. | 18 // RLZ ping delay pref name. |
21 const char kPingDelayPrefName[] = "distribution.ping_delay"; | 19 const char kPingDelayPrefName[] = "distribution.ping_delay"; |
22 | 20 |
23 } // namespace | 21 } // namespace |
24 | 22 |
25 FirstRun::FirstRunState FirstRun::first_run_ = FIRST_RUN_UNKNOWN; | 23 FirstRun::FirstRunState FirstRun::first_run_ = FIRST_RUN_UNKNOWN; |
26 | 24 |
27 // static | 25 // static |
28 bool FirstRun::GetFirstRunSentinelFilePath(base::FilePath* path) { | 26 bool FirstRun::GetFirstRunSentinelFilePath(base::FilePath* path) { |
29 base::FilePath first_run_sentinel; | 27 base::FilePath first_run_sentinel; |
30 if (!PathService::Get(ios::DIR_USER_DATA, &first_run_sentinel)) | 28 if (!PathService::Get(ios::DIR_USER_DATA, &first_run_sentinel)) |
31 return false; | 29 return false; |
32 *path = first_run_sentinel.AppendASCII(kSentinelFile); | 30 *path = first_run_sentinel.Append(kSentinelFile); |
33 return true; | 31 return true; |
34 } | 32 } |
35 | 33 |
36 // static | 34 // static |
37 bool FirstRun::IsChromeFirstRun() { | 35 bool FirstRun::IsChromeFirstRun() { |
38 if (first_run_ != FIRST_RUN_UNKNOWN) | 36 if (first_run_ != FIRST_RUN_UNKNOWN) |
39 return first_run_ == FIRST_RUN_TRUE; | 37 return first_run_ == FIRST_RUN_TRUE; |
40 | 38 |
41 base::FilePath first_run_sentinel; | 39 base::FilePath first_run_sentinel; |
42 if (!GetFirstRunSentinelFilePath(&first_run_sentinel) || | 40 if (!GetFirstRunSentinelFilePath(&first_run_sentinel) || |
(...skipping 25 matching lines...) Expand all Loading... |
68 // static | 66 // static |
69 const char* FirstRun::GetPingDelayPrefName() { | 67 const char* FirstRun::GetPingDelayPrefName() { |
70 return kPingDelayPrefName; | 68 return kPingDelayPrefName; |
71 } | 69 } |
72 | 70 |
73 // static | 71 // static |
74 void FirstRun::RegisterProfilePrefs( | 72 void FirstRun::RegisterProfilePrefs( |
75 user_prefs::PrefRegistrySyncable* registry) { | 73 user_prefs::PrefRegistrySyncable* registry) { |
76 registry->RegisterIntegerPref(GetPingDelayPrefName(), 0); | 74 registry->RegisterIntegerPref(GetPingDelayPrefName(), 0); |
77 } | 75 } |
OLD | NEW |