summaryrefslogtreecommitdiffstats
path: root/chrome/browser/media_galleries/fileapi/iapps_finder_impl.cc
blob: 811398956ba66dfa3f6e6ab1f1980fb592112594 (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
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/media_galleries/fileapi/iapps_finder_impl.h"

#include "base/bind.h"
#include "base/logging.h"
#include "content/public/browser/browser_thread.h"

namespace iapps {

namespace {

void PostResultToUIThread(storage_monitor::StorageInfo::Type type,
                          const IAppsFinderCallback& callback,
                          const std::string& unique_id) {
  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));

  std::string device_id;
  if (!unique_id.empty())
    device_id = storage_monitor::StorageInfo::MakeDeviceId(type, unique_id);

  content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
                                   base::Bind(callback, device_id));
}

}  // namespace

void FindIAppsOnFileThread(storage_monitor::StorageInfo::Type type,
                           const IAppsFinderTask& task,
                           const IAppsFinderCallback& callback) {
  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
  DCHECK(!task.is_null());
  DCHECK(!callback.is_null());

  content::BrowserThread::PostTask(
      content::BrowserThread::FILE,
      FROM_HERE,
      base::Bind(task, base::Bind(PostResultToUIThread, type, callback)));
}

// iPhoto is only supported on OSX.
#if !defined(OS_MACOSX)
void FindIPhotoLibrary(const IAppsFinderCallback& callback) {
  callback.Run(std::string());
}
#endif  // !defined(OS_MACOSX)

// iTunes is only support on OSX and Windows.
#if !defined(OS_MACOSX) && !defined(OS_WIN)
void FindITunesLibrary(const IAppsFinderCallback& callback) {
  callback.Run(std::string());
}
#endif

}  // namespace iapps