Merge revision 845 changes:

- Add about:version, about:credits and about:license internal URLs (issue #731).
- Centralize retrieval of the CEF major version number from a new VERSION file.

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1271@846 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-10-08 17:48:20 +00:00
parent c5bb1d019a
commit 4c4206604d
25 changed files with 1377 additions and 633 deletions

1
cef3/VERSION Normal file
View File

@ -0,0 +1 @@
CEF_MAJOR=3

View File

@ -10,7 +10,7 @@
'revision': '<!(python tools/revision.py)', 'revision': '<!(python tools/revision.py)',
# Need to be creative to match dylib version formatting requirements. # Need to be creative to match dylib version formatting requirements.
'version_mac_dylib': 'version_mac_dylib':
'<!(python ../chrome/tools/build/version.py -f ../chrome/VERSION -t "3<(revision).@BUILD_HI@.@BUILD_LO@" -e "BUILD_HI=int(BUILD)/256" -e "BUILD_LO=int(BUILD)%256")', '<!(python ../chrome/tools/build/version.py -f VERSION -f ../chrome/VERSION -t "@CEF_MAJOR@<(revision).@BUILD_HI@.@BUILD_LO@" -e "BUILD_HI=int(BUILD)/256" -e "BUILD_LO=int(BUILD)%256")',
}, },
'includes': [ 'includes': [
# Bring in the source file lists. # Bring in the source file lists.
@ -792,6 +792,8 @@
'libcef/browser/browser_settings.h', 'libcef/browser/browser_settings.h',
'libcef/browser/browser_urlrequest_impl.cc', 'libcef/browser/browser_urlrequest_impl.cc',
'libcef/browser/browser_urlrequest_impl.h', 'libcef/browser/browser_urlrequest_impl.h',
'libcef/browser/chrome_scheme_handler.cc',
'libcef/browser/chrome_scheme_handler.h',
'libcef/browser/content_browser_client.cc', 'libcef/browser/content_browser_client.cc',
'libcef/browser/content_browser_client.h', 'libcef/browser/content_browser_client.h',
'libcef/browser/context.cc', 'libcef/browser/context.cc',
@ -810,6 +812,8 @@
'libcef/browser/download_manager_delegate.h', 'libcef/browser/download_manager_delegate.h',
'libcef/browser/frame_host_impl.cc', 'libcef/browser/frame_host_impl.cc',
'libcef/browser/frame_host_impl.h', 'libcef/browser/frame_host_impl.h',
'libcef/browser/internal_scheme_handler.cc',
'libcef/browser/internal_scheme_handler.h',
'libcef/browser/javascript_dialog.h', 'libcef/browser/javascript_dialog.h',
'libcef/browser/javascript_dialog_creator.cc', 'libcef/browser/javascript_dialog_creator.cc',
'libcef/browser/javascript_dialog_creator.h', 'libcef/browser/javascript_dialog_creator.h',
@ -830,6 +834,8 @@
'libcef/browser/resource_request_job.cc', 'libcef/browser/resource_request_job.cc',
'libcef/browser/resource_request_job.h', 'libcef/browser/resource_request_job.h',
'libcef/browser/scheme_impl.cc', 'libcef/browser/scheme_impl.cc',
'libcef/browser/scheme_registration.cc',
'libcef/browser/scheme_registration.h',
'libcef/browser/sqlite_diagnostics_stub.cc', 'libcef/browser/sqlite_diagnostics_stub.cc',
'libcef/browser/stream_impl.cc', 'libcef/browser/stream_impl.cc',
'libcef/browser/stream_impl.h', 'libcef/browser/stream_impl.h',

View File

@ -12,6 +12,7 @@
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/devtools_delegate.h" #include "libcef/browser/devtools_delegate.h"
#include "libcef/browser/navigate_params.h" #include "libcef/browser/navigate_params.h"
#include "libcef/browser/scheme_registration.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/browser/url_request_context_getter.h" #include "libcef/browser/url_request_context_getter.h"
#include "libcef/browser/url_request_context_getter_proxy.h" #include "libcef/browser/url_request_context_getter_proxy.h"
@ -1223,6 +1224,10 @@ void CefBrowserHostImpl::DidFinishLoad(
CefRefPtr<CefFrame> frame = GetOrCreateFrame(frame_id, CefRefPtr<CefFrame> frame = GetOrCreateFrame(frame_id,
CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(),
validated_url); validated_url);
// Give internal scheme handlers an opportunity to update content.
scheme::DidFinishLoad(frame, validated_url);
OnLoadEnd(frame, validated_url); OnLoadEnd(frame, validated_url);
} }

View File

@ -0,0 +1,344 @@
// Copyright (c) 2012 The Chromium Embedded Framework 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 "libcef/browser/chrome_scheme_handler.h"
#include <map>
#include <string>
#include "include/cef_version.h"
#include "include/cef_web_plugin.h"
#include "libcef/browser/context.h"
#include "libcef/browser/internal_scheme_handler.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "content/public/common/content_client.h"
#include "grit/cef_resources.h"
#include "v8/include/v8.h"
#include "webkit/user_agent/user_agent_util.h"
namespace scheme {
const char kChromeScheme[] = "chrome";
const char kChromeURL[] = "chrome://";
namespace {
const char kChromeCreditsDomain[] = "credits";
const char kChromeLicenseDomain[] = "license";
const char kChromeVersionDomain[] = "version";
enum ChromeDomain {
CHROME_UNKNOWN = 0,
CHROME_CREDITS,
CHROME_LICENSE,
CHROME_VERSION,
};
ChromeDomain GetChromeDomain(const std::string& domain_name) {
static struct {
const char* name;
ChromeDomain domain;
} domains[] = {
{ kChromeCreditsDomain, CHROME_CREDITS },
{ kChromeLicenseDomain, CHROME_LICENSE },
{ kChromeVersionDomain, CHROME_VERSION },
};
for (size_t i = 0; i < sizeof(domains) / sizeof(domains[0]); ++i) {
if (base::strcasecmp(domains[i].name, domain_name.c_str()) == 0)
return domains[i].domain;
}
return CHROME_UNKNOWN;
}
std::string GetOSType() {
#if defined(OS_WIN)
return "Windows";
#elif defined(OS_MACOSX)
return "Mac OS X";
#elif defined(OS_CHROMEOS)
return "Chromium OS";
#elif defined(OS_ANDROID)
return "Android";
#elif defined(OS_LINUX)
return "Linux";
#elif defined(OS_FREEBSD)
return "FreeBSD";
#elif defined(OS_OPENBSD)
return "OpenBSD";
#elif defined(OS_SOLARIS)
return "Solaris";
#else
return "Unknown";
#endif
}
std::string GetCommandLine() {
#if defined(OS_WIN)
return WideToUTF8(CommandLine::ForCurrentProcess()->GetCommandLineString());
#elif defined(OS_POSIX)
std::string command_line = "";
typedef std::vector<std::string> ArgvList;
const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
command_line += " " + *iter;
// TODO(viettrungluu): |command_line| could really have any encoding, whereas
// below we assumes it's UTF-8.
return command_line;
#endif
}
std::string GetModulePath() {
FilePath path;
if (PathService::Get(base::FILE_MODULE, &path))
return CefString(path.value());
return std::string();
}
class TemplateParser {
public:
TemplateParser()
: ident_start_("$$"),
ident_end_("$$") {
}
TemplateParser(const std::string& ident_start,
const std::string& ident_end)
: ident_start_(ident_start),
ident_end_(ident_end) {
}
void Add(const std::string& key, const std::string& value) {
values_.insert(std::make_pair(key, value));
}
void Parse(std::string* tmpl) {
int start_pos, end_pos = 0;
int ident_start_len = ident_start_.length();
int ident_end_len = ident_end_.length();
while(true) {
start_pos = tmpl->find(ident_start_, end_pos);
if (start_pos >= 0) {
end_pos = tmpl->find(ident_end_, start_pos + ident_start_len);
if (end_pos >= 0) {
// Found an identifier. Check if a substitution exists.
std::string key = tmpl->substr(start_pos + ident_start_len,
end_pos - start_pos - ident_start_len);
KeyMap::const_iterator it = values_.find(key);
if (it != values_.end()) {
// Peform the substitution.
tmpl->replace(start_pos, end_pos + ident_end_len - start_pos,
it->second);
end_pos = start_pos + it->second.length();
} else {
// Leave the unknown identifier in place.
end_pos += ident_end_len;
}
if (end_pos >= static_cast<int>(tmpl->length()) - ident_start_len -
ident_end_len) {
// Not enough room remaining for more identifiers.
break;
}
} else {
// No end identifier found.
break;
}
} else {
// No start identifier found.
break;
}
}
}
private:
typedef std::map<std::string, std::string> KeyMap;
KeyMap values_;
std::string ident_start_;
std::string ident_end_;
};
class Delegate : public InternalHandlerDelegate {
public:
Delegate() {}
virtual bool OnRequest(CefRefPtr<CefRequest> request,
Action* action) OVERRIDE {
GURL url = GURL(request->GetURL().ToString());
std::string path = url.path();
if (path.length() > 0)
path = path.substr(1);
bool handled = false;
ChromeDomain domain = GetChromeDomain(url.host());
switch (domain) {
case CHROME_CREDITS:
handled = OnCredits(path, action);
break;
case CHROME_LICENSE:
handled = OnLicense(action);
break;
case CHROME_VERSION:
handled = OnVersion(action);
break;
default:
break;
}
if (!handled && domain != CHROME_VERSION) {
action->redirect_url =
GURL(std::string(kChromeURL) + kChromeVersionDomain);
}
return true;
}
bool OnCredits(const std::string& path, Action* action) {
if (path == "credits.js") {
action->resource_id = IDR_CEF_CREDITS_JS;
} else if (path == "swiftshader.jpg") {
action->resource_id = IDR_CEF_CREDITS_SWIFTSHADER_JPG;
} else {
action->mime_type = "text/html";
action->resource_id = IDR_CEF_CREDITS_HTML;
}
return true;
}
bool OnLicense(Action* action) {
base::StringPiece piece = content::GetContentClient()->GetDataResource(
IDR_CEF_LICENSE_TXT, ui::SCALE_FACTOR_NONE);
if (piece.empty()) {
NOTREACHED() << "Failed to load license txt resource.";
return false;
}
std::string html = "<html><head><title>License</title></head><body><pre>" +
piece.as_string() + "</pre></body></html>";
action->mime_type = "text/html";
action->stream = CefStreamReader::CreateForData(
const_cast<char*>(html.c_str()), html.length());
action->stream_size = html.length();
return true;
}
bool OnVersion(Action* action) {
base::StringPiece piece = content::GetContentClient()->GetDataResource(
IDR_CEF_VERSION_HTML, ui::SCALE_FACTOR_NONE);
if (piece.empty()) {
NOTREACHED() << "Failed to load version html resource.";
return false;
}
TemplateParser parser;
parser.Add("YEAR", MAKE_STRING(COPYRIGHT_YEAR));
parser.Add("CEF",
base::StringPrintf("%d.%d.%d",
CEF_VERSION_MAJOR,
CHROME_VERSION_BUILD,
CEF_REVISION));
parser.Add("CHROMIUM",
base::StringPrintf("%d.%d.%d.%d",
CHROME_VERSION_MAJOR,
CHROME_VERSION_MINOR,
CHROME_VERSION_BUILD,
CHROME_VERSION_PATCH));
parser.Add("OS", GetOSType());
parser.Add("WEBKIT",
base::StringPrintf("%d.%d",
webkit_glue::GetWebKitMajorVersion(),
webkit_glue::GetWebKitMinorVersion()));
parser.Add("JAVASCRIPT", v8::V8::GetVersion());
parser.Add("FLASH", std::string()); // Value populated asynchronously.
parser.Add("USERAGENT", content::GetUserAgent(GURL()));
parser.Add("COMMANDLINE", GetCommandLine());
parser.Add("MODULEPATH", GetModulePath());
parser.Add("CACHEPATH", CefString(_Context->cache_path().value()));
std::string tmpl = piece.as_string();
parser.Parse(&tmpl);
action->mime_type = "text/html";
action->stream = CefStreamReader::CreateForData(
const_cast<char*>(tmpl.c_str()), tmpl.length());
action->stream_size = tmpl.length();
return true;
}
};
void DidFinishChromeVersionLoad(CefRefPtr<CefFrame> frame) {
// Retieve Flash version information and update asynchronously.
class Visitor : public CefWebPluginInfoVisitor {
public:
Visitor(CefRefPtr<CefFrame> frame)
: frame_(frame) {
}
virtual bool Visit(CefRefPtr<CefWebPluginInfo> info,
int count, int total) OVERRIDE {
std::string name = info->GetName();
if (name == "Shockwave Flash") {
if (frame_->IsValid()) {
std::string version = info->GetVersion();
frame_->ExecuteJavaScript(
"document.getElementById('flash').innerText = '" + version + "';",
std::string(), 0);
}
return false;
}
return true;
}
private:
CefRefPtr<CefFrame> frame_;
IMPLEMENT_REFCOUNTING(Visitor);
};
CefVisitWebPluginInfo(new Visitor(frame));
}
} // namespace
void RegisterChromeHandler() {
CefRegisterSchemeHandlerFactory(
kChromeScheme,
std::string(),
CreateInternalHandlerFactory(
make_scoped_ptr<InternalHandlerDelegate>(new Delegate())));
}
bool WillHandleBrowserAboutURL(GURL* url,
content::BrowserContext* browser_context) {
std::string text = url->possibly_invalid_spec();
if (text.find("about:") == 0 && text != "about:blank" && text.length() > 6) {
// Redirect about: URLs to chrome://
*url = GURL(kChromeURL + text.substr(6));
}
// Allow the redirection to proceed.
return false;
}
void DidFinishChromeLoad(CefRefPtr<CefFrame> frame,
const GURL& validated_url) {
ChromeDomain domain = GetChromeDomain(validated_url.host());
switch (domain) {
case CHROME_VERSION:
DidFinishChromeVersionLoad(frame);
default:
break;
}
}
} // namespace scheme

View File

@ -0,0 +1,35 @@
// Copyright (c) 2012 The Chromium Embedded Framework 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_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_
#define CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_
#pragma once
#include <string>
#include "include/cef_frame.h"
#include "googleurl/src/gurl.h"
namespace content {
class BrowserContext;
}
namespace scheme {
extern const char kChromeScheme[];
extern const char kChromeURL[];
// Register the chrome scheme handler.
void RegisterChromeHandler();
// Used to redirect about: URLs to chrome: URLs.
bool WillHandleBrowserAboutURL(GURL* url,
content::BrowserContext* browser_context);
// Used to fire any asynchronous content updates.
void DidFinishChromeLoad(CefRefPtr<CefFrame> frame,
const GURL& validated_url);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_

View File

@ -11,6 +11,7 @@
#include "libcef/browser/browser_main.h" #include "libcef/browser/browser_main.h"
#include "libcef/browser/browser_message_filter.h" #include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_settings.h" #include "libcef/browser/browser_settings.h"
#include "libcef/browser/chrome_scheme_handler.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/resource_dispatcher_host_delegate.h" #include "libcef/browser/resource_dispatcher_host_delegate.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
@ -23,6 +24,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "content/browser/plugin_service_impl.h" #include "content/browser/plugin_service_impl.h"
#include "content/public/browser/access_token_store.h" #include "content/public/browser/access_token_store.h"
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/media_observer.h" #include "content/public/browser/media_observer.h"
#include "content/public/browser/plugin_service_filter.h" #include "content/public/browser/plugin_service_filter.h"
#include "content/public/browser/quota_permission_context.h" #include "content/public/browser/quota_permission_context.h"
@ -328,6 +330,13 @@ void CefContentBrowserClient::OverrideWebkitPrefs(
BrowserToWebSettings(browser->settings(), *prefs); BrowserToWebSettings(browser->settings(), *prefs);
} }
void CefContentBrowserClient::BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) {
// Used to redirect about: URLs to chrome: URLs.
handler->AddHandlerPair(&scheme::WillHandleBrowserAboutURL,
content::BrowserURLHandler::null_handler());
}
std::string CefContentBrowserClient::GetDefaultDownloadName() { std::string CefContentBrowserClient::GetDefaultDownloadName() {
return "download"; return "download";
} }

