Commit e99bfcb9 authored by jamescook's avatar jamescook Committed by Commit bot

app_shell: Add experimental shellPrivate extension API

This gives us a place to experiment with app_shell-specific identity
work. Start with a throw-away "hello" API.

BUG=420189
TEST=extensions_unittests ShellPrivateApiTest.*

Review URL: https://codereview.chromium.org/623153004

Cr-Commit-Position: refs/heads/master@{#298164}
parent 0a0cad0d
...@@ -152,6 +152,8 @@ source_set("browser") { ...@@ -152,6 +152,8 @@ source_set("browser") {
"api/serial/serial_connection.h", "api/serial/serial_connection.h",
"api/serial/serial_event_dispatcher.cc", "api/serial/serial_event_dispatcher.cc",
"api/serial/serial_event_dispatcher.h", "api/serial/serial_event_dispatcher.h",
"api/shell_private/shell_private_api.cc",
"api/shell_private/shell_private_api.h",
"api/socket/socket.cc", "api/socket/socket.cc",
"api/socket/socket.h", "api/socket/socket.h",
"api/socket/socket_api.cc", "api/socket/socket_api.cc",
......
jamescook@chromium.org
rockot@chromium.org
// 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/browser/api/shell_private/shell_private_api.h"
namespace extensions {
ShellPrivatePrintHelloFunction::ShellPrivatePrintHelloFunction() {
}
ShellPrivatePrintHelloFunction::~ShellPrivatePrintHelloFunction() {
}
ExtensionFunction::ResponseAction ShellPrivatePrintHelloFunction::Run() {
// Warning so it shows in Release and avoids presubmit check for INFO.
LOG(WARNING) << "hello";
return RespondNow(NoArguments());
}
} // namespace extensions
// 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_BROWSER_API_SHELL_PRIVATE_SHELL_PRIVATE_API_H_
#define EXTENSIONS_BROWSER_API_SHELL_PRIVATE_SHELL_PRIVATE_API_H_
#include "base/macros.h"
#include "extensions/browser/extension_function.h"
namespace extensions {
// Synchronously prints "hello" to the console.
class ShellPrivatePrintHelloFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("shellPrivate.printHello", UNKNOWN);
ShellPrivatePrintHelloFunction();
protected:
virtual ~ShellPrivatePrintHelloFunction();
// ExtensionFunction:
virtual ResponseAction Run() override;
private:
DISALLOW_COPY_AND_ASSIGN(ShellPrivatePrintHelloFunction);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_API_SHELL_PRIVATE_SHELL_PRIVATE_API_H_
// 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/browser/api/shell_private/shell_private_api.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/browser/api_unittest.h"
namespace extensions {
typedef ApiUnitTest ShellPrivateApiTest;
// Verifies that the printHello function exists and can be called without
// crashing.
TEST_F(ShellPrivateApiTest, PrintHello) {
scoped_ptr<base::Value> result =
RunFunctionAndReturnValue(new ShellPrivatePrintHelloFunction, "[]");
// Function returns nothing.
EXPECT_FALSE(result.get());
}
} // namespace extensions
...@@ -170,6 +170,11 @@ ...@@ -170,6 +170,11 @@
"dependencies": ["permission:serial"], "dependencies": ["permission:serial"],
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
}, },
"shellPrivate": {
"channel": "trunk",
"extension_types": ["platform_app"],
"contexts": ["blessed_extension"]
},
"socket": { "socket": {
"dependencies": ["permission:socket"], "dependencies": ["permission:socket"],
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
'power.idl', 'power.idl',
'runtime.json', 'runtime.json',
'serial.idl', 'serial.idl',
'shell_private.idl',
'socket.idl', 'socket.idl',
'sockets_tcp.idl', 'sockets_tcp.idl',
'sockets_tcp_server.idl', 'sockets_tcp_server.idl',
......
// 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.
// <code>chrome.shellPrivate</code> API with experimental APIs for app_shell.
[nodoc] namespace shellPrivate {
interface Functions {
// Prints "hello" to the Chrome log.
static void printHello();
};
};
...@@ -420,6 +420,8 @@ ...@@ -420,6 +420,8 @@
'browser/api/serial/serial_connection.h', 'browser/api/serial/serial_connection.h',
'browser/api/serial/serial_event_dispatcher.cc', 'browser/api/serial/serial_event_dispatcher.cc',
'browser/api/serial/serial_event_dispatcher.h', 'browser/api/serial/serial_event_dispatcher.h',
'browser/api/shell_private/shell_private_api.cc',
'browser/api/shell_private/shell_private_api.h',
'browser/api/socket/socket.cc', 'browser/api/socket/socket.cc',
'browser/api/socket/socket.h', 'browser/api/socket/socket.h',
'browser/api/socket/socket_api.cc', 'browser/api/socket/socket_api.cc',
...@@ -1077,6 +1079,7 @@ ...@@ -1077,6 +1079,7 @@
'browser/api/declarative_webrequest/webrequest_condition_unittest.cc', 'browser/api/declarative_webrequest/webrequest_condition_unittest.cc',
'browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc', 'browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc',
'browser/api/power/power_api_unittest.cc', 'browser/api/power/power_api_unittest.cc',
'browser/api/shell_private/shell_private_api_unittest.cc',
'browser/api/sockets_tcp/sockets_tcp_api_unittest.cc', 'browser/api/sockets_tcp/sockets_tcp_api_unittest.cc',
'browser/api/storage/settings_quota_unittest.cc', 'browser/api/storage/settings_quota_unittest.cc',
'browser/api/storage/storage_api_unittest.cc', 'browser/api/storage/storage_api_unittest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment