summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/cros/cros_library.cc
blob: e99ed18a14eb26dd16cd7193bf14d345f9a13f34 (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
// Copyright (c) 2009 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/chromeos/cros/cros_library.h"

#include <dlfcn.h>

#include "base/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
#include "third_party/cros/chromeos_cros_api.h"

namespace chromeos {

// static
bool CrosLibrary::loaded_ = false;

// static
bool CrosLibrary::load_error_ = false;

// static
std::string CrosLibrary::load_error_string_;

// static
bool CrosLibrary::EnsureLoaded() {
  if (!loaded_ && !load_error_) {
    FilePath path;
    if (PathService::Get(chrome::FILE_CHROMEOS_API, &path))
      loaded_ = LoadLibcros(path.value().c_str(), load_error_string_);

    if (!loaded_) {
      load_error_ = true;
      LOG(ERROR) << "Problem loading chromeos shared object: "
                 << load_error_string_;
    }
  }
  return loaded_;
}

}  // namespace chromeos