cef/tests/shared/browser/file_util.h
Marshall Greenblatt 9cff99dc4e Add support for loading extensions (issue #1947)
- Add CefRequestContext::LoadExtension, CefExtension, CefExtensionHandler and
  related methods/interfaces.
- Add chrome://extensions-support that lists supported Chrome APIs.
- Add CefBrowserHost::SetAutoResizeEnabled and CefDisplayHandler::OnAutoResize
  to support browser resize based on preferred web contents size.
- views: Add support for custom CefMenuButton popups.
- cefclient: Run with `--load-extension=set_page_color` command-line flag for
  an extension loading example. Add `--use-views` on Windows and Linux for an
  even better example.
2017-08-25 18:40:32 -04:00

46 lines
1.8 KiB
C++

// Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
// 2012 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.
#ifndef CEF_TESTS_SHARED_BROWSER_FILE_UTIL_H_
#define CEF_TESTS_SHARED_BROWSER_FILE_UTIL_H_
#pragma once
#include <limits>
#include <string>
namespace client {
namespace file_util {
// Platform-specific path separator.
extern const char kPathSep;
// Reads the file at |path| into |contents| and returns true on success and
// false on error. In case of I/O error, |contents| holds the data that could
// be read from the file before the error occurred. When the file size exceeds
// max_size|, the function returns false with |contents| holding the file
// truncated to |max_size|. |contents| may be NULL, in which case this function
// is useful for its side effect of priming the disk cache (could be used for
// unit tests). Calling this function on the browser process UI or IO threads is
// not allowed.
bool ReadFileToString(const std::string& path,
std::string* contents,
size_t max_size = std::numeric_limits<size_t>::max());
// Writes the given buffer into the file, overwriting any data that was
// previously there. Returns the number of bytes written, or -1 on error.
// Calling this function on the browser process UI or IO threads is not allowed.
int WriteFile(const std::string& path, const char* data, int size);
// Combines |path1| and |path2| with the correct platform-specific path
// separator.
std::string JoinPath(const std::string& path1, const std::string& path2);
// Extracts the file extension from |path|.
std::string GetFileExtension(const std::string& path);
} // namespace file_util
} // namespace client
#endif // CEF_TESTS_SHARED_BROWSER_FILE_UTIL_H_