View File

@ -46,6 +46,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh, virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
const GURL& url, const GURL& url,
webkit_glue::WebPreferences* prefs) OVERRIDE; webkit_glue::WebPreferences* prefs) OVERRIDE;
virtual void BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) OVERRIDE;
virtual std::string GetDefaultDownloadName() OVERRIDE; virtual std::string GetDefaultDownloadName() OVERRIDE;
#if defined(OS_WIN) #if defined(OS_WIN)
const wchar_t* GetResourceDllName() OVERRIDE; const wchar_t* GetResourceDllName() OVERRIDE;

View File

@ -8,7 +8,7 @@
#include "libcef/browser/browser_main.h" #include "libcef/browser/browser_main.h"
#include "libcef/browser/browser_message_loop.h" #include "libcef/browser/browser_message_loop.h"
#include "libcef/browser/content_browser_client.h" #include "libcef/browser/content_browser_client.h"
#include "libcef/browser/devtools_scheme_handler.h" #include "libcef/browser/scheme_registration.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/common/main_delegate.h" #include "libcef/common/main_delegate.h"
@ -359,8 +359,8 @@ CefDevToolsDelegate* CefContext::devtools_delegate() const {
void CefContext::OnContextInitialized() { void CefContext::OnContextInitialized() {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
// Perform DevTools scheme registration. // Register internal scheme handlers.
RegisterDevToolsSchemeHandler(); scheme::RegisterInternalHandlers();
// Notify the handler. // Notify the handler.
CefRefPtr<CefApp> app = application(); CefRefPtr<CefApp> app = application();

View File

@ -124,7 +124,7 @@ bool CefDevToolsDelegate::BundlesFrontendResources() {
} }
std::string CefDevToolsDelegate::GetFrontendResourcesBaseURL() { std::string CefDevToolsDelegate::GetFrontendResourcesBaseURL() {
return kChromeDevToolsURL; return scheme::kChromeDevToolsURL;
} }
std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh, std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh,
@ -140,8 +140,8 @@ std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh,
std::string page_id = binding_->GetIdentifier(rvh); std::string page_id = binding_->GetIdentifier(rvh);
std::string host = http_scheme ? std::string host = http_scheme ?
base::StringPrintf("http://localhost:%d/devtools/", port) : base::StringPrintf("http://localhost:%d/devtools/", port) :
kChromeDevToolsURL; scheme::kChromeDevToolsURL;
return base::StringPrintf( return base::StringPrintf(
"%sdevtools.html?ws=localhost:%d/devtools/page/%s", "%sdevtools.html?ws=localhost:%d/devtools/page/%s",
host.c_str(), host.c_str(),

View File

@ -1,25 +1,14 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved. // reserved. Use of this source code is governed by a BSD-style license that can
// Use of this source code is governed by a BSD-style license that can be // be found in the LICENSE file.
// found in the LICENSE file.
#include "libcef/browser/devtools_scheme_handler.h" #include "libcef/browser/devtools_scheme_handler.h"
#include <string> #include <string>
#include "libcef/browser/internal_scheme_handler.h"
#include "include/cef_browser.h"
#include "include/cef_request.h"
#include "include/cef_resource_handler.h"
#include "include/cef_response.h"
#include "include/cef_scheme.h"
#include "include/cef_stream.h"
#include "include/cef_url.h"
#include "base/file_util.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "content/public/common/content_client.h"
#include "grit/devtools_resources_map.h" #include "grit/devtools_resources_map.h"
#include "ui/base/resource/resource_bundle.h"
namespace scheme {
const char kChromeDevToolsScheme[] = "chrome-devtools"; const char kChromeDevToolsScheme[] = "chrome-devtools";
const char kChromeDevToolsHost[] = "devtools"; const char kChromeDevToolsHost[] = "devtools";
@ -27,119 +16,37 @@ const char kChromeDevToolsURL[] = "chrome-devtools://devtools/";
namespace { namespace {
static std::string PathWithoutParams(const std::string& path) { class Delegate : public InternalHandlerDelegate {
size_t query_position = path.find("?");
if (query_position != std::string::npos)
return path.substr(0, query_position);
return path;
}
static std::string GetMimeType(const std::string& filename) {
if (EndsWith(filename, ".html", false)) {
return "text/html";
} else if (EndsWith(filename, ".css", false)) {
return "text/css";
} else if (EndsWith(filename, ".js", false)) {
return "application/javascript";
} else if (EndsWith(filename, ".png", false)) {
return "image/png";
} else if (EndsWith(filename, ".gif", false)) {
return "image/gif";
}
NOTREACHED();
return "text/plain";
}
class DevToolsSchemeHandler : public CefResourceHandler {
public: public:
DevToolsSchemeHandler(const std::string& path, Delegate() {}
CefRefPtr<CefStreamReader> reader,
int size)
: path_(path), reader_(reader), size_(size) {
}
virtual bool ProcessRequest(CefRefPtr<CefRequest> request, virtual bool OnRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback) Action* action) OVERRIDE {
OVERRIDE { GURL url = GURL(request->GetURL().ToString());
callback->Continue(); std::string path = url.path();
return true; if (path.length() > 0)
} path = path.substr(1);
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE {
response_length = size_;
response->SetMimeType(GetMimeType(path_));
response->SetStatus(200);
}
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback)
OVERRIDE {
bytes_read = reader_->Read(data_out, 1, bytes_to_read);
return (bytes_read > 0);
}
virtual void Cancel() OVERRIDE {
}
private:
std::string path_;
CefRefPtr<CefStreamReader> reader_;
int size_;
IMPLEMENT_REFCOUNTING(DevToolSSchemeHandler);
};
class DevToolsSchemeHandlerFactory : public CefSchemeHandlerFactory {
public:
DevToolsSchemeHandlerFactory() {}
virtual CefRefPtr<CefResourceHandler> Create(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& scheme_name,
CefRefPtr<CefRequest> request) OVERRIDE {
std::string url = PathWithoutParams(request->GetURL());
const char* path = &url.c_str()[strlen(kChromeDevToolsURL)];
int size = -1;
CefRefPtr<CefStreamReader> reader = GetStreamReader(path, size);
if (!reader.get())
return NULL;
return new DevToolsSchemeHandler(path, reader, size);
}
CefRefPtr<CefStreamReader> GetStreamReader(const char* path, int& size) {
// Create a stream for the grit resource.
for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) {
if (base::strcasecmp(kDevtoolsResources[i].name, path) == 0) { if (base::strcasecmp(kDevtoolsResources[i].name,
base::StringPiece piece = path.c_str()) == 0) {
content::GetContentClient()->GetDataResource( action->resource_id = kDevtoolsResources[i].value;
kDevtoolsResources[i].value, ui::SCALE_FACTOR_NONE); return true;
if (!piece.empty()) {
size = piece.size();
return CefStreamReader::CreateForData(const_cast<char*>(piece.data()),
size);
}
} }
} }
NOTREACHED() << "Missing DevTools resource: " << path; return false;
return NULL;
} }
IMPLEMENT_REFCOUNTING(DevToolSSchemeHandlerFactory);
}; };
} // namespace } // namespace
// Register the DevTools scheme handler. void RegisterChromeDevToolsHandler() {
void RegisterDevToolsSchemeHandler() { CefRegisterSchemeHandlerFactory(
CefRegisterSchemeHandlerFactory(kChromeDevToolsScheme, kChromeDevToolsHost, kChromeDevToolsScheme,
new DevToolsSchemeHandlerFactory()); kChromeDevToolsHost,
CreateInternalHandlerFactory(
make_scoped_ptr<InternalHandlerDelegate>(new Delegate())));
} }
} // namespace scheme

