summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/chrome_paths_fuchsia.cc
blob: 03c2a4a1d5a29cdb7566eb8c4dd25c1c2c5f9251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(crbug.com/1231928): Define user data directory paths within the
// Chrome component namespace, or update UX to remove these concepts where they
// will not apply under Fuchsia.

#include "chrome/common/chrome_paths.h"

#include "base/files/file_path.h"
#include "base/fuchsia/file_utils.h"
#include "base/notreached.h"
#include "base/path_service.h"

namespace chrome {
namespace {

constexpr char kDocumentsDir[] = "Documents";
constexpr char kDownloadsDir[] = "Downloads";

}  // namespace

bool GetDefaultUserDataDirectory(base::FilePath* result) {
  *result = base::FilePath(base::kPersistedDataDirectoryPath);
  return true;
}

void GetUserCacheDirectory(const base::FilePath& profile_dir,
                           base::FilePath* result) {
  *result = profile_dir;

  base::FilePath user_data_dir;
  if (!base::PathService::Get(DIR_USER_DATA, &user_data_dir))
    return;
  base::FilePath cache_dir(base::kPersistedCacheDirectoryPath);
  if (!user_data_dir.AppendRelativePath(profile_dir, &cache_dir))
    return;

  *result = cache_dir;
}

bool GetUserDocumentsDirectory(base::FilePath* result) {
  if (!GetDefaultUserDataDirectory(result))
    return false;
  *result = result->Append(kDocumentsDir);
  return true;
}

bool GetUserDownloadsDirectorySafe(base::FilePath* result) {
  if (!GetDefaultUserDataDirectory(result))
    return false;
  *result = result->Append(kDownloadsDir);
  return true;
}

bool GetUserDownloadsDirectory(base::FilePath* result) {
  return GetUserDownloadsDirectorySafe(result);
}

bool GetUserMusicDirectory(base::FilePath* result) {
  NOTIMPLEMENTED_LOG_ONCE();
  return false;
}

bool GetUserPicturesDirectory(base::FilePath* result) {
  NOTIMPLEMENTED_LOG_ONCE();
  return false;
}

bool GetUserVideosDirectory(base::FilePath* result) {
  NOTIMPLEMENTED_LOG_ONCE();
  return false;
}

bool ProcessNeedsProfileDir(const std::string& process_type) {
  // Only the browser actually needs DIR_USER_DATA to be set.
  return process_type.empty();
}

}  // namespace chrome