summaryrefslogtreecommitdiffstats
path: root/blimp/engine/common
diff options
context:
space:
mode:
authorhaibinlu <haibinlu@chromium.org>2015-10-07 18:09:40 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-08 01:12:12 +0000
commit6cc1cee477943c76596a9462bd9ba7c2042001a0 (patch)
tree2b3656a6b1371e49b7bdb74e71de534bbdec93b2 /blimp/engine/common
parentdfe296692906ae5f523071b77f24d0aaac584abb (diff)
downloadchromium_src-6cc1cee477943c76596a9462bd9ba7c2042001a0.zip
chromium_src-6cc1cee477943c76596a9462bd9ba7c2042001a0.tar.gz
chromium_src-6cc1cee477943c76596a9462bd9ba7c2042001a0.tar.bz2
[Blimp] Adds a headless content shell as a blimp engine. It uses a dummy screen, and is a slimming down version of the content shell.
It loads google.com as the initial URL. BUG=533592 Committed: https://crrev.com/ce6219fba3471bb7b4d295127eb34e734d14f499 Cr-Commit-Position: refs/heads/master@{#352902} Review URL: https://codereview.chromium.org/1364463003 Cr-Commit-Position: refs/heads/master@{#352999}
Diffstat (limited to 'blimp/engine/common')
-rw-r--r--blimp/engine/common/BUILD.gn16
-rw-r--r--blimp/engine/common/blimp_content_client.cc50
-rw-r--r--blimp/engine/common/blimp_content_client.h35
3 files changed, 101 insertions, 0 deletions
diff --git a/blimp/engine/common/BUILD.gn b/blimp/engine/common/BUILD.gn
new file mode 100644
index 0000000..48632dc
--- /dev/null
+++ b/blimp/engine/common/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2015 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.
+
+source_set("common") {
+ sources = [
+ "blimp_content_client.cc",
+ "blimp_content_client.h",
+ ]
+
+ deps = [
+ "//base",
+ "//content/public/common",
+ "//ui/base",
+ ]
+}
diff --git a/blimp/engine/common/blimp_content_client.cc b/blimp/engine/common/blimp_content_client.cc
new file mode 100644
index 0000000..00c2c2d
--- /dev/null
+++ b/blimp/engine/common/blimp_content_client.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2015 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 "blimp/engine/common/blimp_content_client.h"
+
+#include "content/public/common/user_agent.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+
+namespace blimp {
+namespace engine {
+
+// TODO(haibinlu) Generate proper version. See crbug/537367.
+const char kProduct[] = "Chrome/20.77.33.5";
+
+std::string GetBlimpEngineUserAgent() {
+ return content::BuildUserAgentFromProduct(kProduct);
+}
+
+BlimpContentClient::~BlimpContentClient() {}
+
+std::string BlimpContentClient::GetUserAgent() const {
+ return GetBlimpEngineUserAgent();
+}
+
+base::string16 BlimpContentClient::GetLocalizedString(int message_id) const {
+ return l10n_util::GetStringUTF16(message_id);
+}
+
+base::StringPiece BlimpContentClient::GetDataResource(
+ int resource_id,
+ ui::ScaleFactor scale_factor) const {
+ return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
+ resource_id, scale_factor);
+}
+
+base::RefCountedStaticMemory* BlimpContentClient::GetDataResourceBytes(
+ int resource_id) const {
+ return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
+ resource_id);
+}
+
+gfx::Image& BlimpContentClient::GetNativeImageNamed(int resource_id) const {
+ return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ resource_id);
+}
+
+} // namespace engine
+} // namespace blimp
diff --git a/blimp/engine/common/blimp_content_client.h b/blimp/engine/common/blimp_content_client.h
new file mode 100644
index 0000000..8826a62
--- /dev/null
+++ b/blimp/engine/common/blimp_content_client.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2015 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 BLIMP_ENGINE_COMMON_BLIMP_CONTENT_CLIENT_H_
+#define BLIMP_ENGINE_COMMON_BLIMP_CONTENT_CLIENT_H_
+
+#include <string>
+
+#include "content/public/common/content_client.h"
+
+namespace blimp {
+namespace engine {
+
+std::string GetBlimpEngineUserAgent();
+
+class BlimpContentClient : public content::ContentClient {
+ public:
+ ~BlimpContentClient() override;
+
+ // content::ContentClient implementation.
+ std::string GetUserAgent() const override;
+ base::string16 GetLocalizedString(int message_id) const override;
+ base::StringPiece GetDataResource(
+ int resource_id,
+ ui::ScaleFactor scale_factor) const override;
+ base::RefCountedStaticMemory* GetDataResourceBytes(
+ int resource_id) const override;
+ gfx::Image& GetNativeImageNamed(int resource_id) const override;
+};
+
+} // namespace engine
+} // namespace blimp
+
+#endif // BLIMP_ENGINE_COMMON_BLIMP_CONTENT_CLIENT_H_