View File

@ -6,11 +6,15 @@
#define CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ #define CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_
#pragma once #pragma once
namespace scheme {
extern const char kChromeDevToolsScheme[]; extern const char kChromeDevToolsScheme[];
extern const char kChromeDevToolsHost[]; extern const char kChromeDevToolsHost[];
extern const char kChromeDevToolsURL[]; extern const char kChromeDevToolsURL[];
// Register the DevTools scheme handler. // Register the chrome-devtools scheme handler.
void RegisterDevToolsSchemeHandler(); void RegisterChromeDevToolsHandler();
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ #endif // CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_

View File

@ -0,0 +1,178 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 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.
#include "libcef/browser/internal_scheme_handler.h"
#include <string>
#include "base/string_util.h"
#include "content/public/common/content_client.h"
#include "ui/base/resource/resource_bundle.h"
namespace scheme {
namespace {
static std::string GetMimeType(const std::string& filename) {
if (EndsWith(filename, ".html", false)) {
return "text/html";
} else if (EndsWith(filename, ".css", false)) {
return "text/css";
} else if (EndsWith(filename, ".jpg", false)) {
return "image/jpeg";
} else if (EndsWith(filename, ".js", false)) {
return "application/javascript";
} else if (EndsWith(filename, ".png", false)) {
return "image/png";
} else if (EndsWith(filename, ".gif", false)) {
return "image/gif";
}
NOTREACHED() << "No known mime type for file: " << filename.c_str();
return "text/plain";
}
class RedirectHandler : public CefResourceHandler {
public:
explicit RedirectHandler(const GURL& url)
: url_(url) {
}
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback) OVERRIDE {
callback->Continue();
return true;
}
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE {
response_length = 0;
redirectUrl = url_.spec();
}
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback) OVERRIDE {
return false;
}
virtual void Cancel() OVERRIDE {
}
private:
GURL url_;
IMPLEMENT_REFCOUNTING(RedirectHandler);
};
class InternalHandler : public CefResourceHandler {
public:
InternalHandler(const std::string& mime_type,
CefRefPtr<CefStreamReader> reader,
int size)
: mime_type_(mime_type),
reader_(reader),
size_(size) {
}
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback) OVERRIDE {
callback->Continue();
return true;
}
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE {
response_length = size_;
response->SetMimeType(mime_type_);
response->SetStatus(200);
}
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback) OVERRIDE {
bytes_read = reader_->Read(data_out, 1, bytes_to_read);
return (bytes_read > 0);
}
virtual void Cancel() OVERRIDE {
}
private:
std::string mime_type_;
CefRefPtr<CefStreamReader> reader_;
int size_;
IMPLEMENT_REFCOUNTING(InternalHandler);
};
class InternalHandlerFactory : public CefSchemeHandlerFactory {
public:
explicit InternalHandlerFactory(
scoped_ptr<InternalHandlerDelegate> delegate)
: delegate_(delegate.Pass()) {
}
virtual CefRefPtr<CefResourceHandler> Create(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& scheme_name,
CefRefPtr<CefRequest> request) OVERRIDE {
GURL url = GURL(request->GetURL().ToString());
InternalHandlerDelegate::Action action;
if (delegate_->OnRequest(request, &action)) {
if (!action.redirect_url.is_empty() && action.redirect_url.is_valid())
return new RedirectHandler(action.redirect_url);
if (action.mime_type.empty())
action.mime_type = GetMimeType(url.path());
if (action.resource_id >= 0) {
base::StringPiece piece = content::GetContentClient()->GetDataResource(
action.resource_id, ui::SCALE_FACTOR_NONE);
if (!piece.empty()) {
action.stream =
CefStreamReader::CreateForData(const_cast<char*>(piece.data()),
piece.size());
action.stream_size = piece.size();
} else {
NOTREACHED() << "Failed to load internal resource for id: " <<
action.resource_id << " URL: " << url.spec().c_str();
return NULL;
}
}
if (action.stream.get()) {
return new InternalHandler(action.mime_type, action.stream,
action.stream_size);
}
}
return NULL;
}
private:
scoped_ptr<InternalHandlerDelegate> delegate_;
IMPLEMENT_REFCOUNTING(InternalHandlerFactory);
};
} // namespace
InternalHandlerDelegate::Action::Action()
: stream_size(-1),
resource_id(-1) {
}
CefRefPtr<CefSchemeHandlerFactory> CreateInternalHandlerFactory(
scoped_ptr<InternalHandlerDelegate> delegate) {
DCHECK(delegate.get());
return new InternalHandlerFactory(delegate.Pass());
}
} // namespace scheme

