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.
This commit is contained in:
Marshall Greenblatt
2017-08-03 18:55:19 -04:00
parent 5b12134a45
commit 9cff99dc4e
178 changed files with 10360 additions and 650 deletions

View File

@ -5,31 +5,33 @@
#include <string>
#include "include/wrapper/cef_scoped_temp_dir.h"
#include "tests/ceftests/file_util.h"
#include "tests/gtest/include/gtest/gtest.h"
#include "tests/shared/browser/file_util.h"
TEST(FileUtil, JoinPath) {
// Should return whichever path component is non-empty.
EXPECT_STREQ("", file_util::JoinPath("", "").c_str());
EXPECT_STREQ("path1", file_util::JoinPath("path1", "").c_str());
EXPECT_STREQ("path2", file_util::JoinPath("", "path2").c_str());
EXPECT_STREQ("", client::file_util::JoinPath("", "").c_str());
EXPECT_STREQ("path1", client::file_util::JoinPath("path1", "").c_str());
EXPECT_STREQ("path2", client::file_util::JoinPath("", "path2").c_str());
const std::string& expected =
std::string("path1") + file_util::kPathSep + std::string("path2");
std::string("path1") + client::file_util::kPathSep + std::string("path2");
// Should always be 1 kPathSep character between paths.
EXPECT_STREQ(expected.c_str(), file_util::JoinPath("path1", "path2").c_str());
EXPECT_STREQ(
expected.c_str(),
file_util::JoinPath(std::string("path1") + file_util::kPathSep, "path2")
.c_str());
EXPECT_STREQ(
expected.c_str(),
file_util::JoinPath("path1", file_util::kPathSep + std::string("path2"))
.c_str());
EXPECT_STREQ(expected.c_str(),
file_util::JoinPath(std::string("path1") + file_util::kPathSep,
file_util::kPathSep + std::string("path2"))
client::file_util::JoinPath("path1", "path2").c_str());
EXPECT_STREQ(expected.c_str(),
client::file_util::JoinPath(
std::string("path1") + client::file_util::kPathSep, "path2")
.c_str());
EXPECT_STREQ(expected.c_str(),
client::file_util::JoinPath(
"path1", client::file_util::kPathSep + std::string("path2"))
.c_str());
EXPECT_STREQ(expected.c_str(),
client::file_util::JoinPath(
std::string("path1") + client::file_util::kPathSep,
client::file_util::kPathSep + std::string("path2"))
.c_str());
}
@ -38,13 +40,21 @@ TEST(FileUtil, WriteAndReadFile) {
EXPECT_TRUE(dir.CreateUniqueTempDir());
const std::string& data = "Test contents to read/write";
const std::string& path = file_util::JoinPath(dir.GetPath(), "test.txt");
const std::string& path =
client::file_util::JoinPath(dir.GetPath(), "test.txt");
EXPECT_EQ(static_cast<int>(data.size()),
file_util::WriteFile(path.c_str(), data.data(),
static_cast<int>(data.size())));
client::file_util::WriteFile(path.c_str(), data.data(),
static_cast<int>(data.size())));
std::string read;
EXPECT_TRUE(file_util::ReadFileToString(path.c_str(), &read));
EXPECT_TRUE(client::file_util::ReadFileToString(path.c_str(), &read));
EXPECT_STREQ(data.c_str(), read.c_str());
}
TEST(FileUtil, GetFileExtension) {
EXPECT_TRUE(client::file_util::GetFileExtension(std::string()).empty());
EXPECT_TRUE(client::file_util::GetFileExtension("/path/to/foo").empty());
EXPECT_STREQ("ext",
client::file_util::GetFileExtension("/path/to/foo.ext").c_str());
}