2010-10-23 19:00:47 +02:00
|
|
|
// Copyright (c) 2010 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2006-2008 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 "base/compiler_specific.h"
|
|
|
|
|
2011-01-27 00:54:54 +01:00
|
|
|
#include "third_party/WebKit/Source/WebCore/config.h"
|
2010-10-23 19:00:47 +02:00
|
|
|
|
|
|
|
#include "browser_webkit_glue.h"
|
|
|
|
|
|
|
|
#undef LOG
|
|
|
|
#include "base/file_util.h"
|
|
|
|
#include "base/logging.h"
|
2011-01-07 22:34:20 +01:00
|
|
|
#include "base/mac/mac_util.h"
|
2010-10-23 19:00:47 +02:00
|
|
|
#include "base/path_service.h"
|
2011-09-23 02:16:03 +02:00
|
|
|
#include "base/utf_string_conversions.h"
|
2010-10-23 19:00:47 +02:00
|
|
|
#include "grit/webkit_resources.h"
|
2011-09-30 11:22:54 +02:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
2010-10-23 19:00:47 +02:00
|
|
|
#include "webkit/glue/webkit_glue.h"
|
|
|
|
|
2011-09-30 11:22:54 +02:00
|
|
|
|
2010-10-23 19:00:47 +02:00
|
|
|
namespace webkit_glue {
|
|
|
|
|
|
|
|
// Helper method for getting the path to the CEF resources directory.
|
|
|
|
FilePath GetResourcesFilePath() {
|
|
|
|
FilePath path;
|
|
|
|
// We need to know if we're bundled or not to know which path to use.
|
2011-01-07 22:34:20 +01:00
|
|
|
if (base::mac::AmIBundled()) {
|
2010-10-23 19:00:47 +02:00
|
|
|
PathService::Get(base::DIR_EXE, &path);
|
|
|
|
path = path.Append(FilePath::kParentDirectory);
|
|
|
|
return path.AppendASCII("Resources");
|
|
|
|
} else {
|
2010-11-15 16:39:56 +01:00
|
|
|
// TODO(port): Allow the embedder to customize the resource path.
|
2010-10-23 19:00:47 +02:00
|
|
|
PathService::Get(base::DIR_SOURCE_ROOT, &path);
|
|
|
|
path = path.AppendASCII("src");
|
|
|
|
path = path.AppendASCII("cef");
|
2010-11-15 16:39:56 +01:00
|
|
|
path = path.AppendASCII("tests");
|
|
|
|
path = path.AppendASCII("cefclient");
|
|
|
|
return path.AppendASCII("res");
|
2010-10-23 19:00:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
base::StringPiece GetDataResource(int resource_id) {
|
|
|
|
switch (resource_id) {
|
|
|
|
case IDR_BROKENIMAGE: {
|
|
|
|
// Use webkit's broken image icon (16x16)
|
|
|
|
static std::string broken_image_data;
|
|
|
|
if (broken_image_data.empty()) {
|
|
|
|
FilePath path = GetResourcesFilePath();
|
|
|
|
// In order to match WebKit's colors for the missing image, we have to
|
|
|
|
// use a PNG. The GIF doesn't have the color range needed to correctly
|
|
|
|
// match the TIFF they use in Safari.
|
|
|
|
path = path.AppendASCII("missingImage.png");
|
|
|
|
bool success = file_util::ReadFileToString(path, &broken_image_data);
|
|
|
|
if (!success) {
|
|
|
|
LOG(FATAL) << "Failed reading: " << path.value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return broken_image_data;
|
|
|
|
}
|
|
|
|
case IDR_TEXTAREA_RESIZER: {
|
|
|
|
// Use webkit's text area resizer image.
|
|
|
|
static std::string resize_corner_data;
|
|
|
|
if (resize_corner_data.empty()) {
|
|
|
|
FilePath path = GetResourcesFilePath();
|
|
|
|
path = path.AppendASCII("textAreaResizeCorner.png");
|
|
|
|
bool success = file_util::ReadFileToString(path, &resize_corner_data);
|
|
|
|
if (!success) {
|
|
|
|
LOG(FATAL) << "Failed reading: " << path.value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resize_corner_data;
|
|
|
|
}
|
2011-09-30 11:22:54 +02:00
|
|
|
|
2010-10-23 19:00:47 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-09-30 11:22:54 +02:00
|
|
|
|
|
|
|
base::StringPiece piece =
|
|
|
|
ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
|
|
|
|
DCHECK(!piece.empty());
|
|
|
|
return piece;
|
2010-10-23 19:00:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DidLoadPlugin(const std::string& filename) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void DidUnloadPlugin(const std::string& filename) {
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace webkit_glue
|