View File

@ -0,0 +1,53 @@
// Copyright (c) 2012 The Chromium Embedded Framework 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_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_
#define CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_
#pragma once
#include <string>
#include "include/cef_scheme.h"
#include "base/memory/scoped_ptr.h"
#include "googleurl/src/gurl.h"
namespace scheme {
// All methods will be called on the browser process IO thread.
class InternalHandlerDelegate {
public:
class Action {
public:
Action();
// Set to the appropriate value or leave empty to have it determined based
// on the file extension.
std::string mime_type;
// Option 1: Provide a stream for the resource contents. Set |stream_size|
// to the stream size or to -1 if unknown.
CefRefPtr<CefStreamReader> stream;
int stream_size;
// Option 2: Specify a resource id to load static content.
int resource_id;
// Option 3: Redirect to the specified URL.
GURL redirect_url;
};
virtual ~InternalHandlerDelegate() {}
// Populate |action| and return true if the request was handled.
virtual bool OnRequest(CefRefPtr<CefRequest> request,
Action* action) = 0;
};
// Create an internal scheme handler factory. The factory will take ownership of
// |delegate|.
CefRefPtr<CefSchemeHandlerFactory> CreateInternalHandlerFactory(
scoped_ptr<InternalHandlerDelegate> delegate);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_INTERNAL_SCHEME_HANDLER_H_

View File

@ -10,8 +10,8 @@
#include "libcef/browser/browser_context.h" #include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_host_impl.h" #include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/devtools_scheme_handler.h"
#include "libcef/browser/resource_request_job.h" #include "libcef/browser/resource_request_job.h"
#include "libcef/browser/scheme_registration.h"
#include "libcef/browser/thread_util.h" #include "libcef/browser/thread_util.h"
#include "libcef/browser/url_request_context_getter.h" #include "libcef/browser/url_request_context_getter.h"
#include "libcef/common/request_impl.h" #include "libcef/common/request_impl.h"
@ -310,8 +310,8 @@ bool CefClearSchemeHandlerFactories() {
if (CEF_CURRENTLY_ON(CEF_IOT)) { if (CEF_CURRENTLY_ON(CEF_IOT)) {
CefUrlRequestManager::GetInstance()->ClearFactories(); CefUrlRequestManager::GetInstance()->ClearFactories();
// Re-register the DevTools scheme handler. // Register internal scheme handlers.
RegisterDevToolsSchemeHandler(); scheme::RegisterInternalHandlers();
} else { } else {
CEF_POST_TASK(CEF_IOT, CEF_POST_TASK(CEF_IOT,
base::Bind(base::IgnoreResult(&CefClearSchemeHandlerFactories))); base::Bind(base::IgnoreResult(&CefClearSchemeHandlerFactories)));

View File

@ -0,0 +1,44 @@
// Copyright (c) 2012 The Chromium Embedded Framework 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 "libcef/browser/scheme_registration.h"
#include "libcef/browser/chrome_scheme_handler.h"
#include "libcef/browser/devtools_scheme_handler.h"
#include "libcef/renderer/content_renderer_client.h"
namespace scheme {
void AddStandardSchemes(std::vector<std::string>* standard_schemes) {
static struct {
const char* name;
bool is_local;
bool is_display_isolated;
} schemes[] = {
{ scheme::kChromeScheme, true, true },
{ scheme::kChromeDevToolsScheme, true, false }
};
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i)
standard_schemes->push_back(schemes[i].name);
if (CefContentRendererClient::Get()) {
// Running in single-process mode. Register the schemes with WebKit.
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) {
CefContentRendererClient::Get()->AddCustomScheme(
schemes[i].name, schemes[i].is_local, schemes[i].is_display_isolated);
}
}
}
void RegisterInternalHandlers() {
scheme::RegisterChromeHandler();
scheme::RegisterChromeDevToolsHandler();
}
void DidFinishLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url) {
if (validated_url.scheme() == scheme::kChromeScheme)
scheme::DidFinishChromeLoad(frame, validated_url);
}
} // namespace scheme

View File

@ -0,0 +1,27 @@
// Copyright (c) 2012 The Chromium Embedded Framework 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_LIBCEF_BROWSER_SCHEME_IMPL_H_
#define CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_
#pragma once
#include <string>
#include <vector>
#include "include/cef_frame.h"
#include "googleurl/src/gurl.h"
namespace scheme {
// Add all standard schemes.
void AddStandardSchemes(std::vector<std::string>* standard_schemes);
// Register all internal scheme handlers.
void RegisterInternalHandlers();
// Used to fire any asynchronous content updates.
void DidFinishLoad(CefRefPtr<CefFrame> frame, const GURL& validated_url);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_SCHEME_IMPL_H_

View File

@ -5,10 +5,9 @@
#include "libcef/common/content_client.h" #include "libcef/common/content_client.h"
#include "include/cef_stream.h" #include "include/cef_stream.h"
#include "include/cef_version.h" #include "include/cef_version.h"
#include "libcef/browser/devtools_scheme_handler.h" #include "libcef/browser/scheme_registration.h"
#include "libcef/common/cef_switches.h" #include "libcef/common/cef_switches.h"
#include "libcef/common/scheme_registrar_impl.h" #include "libcef/common/scheme_registrar_impl.h"
#include "libcef/renderer/content_renderer_client.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
@ -54,12 +53,7 @@ void CefContentClient::AddAdditionalSchemes(
DCHECK(schemeRegistrar->VerifyRefCount()); DCHECK(schemeRegistrar->VerifyRefCount());
} }
standard_schemes->push_back(kChromeDevToolsScheme); scheme::AddStandardSchemes(standard_schemes);
if (CefContentRendererClient::Get()) {
// Register the DevTools scheme with WebKit.
CefContentRendererClient::Get()->AddCustomScheme(kChromeDevToolsScheme,
true, false);
}
} }
std::string CefContentClient::GetUserAgent() const { std::string CefContentClient::GetUserAgent() const {

View File

@ -0,0 +1,123 @@
<!DOCTYPE HTML>
<!--
about:version template page
-->
<html id="t" i18n-values="dir:textdirection;">
<head>
<title>About Version</title>
<style>/* Copyright (c) 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. */
body {
background-color: white;
color: black;
font-family: Helvetica,Arial,sans-serif;
margin: 0;
}
#outer {
margin-left: auto;
margin-right: auto;
margin-top: 10px;
width: 820px;
}
#inner {
padding-top: 10px;
width: 550px;
}
.label {
-webkit-padding-end: 5px;
font-size: 0.9em;
font-weight: bold;
text-align: end;
white-space: nowrap;
}
.label:after {
content: ':';
}
#logo {
float: right;
margin-left: 40px;
text-align: right;
width: 200px;
}
#company {
font-size: 0.7em;
text-align: right;
}
#copyright {
font-size: 0.7em;
text-align: right;
}
.value {
font-family: monospace;
max-width: 430px;
padding-left: 5px;
}
</style>
</head>
<body>
<div id="outer">
<div id="logo">
<div id="company">Chromium Embedded Framework (CEF)</div>
<div id="copyright">Copyright &copy; $$YEAR$$ The Chromium Embedded Framework Authors.<br/>All rights reserved.<br/><a href="chrome://license">license</a> | <a href="chrome://credits">credits</a></div>
</div>
<table id="inner" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="label" valign="top">CEF</td>
<td class="value">$$CEF$$</td>
</tr>
<tr>
<td class="label" valign="top">Chromium</td>
<td class="value">$$CHROMIUM$$</td>
</tr>
<tr>
<td class="label" valign="top">OS</td>
<td class="value">$$OS$$</td>
</tr>
<tr>
<td class="label" valign="top">WebKit</td>
<td class="value">$$WEBKIT$$</td>
</tr>
<tr>
<td class="label" valign="top">JavaScript</td>
<td class="value">$$JAVASCRIPT$$</td>
</tr>
<tr><td class="label" valign="top">Flash</td>
<td class="value" id="flash">$$FLASH$$</td>
</tr>
<tr>
<td class="label" valign="top">User Agent</td>
<td class="value">$$USERAGENT$$</td>
</tr>
<tr>
<td class="label" valign="top">Command Line</td>
<td class="value">$$COMMANDLINE$$</td>
</tr>
<tr>
<td class="label" valign="top">Module Path</td>
<td class="value">$$MODULEPATH$$</td>
</tr>
<tr>
<td class="label" valign="top">Cache Path</td>
<td class="value">$$CACHEPATH$$</td>
</tr>
</table>
</div>
</body>
</html>

