summaryrefslogtreecommitdiffstats
path: root/extensions/utility
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2014-11-06 10:50:01 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-06 18:50:26 +0000
commit3813023bde420950c60d9d12a8610510b76da337 (patch)
treec4c1a71be980404150fce8f9848ae4ac831fb0c8 /extensions/utility
parentba4eca9bf6691e4ed55eee55a0bcac1a932b7688 (diff)
downloadchromium_src-3813023bde420950c60d9d12a8610510b76da337.zip
chromium_src-3813023bde420950c60d9d12a8610510b76da337.tar.gz
chromium_src-3813023bde420950c60d9d12a8610510b76da337.tar.bz2
Add rudimentary UpdateService to app_shell
It can download a CRX from the web store using an ID given at the command line. This wires up utility process support for app_shell and establishes a base for factoring additional extensions utility IPCs out of //chrome in the near future. BUG=398671 TBR=asargent@chromium.org for cloned dependency on omaha_query_params Review URL: https://codereview.chromium.org/693233003 Cr-Commit-Position: refs/heads/master@{#303055}
Diffstat (limited to 'extensions/utility')
-rw-r--r--extensions/utility/BUILD.gn26
-rw-r--r--extensions/utility/DEPS3
-rw-r--r--extensions/utility/utility_handler.cc67
-rw-r--r--extensions/utility/utility_handler.h37
4 files changed, 133 insertions, 0 deletions
diff --git a/extensions/utility/BUILD.gn b/extensions/utility/BUILD.gn
new file mode 100644
index 0000000..ad884a2
--- /dev/null
+++ b/extensions/utility/BUILD.gn
@@ -0,0 +1,26 @@
+# Copyright 2014 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.
+
+import("//build/config/features.gni")
+
+assert(enable_extensions)
+
+# GYP version: extensions/extensions.gyp:extensions_utility
+source_set("utility") {
+ sources = [
+ "utility_handler.cc",
+ "utility_handler.h",
+ ]
+
+ deps = [
+ "//content/public/utility",
+ "//extensions/common",
+ ]
+
+ if (is_win) {
+ cflags = [
+ "/wd4267", # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ ]
+ }
+}
diff --git a/extensions/utility/DEPS b/extensions/utility/DEPS
new file mode 100644
index 0000000..8ad521e
--- /dev/null
+++ b/extensions/utility/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+content/public/utility",
+]
diff --git a/extensions/utility/utility_handler.cc b/extensions/utility/utility_handler.cc
new file mode 100644
index 0000000..1298933
--- /dev/null
+++ b/extensions/utility/utility_handler.cc
@@ -0,0 +1,67 @@
+// Copyright 2014 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 "extensions/utility/utility_handler.h"
+
+#include "base/command_line.h"
+#include "content/public/utility/utility_thread.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_l10n_util.h"
+#include "extensions/common/extension_utility_messages.h"
+#include "extensions/common/update_manifest.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_message_macros.h"
+#include "ui/base/ui_base_switches.h"
+
+namespace extensions {
+
+namespace {
+
+bool Send(IPC::Message* message) {
+ return content::UtilityThread::Get()->Send(message);
+}
+
+void ReleaseProcessIfNeeded() {
+ content::UtilityThread::Get()->ReleaseProcessIfNeeded();
+}
+
+} // namespace
+
+UtilityHandler::UtilityHandler() {
+}
+
+UtilityHandler::~UtilityHandler() {
+}
+
+// static
+void UtilityHandler::UtilityThreadStarted() {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ std::string lang = command_line->GetSwitchValueASCII(switches::kLang);
+ if (!lang.empty())
+ extension_l10n_util::SetProcessLocale(lang);
+}
+
+bool UtilityHandler::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(UtilityHandler, message)
+ IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_ParseUpdateManifest,
+ OnParseUpdateManifest)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void UtilityHandler::OnParseUpdateManifest(const std::string& xml) {
+ UpdateManifest manifest;
+ if (!manifest.Parse(xml)) {
+ Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Failed(
+ manifest.errors()));
+ } else {
+ Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded(
+ manifest.results()));
+ }
+ ReleaseProcessIfNeeded();
+}
+
+} // namespace extensions
diff --git a/extensions/utility/utility_handler.h b/extensions/utility/utility_handler.h
new file mode 100644
index 0000000..0ae31ec
--- /dev/null
+++ b/extensions/utility/utility_handler.h
@@ -0,0 +1,37 @@
+// Copyright 2014 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 EXTENSIONS_UTILITY_UTILITY_HANDLER_
+#define EXTENSIONS_UTILITY_UTILITY_HANDLER_
+
+#include <string>
+
+#include "base/macros.h"
+
+namespace IPC {
+class Message;
+}
+
+namespace extensions {
+
+// A handler for extensions-related IPC from within utility processes.
+class UtilityHandler {
+ public:
+ UtilityHandler();
+ ~UtilityHandler();
+
+ static void UtilityThreadStarted();
+
+ bool OnMessageReceived(const IPC::Message& message);
+
+ private:
+ // IPC message handlers.
+ void OnParseUpdateManifest(const std::string& xml);
+
+ DISALLOW_COPY_AND_ASSIGN(UtilityHandler);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_UTILITY_UTILITY_HANDLER_