diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 21:03:05 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 21:03:05 +0000 |
commit | 21fdcdd977e8ab479dd99c6d0d2f562dda98261d (patch) | |
tree | c4a954d46fcd6a19f4496961d668e73bc124135e /remoting | |
parent | c4a5d6e32dffa766ca4df79d5b2ed262a71c9440 (diff) | |
download | chromium_src-21fdcdd977e8ab479dd99c6d0d2f562dda98261d.zip chromium_src-21fdcdd977e8ab479dd99c6d0d2f562dda98261d.tar.gz chromium_src-21fdcdd977e8ab479dd99c6d0d2f562dda98261d.tar.bz2 |
Restrict the Chromoting client plugin to use by extensions & apps.
BUG=160456
Review URL: https://chromiumcodereview.appspot.com/11365276
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 26 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index f3d006c..4b2be13 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -23,6 +23,7 @@ #include "media/base/media.h" #include "net/socket/ssl_server_socket.h" #include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/dev/url_util_dev.h" #include "ppapi/cpp/input_event.h" #include "ppapi/cpp/mouse_cursor.h" #include "ppapi/cpp/rect.h" @@ -55,6 +56,9 @@ const int kBytesPerPixel = 4; const int kPerfStatsIntervalMs = 1000; +// URL scheme used by Chrome apps and extensions. +const char kChromeExtensionUrlScheme[] = "chrome-extension"; + std::string ConnectionStateToString(protocol::ConnectionToHost::State state) { // Values returned by this function must match the // remoting.ClientSession.State enum in JS code. @@ -217,6 +221,12 @@ bool ChromotingInstance::Init(uint32_t argc, return false; } + // Check that the calling content is part of an app or extension. + if (!IsCallerAppOrExtension()) { + LOG(ERROR) << "Not an app or extension"; + return false; + } + // Enable support for SSL server sockets, which must be done as early as // possible, preferably before any NSS SSL sockets (client or server) have // been created. @@ -754,6 +764,22 @@ void ChromotingInstance::ProcessLogToUI(const std::string& message) { g_logging_to_plugin = false; } +bool ChromotingInstance::IsCallerAppOrExtension() { + const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); + if (!url_util) + return false; + + PP_URLComponents_Dev url_components; + pp::Var url_var = url_util->GetDocumentURL(this, &url_components); + if (!url_var.is_string()) + return false; + + std::string url = url_var.AsString(); + std::string url_scheme = url.substr(url_components.scheme.begin, + url_components.scheme.len); + return url_scheme == kChromeExtensionUrlScheme; +} + bool ChromotingInstance::IsConnected() { return host_connection_.get() && (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h index 83e712b..44911c8 100644 --- a/remoting/client/plugin/chromoting_instance.h +++ b/remoting/client/plugin/chromoting_instance.h @@ -177,6 +177,9 @@ class ChromotingInstance : void ProcessLogToUI(const std::string& message); + // Returns true if the hosting content has the chrome-extension:// scheme. + bool IsCallerAppOrExtension(); + // Returns true if there is a ConnectionToHost and it is connected. bool IsConnected(); |