View File

@ -10,6 +10,11 @@
<release seq="1"> <release seq="1">
<includes> <includes>
<include name="IDR_CEF_DEVTOOLS_DISCOVERY_PAGE" file="devtools_discovery_page.html" type="BINDATA" /> <include name="IDR_CEF_DEVTOOLS_DISCOVERY_PAGE" file="devtools_discovery_page.html" type="BINDATA" />
<include name="IDR_CEF_CREDITS_HTML" file="..\..\..\chrome\browser\resources\about_credits.html" type="BINDATA" />
<include name="IDR_CEF_CREDITS_JS" file="..\..\..\chrome\browser\resources\about_credits.js" type="BINDATA" />
<include name="IDR_CEF_CREDITS_SWIFTSHADER_JPG" file="..\..\..\chrome\browser\resources\swiftshader.jpg" type="BINDATA" />
<include name="IDR_CEF_LICENSE_TXT" file="..\..\LICENSE.txt" type="BINDATA" />
<include name="IDR_CEF_VERSION_HTML" file="about_version.html" type="BINDATA" />
</includes> </includes>
</release> </release>
</grit> </grit>

View File

@ -95,8 +95,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,CHROME_VERSION_BUILD,CEF_REVISION,0 FILEVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
PRODUCTVERSION 3,CHROME_VERSION_BUILD,CEF_REVISION,0 PRODUCTVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -112,12 +112,12 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileDescription", "Chromium Embedded Framework (CEF) Dynamic Link Library" VALUE "FileDescription", "Chromium Embedded Framework (CEF) Dynamic Link Library"
VALUE "FileVersion", "3." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION) VALUE "FileVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
VALUE "InternalName", "libcef" VALUE "InternalName", "libcef"
VALUE "LegalCopyright", "Copyright (C) " MAKE_STRING(COPYRIGHT_YEAR) " The Chromium Embedded Framework Authors" VALUE "LegalCopyright", "Copyright (C) " MAKE_STRING(COPYRIGHT_YEAR) " The Chromium Embedded Framework Authors"
VALUE "OriginalFilename", "libcef.dll" VALUE "OriginalFilename", "libcef.dll"
VALUE "ProductName", "Chromium Embedded Framework (CEF) Dynamic Link Library" VALUE "ProductName", "Chromium Embedded Framework (CEF) Dynamic Link Library"
VALUE "ProductVersion", "3." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION) VALUE "ProductVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -109,3 +109,11 @@ def make_dir(name, quiet = True):
def get_files(search_glob): def get_files(search_glob):
""" Returns all files matching the search glob. """ """ Returns all files matching the search glob. """
return iglob(search_glob) return iglob(search_glob)
def read_version_file(file, args):
""" Read and parse a version file (key=value pairs, one per line). """
lines = read_file(file).split("\n")
for line in lines:
parts = line.split('=', 1)
if len(parts) == 2:
args[parts[0]] = parts[1]

View File

@ -16,7 +16,8 @@ RunAction(cef_dir, gyper)
print "\nGenerating CEF version header file..." print "\nGenerating CEF version header file..."
gyper = [ 'python', 'tools/make_version_header.py', gyper = [ 'python', 'tools/make_version_header.py',
'--header', 'include/cef_version.h', '--header', 'include/cef_version.h',
'--version', '../chrome/VERSION' ] '--cef_version', 'VERSION',
'--chrome_version', '../chrome/VERSION' ]
RunAction(cef_dir, gyper) RunAction(cef_dir, gyper)
print "\nPatching build configuration and source files for CEF..." print "\nPatching build configuration and source files for CEF..."

View File

@ -1,470 +1,467 @@
# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights # Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that # reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file. # can be found in the LICENSE file.
from date_util import * from date_util import *
from file_util import * from file_util import *
from gclient_util import * from gclient_util import *
from optparse import OptionParser from optparse import OptionParser
import os import os
import re import re
import shlex import shlex
import subprocess import subprocess
from svn_util import * from svn_util import *
import sys import sys
import zipfile import zipfile
def create_archive(input_dir, zip_file): def create_archive(input_dir, zip_file):
""" Creates a zip archive of the specified input directory. """ """ Creates a zip archive of the specified input directory. """
zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED)
def addDir(dir): def addDir(dir):
for f in os.listdir(dir): for f in os.listdir(dir):
full_path = os.path.join(dir, f) full_path = os.path.join(dir, f)
if os.path.isdir(full_path): if os.path.isdir(full_path):
addDir(full_path) addDir(full_path)
else: else:
zf.write(full_path, os.path.relpath(full_path, \ zf.write(full_path, os.path.relpath(full_path, \
os.path.join(input_dir, os.pardir))) os.path.join(input_dir, os.pardir)))
addDir(input_dir) addDir(input_dir)
zf.close() zf.close()
def create_readme(src, output_dir, cef_url, cef_rev, cef_ver, chromium_url, \ def create_readme(src, output_dir, cef_url, cef_rev, cef_ver, chromium_url, \
chromium_rev, chromium_ver, date): chromium_rev, chromium_ver, date):
""" Creates the README.TXT file. """ """ Creates the README.TXT file. """
data = read_file(src) data = read_file(src)
data = data.replace('$CEF_URL$', cef_url) data = data.replace('$CEF_URL$', cef_url)
data = data.replace('$CEF_REV$', cef_rev) data = data.replace('$CEF_REV$', cef_rev)
data = data.replace('$CEF_VER$', cef_ver) data = data.replace('$CEF_VER$', cef_ver)
data = data.replace('$CHROMIUM_URL$', chromium_url) data = data.replace('$CHROMIUM_URL$', chromium_url)
data = data.replace('$CHROMIUM_REV$', chromium_rev) data = data.replace('$CHROMIUM_REV$', chromium_rev)
data = data.replace('$CHROMIUM_VER$', chromium_ver) data = data.replace('$CHROMIUM_VER$', chromium_ver)
data = data.replace('$DATE$', date) data = data.replace('$DATE$', date)
write_file(os.path.join(output_dir, 'README.txt'), data) write_file(os.path.join(output_dir, 'README.txt'), data)
if not options.quiet: if not options.quiet:
sys.stdout.write('Creating README.TXT file.\n') sys.stdout.write('Creating README.TXT file.\n')
def eval_file(src): def eval_file(src):
""" Loads and evaluates the contents of the specified file. """ """ Loads and evaluates the contents of the specified file. """
return eval(read_file(src), {'__builtins__': None}, None) return eval(read_file(src), {'__builtins__': None}, None)
def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet): def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet):
""" Transfer files from one location to another. """ """ Transfer files from one location to another. """
for path in gypi_paths: for path in gypi_paths:
# skip gyp includes # skip gyp includes
if path[:2] == '<@': if path[:2] == '<@':
continue continue
src = os.path.join(src_dir, path) src = os.path.join(src_dir, path)
dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, '')) dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, ''))
dst_path = os.path.dirname(dst) dst_path = os.path.dirname(dst)
make_dir(dst_path, quiet) make_dir(dst_path, quiet)
copy_file(src, dst, quiet) copy_file(src, dst, quiet)
def normalize_headers(file, new_path = ''): def normalize_headers(file, new_path = ''):
""" Normalize headers post-processing. Remove the path component from any """ Normalize headers post-processing. Remove the path component from any
project include directives. """ project include directives. """
data = read_file(file) data = read_file(file)
data = re.sub(r'''#include \"(?!include\/)[a-zA-Z0-9_\/]+\/+([a-zA-Z0-9_\.]+)\"''', \ data = re.sub(r'''#include \"(?!include\/)[a-zA-Z0-9_\/]+\/+([a-zA-Z0-9_\.]+)\"''', \
"// Include path modified for CEF Binary Distribution.\n#include \""+new_path+"\\1\"", data) "// Include path modified for CEF Binary Distribution.\n#include \""+new_path+"\\1\"", data)
write_file(file, data) write_file(file, data)
def transfer_files(cef_dir, script_dir, transfer_cfg, output_dir, quiet): def transfer_files(cef_dir, script_dir, transfer_cfg, output_dir, quiet):
""" Transfer files based on the specified configuration. """ """ Transfer files based on the specified configuration. """
if not path_exists(transfer_cfg): if not path_exists(transfer_cfg):
return return
configs = eval_file(transfer_cfg) configs = eval_file(transfer_cfg)
for cfg in configs: for cfg in configs:
dst = os.path.join(output_dir, cfg['target']) dst = os.path.join(output_dir, cfg['target'])
# perform a copy if source is specified # perform a copy if source is specified
if not cfg['source'] is None: if not cfg['source'] is None:
src = os.path.join(cef_dir, cfg['source']) src = os.path.join(cef_dir, cfg['source'])
dst_path = os.path.dirname(dst) dst_path = os.path.dirname(dst)
make_dir(dst_path, quiet) make_dir(dst_path, quiet)
copy_file(src, dst, quiet) copy_file(src, dst, quiet)
# place a readme file in the destination directory # place a readme file in the destination directory
readme = os.path.join(dst_path, 'README-TRANSFER.txt') readme = os.path.join(dst_path, 'README-TRANSFER.txt')
if not path_exists(readme): if not path_exists(readme):
copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme) copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme)
open(readme, 'ab').write(cfg['source']+"\n") open(readme, 'ab').write(cfg['source']+"\n")
# perform any required post-processing # perform any required post-processing
if 'post-process' in cfg: if 'post-process' in cfg:
post = cfg['post-process'] post = cfg['post-process']
if post == 'normalize_headers': if post == 'normalize_headers':
new_path = '' new_path = ''
if cfg.has_key('new_header_path'): if cfg.has_key('new_header_path'):
new_path = cfg['new_header_path'] new_path = cfg['new_header_path']
normalize_headers(dst, new_path) normalize_headers(dst, new_path)
def generate_msvs_projects(version): def generate_msvs_projects(version):
""" Generate MSVS projects for the specified version. """ """ Generate MSVS projects for the specified version. """
sys.stdout.write('Generating '+version+' project files...') sys.stdout.write('Generating '+version+' project files...')
os.environ['GYP_MSVS_VERSION'] = version os.environ['GYP_MSVS_VERSION'] = version
gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ] gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ]
RunAction(cef_dir, gyper); RunAction(cef_dir, gyper);
move_file(os.path.relpath(os.path.join(output_dir, 'cefclient.sln')), \ move_file(os.path.relpath(os.path.join(output_dir, 'cefclient.sln')), \
os.path.relpath(os.path.join(output_dir, 'cefclient'+version+'.sln'))) os.path.relpath(os.path.join(output_dir, 'cefclient'+version+'.sln')))
def fix_msvs_projects(): def fix_msvs_projects():
""" Fix the output directory path in all .vcproj and .vcxproj files. """ """ Fix the output directory path in all .vcproj and .vcxproj files. """
files = [] files = []
for file in get_files(os.path.join(output_dir, '*.vcproj')): for file in get_files(os.path.join(output_dir, '*.vcproj')):
files.append(file) files.append(file)
for file in get_files(os.path.join(output_dir, '*.vcxproj')): for file in get_files(os.path.join(output_dir, '*.vcxproj')):
files.append(file) files.append(file)
for file in files: for file in files:
data = read_file(file) data = read_file(file)
data = data.replace('../../..\\build\\', '') data = data.replace('../../..\\build\\', '')
write_file(file, data) write_file(file, data)
def run(command_line, working_dir): def run(command_line, working_dir):
""" Run a command. """ """ Run a command. """
sys.stdout.write('-------- Running "'+command_line+'" in "'+\ sys.stdout.write('-------- Running "'+command_line+'" in "'+\
working_dir+'"...'+"\n") working_dir+'"...'+"\n")
args = shlex.split(command_line.replace('\\', '\\\\')) args = shlex.split(command_line.replace('\\', '\\\\'))
return subprocess.check_call(args, cwd=working_dir, env=os.environ, return subprocess.check_call(args, cwd=working_dir, env=os.environ,
shell=(sys.platform == 'win32')) shell=(sys.platform == 'win32'))
# cannot be loaded as a module # cannot be loaded as a module
if __name__ != "__main__": if __name__ != "__main__":
sys.stderr.write('This file cannot be loaded as a module!') sys.stderr.write('This file cannot be loaded as a module!')
sys.exit() sys.exit()
# parse command-line options # parse command-line options
disc = """ disc = """
This utility builds the CEF Binary Distribution. This utility builds the CEF Binary Distribution.
""" """
parser = OptionParser(description=disc) parser = OptionParser(description=disc)
parser.add_option('--output-dir', dest='outputdir', metavar='DIR', parser.add_option('--output-dir', dest='outputdir', metavar='DIR',
help='output directory [required]') help='output directory [required]')
parser.add_option('--allow-partial', parser.add_option('--allow-partial',
action='store_true', dest='allowpartial', default=False, action='store_true', dest='allowpartial', default=False,
help='allow creation of partial distributions') help='allow creation of partial distributions')
parser.add_option('--no-symbols', parser.add_option('--no-symbols',
action='store_true', dest='nosymbols', default=False, action='store_true', dest='nosymbols', default=False,
help='do not create symbol files') help='do not create symbol files')
parser.add_option('-q', '--quiet', parser.add_option('-q', '--quiet',
action='store_true', dest='quiet', default=False, action='store_true', dest='quiet', default=False,
help='do not output detailed status information') help='do not output detailed status information')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
# the outputdir option is required # the outputdir option is required
if options.outputdir is None: if options.outputdir is None:
parser.print_help(sys.stdout) parser.print_help(sys.stdout)
sys.exit() sys.exit()
# script directory # script directory
script_dir = os.path.dirname(__file__) script_dir = os.path.dirname(__file__)
# CEF root directory # CEF root directory
cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
# src directory # src directory
src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir)) src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir))
# retrieve url, revision and date information # retrieve url, revision and date information
cef_info = get_svn_info(cef_dir) cef_info = get_svn_info(cef_dir)
cef_url = cef_info['url'] cef_url = cef_info['url']
cef_rev = cef_info['revision'] cef_rev = cef_info['revision']
chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir)) chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir))
chromium_url = chromium_info['url'] chromium_url = chromium_info['url']
chromium_rev = chromium_info['revision'] chromium_rev = chromium_info['revision']
date = get_date() date = get_date()
# Read and parse the version file (key=value pairs, one per line) # Read and parse the version file (key=value pairs, one per line)
chrome = {} args = {}
lines = read_file(os.path.join(cef_dir, '../chrome/VERSION')).split("\n") read_version_file('VERSION', args)
for line in lines: read_version_file('../chrome/VERSION', args)
parts = line.split('=', 1)
if len(parts) == 2: cef_ver = args['CEF_MAJOR']+'.'+args['BUILD']+'.'+cef_rev
chrome[parts[0]] = parts[1] chromium_ver = args['MAJOR']+'.'+args['MINOR']+'.'+args['BUILD']+'.'+args['PATCH']
cef_ver = '3.'+chrome['BUILD']+'.'+cef_rev # Test the operating system.
chromium_ver = chrome['MAJOR']+'.'+chrome['MINOR']+'.'+chrome['BUILD']+'.'+chrome['PATCH'] platform = '';
if sys.platform == 'win32':
# Test the operating system. platform = 'windows'
platform = ''; elif sys.platform == 'darwin':
if sys.platform == 'win32': platform = 'macosx'
platform = 'windows' elif sys.platform.startswith('linux'):
elif sys.platform == 'darwin': platform = 'linux'
platform = 'macosx'
elif sys.platform.startswith('linux'): # output directory
platform = 'linux' output_dir = os.path.abspath(os.path.join(options.outputdir, \
'cef_binary_'+cef_ver+'_'+platform))
# output directory remove_dir(output_dir, options.quiet)
output_dir = os.path.abspath(os.path.join(options.outputdir, \ make_dir(output_dir, options.quiet)
'cef_binary_'+cef_ver+'_'+platform))
remove_dir(output_dir, options.quiet) if not options.nosymbols:
make_dir(output_dir, options.quiet) # symbol directory
symbol_dir = os.path.abspath(os.path.join(options.outputdir, \
if not options.nosymbols: 'cef_binary_'+cef_ver+'_'+platform+'_symbols'))
# symbol directory remove_dir(symbol_dir, options.quiet)
symbol_dir = os.path.abspath(os.path.join(options.outputdir, \ make_dir(symbol_dir, options.quiet)
'cef_binary_'+cef_ver+'_'+platform+'_symbols'))
remove_dir(symbol_dir, options.quiet) # transfer the LICENSE.txt file
make_dir(symbol_dir, options.quiet) copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet)
# transfer the LICENSE.txt file # read the variables list from the autogenerated cef_paths.gypi file
copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet) cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi'))
cef_paths = cef_paths['variables']
# read the variables list from the autogenerated cef_paths.gypi file
cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi')) # read the variables list from the manually edited cef_paths2.gypi file
cef_paths = cef_paths['variables'] cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi'))
cef_paths2 = cef_paths2['variables']
# read the variables list from the manually edited cef_paths2.gypi file
cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi')) # create the include directory
cef_paths2 = cef_paths2['variables'] include_dir = os.path.join(output_dir, 'include')
make_dir(include_dir, options.quiet)
# create the include directory
include_dir = os.path.join(output_dir, 'include') # create the cefclient directory
make_dir(include_dir, options.quiet) cefclient_dir = os.path.join(output_dir, 'cefclient')
make_dir(cefclient_dir, options.quiet)
# create the cefclient directory
cefclient_dir = os.path.join(output_dir, 'cefclient') # create the libcef_dll_wrapper directory
make_dir(cefclient_dir, options.quiet) wrapper_dir = os.path.join(output_dir, 'libcef_dll')
make_dir(wrapper_dir, options.quiet)
# create the libcef_dll_wrapper directory
wrapper_dir = os.path.join(output_dir, 'libcef_dll') # transfer common include files
make_dir(wrapper_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \
'include/', include_dir, options.quiet)
# transfer common include files transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \
transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \ 'include/', include_dir, options.quiet)
'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \
transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \ 'include/', include_dir, options.quiet)
'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths['autogen_cpp_includes'], \
transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \ 'include/', include_dir, options.quiet)
'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \
transfer_gypi_files(cef_dir, cef_paths['autogen_cpp_includes'], \ 'include/', include_dir, options.quiet)
'include/', include_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \ # transfer common cefclient files
'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \
'tests/cefclient/', cefclient_dir, options.quiet)
# transfer common cefclient files
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \ # transfer common libcef_dll_wrapper files
'tests/cefclient/', cefclient_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \
'libcef_dll/', wrapper_dir, options.quiet)
# transfer common libcef_dll_wrapper files transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \
transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \ 'libcef_dll/', wrapper_dir, options.quiet)
'libcef_dll/', wrapper_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \ # transfer gyp files
'libcef_dll/', wrapper_dir, options.quiet) copy_file(os.path.join(script_dir, 'distrib/cefclient.gyp'), output_dir, options.quiet)
paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi')
# transfer gyp files data = read_file(paths_gypi)
copy_file(os.path.join(script_dir, 'distrib/cefclient.gyp'), output_dir, options.quiet) data = data.replace('tests/cefclient/', 'cefclient/')
paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi') write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data)
data = read_file(paths_gypi) copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \
data = data.replace('tests/cefclient/', 'cefclient/') os.path.join(output_dir, 'cef_paths.gypi'), options.quiet)
write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data)
copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \ # transfer additional files
os.path.join(output_dir, 'cef_paths.gypi'), options.quiet) transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.cfg'), \
output_dir, options.quiet)
# transfer additional files
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.cfg'), \ if platform == 'windows':
output_dir, options.quiet) # create the README.TXT file
create_readme(os.path.join(script_dir, 'distrib/win/README.txt'), output_dir, cef_url, \
if platform == 'windows': cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date)
# create the README.TXT file
create_readme(os.path.join(script_dir, 'distrib/win/README.txt'), output_dir, cef_url, \ # transfer include files
cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \
'include/', include_dir, options.quiet)
# transfer include files
transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \ # transfer cefclient files
'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \
'tests/cefclient/', cefclient_dir, options.quiet)
# transfer cefclient files
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \ # transfer build/Debug files
'tests/cefclient/', cefclient_dir, options.quiet) build_dir = os.path.join(src_dir, 'build/Debug');
if not options.allowpartial or path_exists(build_dir):
# transfer build/Debug files dst_dir = os.path.join(output_dir, 'Debug')
build_dir = os.path.join(src_dir, 'build/Debug'); make_dir(dst_dir, options.quiet)
if not options.allowpartial or path_exists(build_dir): copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet)
dst_dir = os.path.join(output_dir, 'Debug') copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet)
make_dir(dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet) copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \ # transfer lib/Debug files
options.quiet) dst_dir = os.path.join(output_dir, 'lib/Debug')
make_dir(dst_dir, options.quiet)
# transfer lib/Debug files copy_file(os.path.join(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet)
dst_dir = os.path.join(output_dir, 'lib/Debug') else:
make_dir(dst_dir, options.quiet) sys.stderr.write("No Debug build files.\n")
copy_file(os.path.join(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet)
else: # transfer build/Release files
sys.stderr.write("No Debug build files.\n") build_dir = os.path.join(src_dir, 'build/Release');
if not options.allowpartial or path_exists(build_dir):
# transfer build/Release files dst_dir = os.path.join(output_dir, 'Release')
build_dir = os.path.join(src_dir, 'build/Release'); make_dir(dst_dir, options.quiet)
if not options.allowpartial or path_exists(build_dir): copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet)
dst_dir = os.path.join(output_dir, 'Release') copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet)
make_dir(dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet) copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \ # transfer lib/Release files
options.quiet) dst_dir = os.path.join(output_dir, 'lib/Release')
make_dir(dst_dir, options.quiet)
# transfer lib/Release files copy_file(os.path.join(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet)
dst_dir = os.path.join(output_dir, 'lib/Release')
make_dir(dst_dir, options.quiet) if not options.nosymbols:
copy_file(os.path.join(build_dir, 'lib/libcef.lib'), dst_dir, options.quiet) # transfer symbols
copy_file(os.path.join(build_dir, 'libcef.pdb'), symbol_dir, options.quiet)
if not options.nosymbols: else:
# transfer symbols sys.stderr.write("No Release build files.\n")
copy_file(os.path.join(build_dir, 'libcef.pdb'), symbol_dir, options.quiet)
else: # generate doc files
sys.stderr.write("No Release build files.\n") os.popen('make_cppdocs.bat '+cef_rev)
# generate doc files # transfer docs files
os.popen('make_cppdocs.bat '+cef_rev) dst_dir = os.path.join(output_dir, 'docs')
src_dir = os.path.join(cef_dir, 'docs')
# transfer docs files if path_exists(src_dir):
dst_dir = os.path.join(output_dir, 'docs') copy_dir(src_dir, dst_dir, options.quiet)
src_dir = os.path.join(cef_dir, 'docs')
if path_exists(src_dir): # transfer additional files, if any
copy_dir(src_dir, dst_dir, options.quiet) transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/win/transfer.cfg'), \
output_dir, options.quiet)
# transfer additional files, if any
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/win/transfer.cfg'), \ # generate the project files
output_dir, options.quiet) generate_msvs_projects('2005');
generate_msvs_projects('2008');
# generate the project files generate_msvs_projects('2010');
generate_msvs_projects('2005'); fix_msvs_projects();
generate_msvs_projects('2008');
generate_msvs_projects('2010'); elif platform == 'macosx':
fix_msvs_projects(); # create the README.TXT file
create_readme(os.path.join(script_dir, 'distrib/mac/README.txt'), output_dir, cef_url, \
elif platform == 'macosx': cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date)
# create the README.TXT file
create_readme(os.path.join(script_dir, 'distrib/mac/README.txt'), output_dir, cef_url, \ # transfer include files
cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \
'include/', include_dir, options.quiet)
# transfer include files
transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \ # transfer cefclient files
'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac'], \
'tests/cefclient/', cefclient_dir, options.quiet)
# transfer cefclient files transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac_helper'], \
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac'], \ 'tests/cefclient/', cefclient_dir, options.quiet)
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac_helper'], \ # transfer cefclient/mac files
'tests/cefclient/', cefclient_dir, options.quiet) copy_dir(os.path.join(cef_dir, 'tests/cefclient/mac/'), os.path.join(output_dir, 'cefclient/mac/'), \
options.quiet)
# transfer cefclient/mac files
copy_dir(os.path.join(cef_dir, 'tests/cefclient/mac/'), os.path.join(output_dir, 'cefclient/mac/'), \ # transfer xcodebuild/Debug files
options.quiet) build_dir = os.path.join(src_dir, 'xcodebuild/Debug')
if not options.allowpartial or path_exists(build_dir):
# transfer xcodebuild/Debug files dst_dir = os.path.join(output_dir, 'Debug')
build_dir = os.path.join(src_dir, 'xcodebuild/Debug') make_dir(dst_dir, options.quiet)
if not options.allowpartial or path_exists(build_dir): copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet)
dst_dir = os.path.join(output_dir, 'Debug') copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet)
make_dir(dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet) else:
copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet) build_dir = None
copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet)
else: # transfer xcodebuild/Release files
build_dir = None build_dir = os.path.join(src_dir, 'xcodebuild/Release')
if not options.allowpartial or path_exists(build_dir):
# transfer xcodebuild/Release files dst_dir = os.path.join(output_dir, 'Release')
build_dir = os.path.join(src_dir, 'xcodebuild/Release') make_dir(dst_dir, options.quiet)
if not options.allowpartial or path_exists(build_dir): copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet)
dst_dir = os.path.join(output_dir, 'Release') copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet)
make_dir(dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'ffmpegsumo.so'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'libcef.dylib'), dst_dir, options.quiet) if not options.nosymbols:
copy_file(os.path.join(build_dir, 'libplugin_carbon_interpose.dylib'), dst_dir, options.quiet) # create the real dSYM file from the "fake" dSYM file
sys.stdout.write("Creating the real dSYM file...\n")
if not options.nosymbols: src_path = os.path.join(build_dir, 'libcef.dylib.dSYM/Contents/Resources/DWARF/libcef.dylib')
# create the real dSYM file from the "fake" dSYM file dst_path = os.path.join(symbol_dir, 'libcef.dylib.dSYM')
sys.stdout.write("Creating the real dSYM file...\n") run('dsymutil '+src_path+' -o '+dst_path, cef_dir)
src_path = os.path.join(build_dir, 'libcef.dylib.dSYM/Contents/Resources/DWARF/libcef.dylib') else:
dst_path = os.path.join(symbol_dir, 'libcef.dylib.dSYM') build_dir = None
run('dsymutil '+src_path+' -o '+dst_path, cef_dir)
else: if not build_dir is None:
build_dir = None # transfer resource files
dst_dir = os.path.join(output_dir, 'Resources')
if not build_dir is None: make_dir(dst_dir, options.quiet)
# transfer resource files copy_files(os.path.join(build_dir, 'cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/*.*'), \
dst_dir = os.path.join(output_dir, 'Resources') dst_dir, options.quiet)
make_dir(dst_dir, options.quiet)
copy_files(os.path.join(build_dir, 'cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/*.*'), \ # transfer additional files, if any
dst_dir, options.quiet) transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/mac/transfer.cfg'), \
output_dir, options.quiet)
# transfer additional files, if any
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/mac/transfer.cfg'), \ # Generate Xcode project files
output_dir, options.quiet) sys.stdout.write('Generating Xcode project files...')
gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ]
# Generate Xcode project files RunAction(cef_dir, gyper);
sys.stdout.write('Generating Xcode project files...')
gyper = [ 'python', 'tools/gyp_cef', os.path.relpath(os.path.join(output_dir, 'cefclient.gyp'), cef_dir) ] # Post-process the Xcode project to fix file paths
RunAction(cef_dir, gyper); src_file = os.path.join(output_dir, 'cefclient.xcodeproj/project.pbxproj')
data = read_file(src_file)
# Post-process the Xcode project to fix file paths data = data.replace('../../../build/mac/', 'tools/')
src_file = os.path.join(output_dir, 'cefclient.xcodeproj/project.pbxproj') data = data.replace('../../../build', 'build')
data = read_file(src_file) data = data.replace('../../../xcodebuild', 'xcodebuild')
data = data.replace('../../../build/mac/', 'tools/') write_file(src_file, data)
data = data.replace('../../../build', 'build')
data = data.replace('../../../xcodebuild', 'xcodebuild') elif platform == 'linux':
write_file(src_file, data) # create the README.TXT file
create_readme(os.path.join(script_dir, 'distrib/linux/README.txt'), output_dir, cef_url, \
elif platform == 'linux': cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date)
# create the README.TXT file
create_readme(os.path.join(script_dir, 'distrib/linux/README.txt'), output_dir, cef_url, \ # transfer out/Debug files
cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date) build_dir = os.path.join(src_dir, 'out/Debug');
if not options.allowpartial or path_exists(build_dir):
# transfer out/Debug files dst_dir = os.path.join(output_dir, 'Debug')
build_dir = os.path.join(src_dir, 'out/Debug'); make_dir(dst_dir, options.quiet)
if not options.allowpartial or path_exists(build_dir): copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
dst_dir = os.path.join(output_dir, 'Debug') copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
make_dir(dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet) copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) else:
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet) sys.stderr.write("No Debug build files.\n")
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
else: # transfer out/Release files
sys.stderr.write("No Debug build files.\n") build_dir = os.path.join(src_dir, 'out/Release');
if not options.allowpartial or path_exists(build_dir):
# transfer out/Release files dst_dir = os.path.join(output_dir, 'Release')
build_dir = os.path.join(src_dir, 'out/Release'); make_dir(dst_dir, options.quiet)
if not options.allowpartial or path_exists(build_dir): copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
dst_dir = os.path.join(output_dir, 'Release') copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
make_dir(dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet) copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) else:
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet) sys.stderr.write("No Release build files.\n")
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
else: # transfer include files
sys.stderr.write("No Release build files.\n") transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \
'include/', include_dir, options.quiet)
# transfer include files
transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \ # transfer cefclient files
'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \
'tests/cefclient/', cefclient_dir, options.quiet)
# transfer cefclient files
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \ # transfer additional files, if any
'tests/cefclient/', cefclient_dir, options.quiet) transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/linux/transfer.cfg'), \
output_dir, options.quiet)
# transfer additional files, if any
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/linux/transfer.cfg'), \ # Create an archive of the output directory
output_dir, options.quiet) zip_file = os.path.split(output_dir)[1] + '.zip'
if not options.quiet:
# Create an archive of the output directory sys.stdout.write('Creating '+zip_file+"...\n")
zip_file = os.path.split(output_dir)[1] + '.zip' create_archive(output_dir, os.path.join(output_dir, os.pardir, zip_file))
if not options.quiet:
sys.stdout.write('Creating '+zip_file+"...\n") if not options.nosymbols:
create_archive(output_dir, os.path.join(output_dir, os.pardir, zip_file)) # Create an archive of the symbol directory
zip_file = os.path.split(symbol_dir)[1] + '.zip'
if not options.nosymbols: if not options.quiet:
# Create an archive of the symbol directory sys.stdout.write('Creating '+zip_file+"...\n")
zip_file = os.path.split(symbol_dir)[1] + '.zip' create_archive(symbol_dir, os.path.join(symbol_dir, os.pardir, zip_file))
if not options.quiet:
sys.stdout.write('Creating '+zip_file+"...\n")
create_archive(symbol_dir, os.path.join(symbol_dir, os.pardir, zip_file))

View File

@ -1,2 +1,2 @@
@echo off @echo off
..\third_party\python_26\python.exe tools\make_version_header.py --header include\cef_version.h --version ../chrome/VERSION ..\third_party\python_26\python.exe tools\make_version_header.py --header include\cef_version.h --cef_version VERSION --chrome_version ../chrome/VERSION

View File

@ -23,7 +23,9 @@ This utility creates the version header file.
parser = OptionParser(description=disc) parser = OptionParser(description=disc)
parser.add_option('--header', dest='header', metavar='FILE', parser.add_option('--header', dest='header', metavar='FILE',
help='output version header file [required]') help='output version header file [required]')
parser.add_option('--version', dest='version', metavar='FILE', parser.add_option('--cef_version', dest='cef_version', metavar='FILE',
help='input CEF version config file [required]')
parser.add_option('--chrome_version', dest='chrome_version', metavar='FILE',
help='input Chrome version config file [required]') help='input Chrome version config file [required]')
parser.add_option('-q', '--quiet', parser.add_option('-q', '--quiet',
action='store_true', dest='quiet', default=False, action='store_true', dest='quiet', default=False,
@ -31,24 +33,22 @@ parser.add_option('-q', '--quiet',
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
# the header option is required # the header option is required
if options.header is None or options.version is None: if options.header is None or options.cef_version is None or options.chrome_version is None:
parser.print_help(sys.stdout) parser.print_help(sys.stdout)
sys.exit() sys.exit()
def write_svn_header(header, version): def write_svn_header(header, chrome_version, cef_version):
""" Creates the header file for the current revision and Chrome version information """ Creates the header file for the current revision and Chrome version information
if the information has changed or if the file doesn't already exist. """ if the information has changed or if the file doesn't already exist. """
if not path_exists(version): if not path_exists(chrome_version):
raise Exception('Version file '+version+' does not exist.') raise Exception('Chrome version file '+chrome_version+' does not exist.')
if not path_exists(cef_version):
raise Exception('CEF version file '+cef_version+' does not exist.')
# Read and parse the version file (key=value pairs, one per line) args = {}
chrome = {} read_version_file(chrome_version, args)
lines = read_file(version).split("\n") read_version_file(cef_version, args)
for line in lines:
parts = line.split('=', 1)
if len(parts) == 2:
chrome[parts[0]] = parts[1]
if path_exists(header): if path_exists(header):
oldcontents = read_file(header) oldcontents = read_file(header)
@ -97,12 +97,13 @@ def write_svn_header(header, version):
'//\n\n'+\ '//\n\n'+\
'#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\ '#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\
'#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\ '#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\
'#define CEF_VERSION_MAJOR ' + args['CEF_MAJOR'] + '\n'+\
'#define CEF_REVISION ' + revision + '\n'+\ '#define CEF_REVISION ' + revision + '\n'+\
'#define COPYRIGHT_YEAR ' + year + '\n\n'+\ '#define COPYRIGHT_YEAR ' + year + '\n\n'+\
'#define CHROME_VERSION_MAJOR ' + chrome['MAJOR'] + '\n'+\ '#define CHROME_VERSION_MAJOR ' + args['MAJOR'] + '\n'+\
'#define CHROME_VERSION_MINOR ' + chrome['MINOR'] + '\n'+\ '#define CHROME_VERSION_MINOR ' + args['MINOR'] + '\n'+\
'#define CHROME_VERSION_BUILD ' + chrome['BUILD'] + '\n'+\ '#define CHROME_VERSION_BUILD ' + args['BUILD'] + '\n'+\
'#define CHROME_VERSION_PATCH ' + chrome['PATCH'] + '\n\n'+\ '#define CHROME_VERSION_PATCH ' + args['PATCH'] + '\n\n'+\
'#define DO_MAKE_STRING(p) #p\n'+\ '#define DO_MAKE_STRING(p) #p\n'+\
'#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\
'#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\ '#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\
@ -125,7 +126,7 @@ def write_svn_header(header, version):
return False return False
written = write_svn_header(options.header, options.version) written = write_svn_header(options.header, options.chrome_version, options.cef_version)
if not options.quiet: if not options.quiet:
if written: if written:
sys.stdout.write('File '+options.header+' updated.\n') sys.stdout.write('File '+options.header+' updated.\n')