forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ExtensionsRendererClient defines an interface for clients who wish to embed the extensions system into their renderer processes. This initial CL introduces two simple client methods to abstract away Chrome dependencies within UserScriptSlave. BUG=359836 R=yoz@chromium.org TBR=jochen@chromium.org for ChromeContentRendererClient Review URL: https://codereview.chromium.org/237833002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264097 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
rockot@chromium.org
committed
Apr 16, 2014
1 parent
98cb9ff
commit 60961f7
Showing
13 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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 "apps/shell/renderer/shell_extensions_renderer_client.h" | ||
|
||
namespace apps { | ||
|
||
ShellExtensionsRendererClient::ShellExtensionsRendererClient() {} | ||
|
||
ShellExtensionsRendererClient::~ShellExtensionsRendererClient() {} | ||
|
||
bool ShellExtensionsRendererClient::IsIncognitoProcess() const { | ||
// app_shell doesn't support off-the-record contexts. | ||
return false; | ||
} | ||
|
||
int ShellExtensionsRendererClient::GetLowestIsolatedWorldId() const { | ||
// app_shell doesn't need to reserve world IDs for anything other than | ||
// extensions, so we always return 1. Note that 0 is reserved for the global | ||
// world. | ||
return 1; | ||
} | ||
|
||
} // namespace apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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 APPS_SHELL_RENDERER_SHELL_EXTENSIONS_RENDERER_CLIENT_H_ | ||
#define APPS_SHELL_RENDERER_SHELL_EXTENSIONS_RENDERER_CLIENT_H_ | ||
|
||
#include "base/macros.h" | ||
#include "extensions/renderer/extensions_renderer_client.h" | ||
|
||
namespace apps { | ||
|
||
class ShellExtensionsRendererClient | ||
: public extensions::ExtensionsRendererClient { | ||
public: | ||
ShellExtensionsRendererClient(); | ||
virtual ~ShellExtensionsRendererClient(); | ||
|
||
// extensions::ExtensionsRendererClient implementation. | ||
virtual bool IsIncognitoProcess() const OVERRIDE; | ||
virtual int GetLowestIsolatedWorldId() const OVERRIDE; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(ShellExtensionsRendererClient); | ||
}; | ||
|
||
} // namespace apps | ||
|
||
#endif // APPS_SHELL_RENDERER_SHELL_EXTENSIONS_RENDERER_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
chrome/renderer/extensions/chrome_extensions_renderer_client.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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 "chrome/renderer/extensions/chrome_extensions_renderer_client.h" | ||
|
||
#include "base/lazy_instance.h" | ||
#include "chrome/renderer/chrome_render_process_observer.h" | ||
#include "chrome/renderer/isolated_world_ids.h" | ||
|
||
ChromeExtensionsRendererClient::ChromeExtensionsRendererClient() {} | ||
|
||
ChromeExtensionsRendererClient::~ChromeExtensionsRendererClient() {} | ||
|
||
// static | ||
ChromeExtensionsRendererClient* ChromeExtensionsRendererClient::GetInstance() { | ||
static base::LazyInstance<ChromeExtensionsRendererClient> client = | ||
LAZY_INSTANCE_INITIALIZER; | ||
return client.Pointer(); | ||
} | ||
|
||
bool ChromeExtensionsRendererClient::IsIncognitoProcess() const { | ||
return ChromeRenderProcessObserver::is_incognito_process(); | ||
} | ||
|
||
int ChromeExtensionsRendererClient::GetLowestIsolatedWorldId() const { | ||
return chrome::ISOLATED_WORLD_ID_EXTENSIONS; | ||
} |
28 changes: 28 additions & 0 deletions
28
chrome/renderer/extensions/chrome_extensions_renderer_client.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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 CHROME_RENDERER_EXTENSIONS_CHROME_EXTENSIONS_RENDERER_CLIENT_H_ | ||
#define CHROME_RENDERER_EXTENSIONS_CHROME_EXTENSIONS_RENDERER_CLIENT_H_ | ||
|
||
#include "base/macros.h" | ||
#include "extensions/renderer/extensions_renderer_client.h" | ||
|
||
class ChromeExtensionsRendererClient | ||
: public extensions::ExtensionsRendererClient { | ||
public: | ||
ChromeExtensionsRendererClient(); | ||
virtual ~ChromeExtensionsRendererClient(); | ||
|
||
// Get the LazyInstance for ChromeExtensionsRendererClient. | ||
static ChromeExtensionsRendererClient* GetInstance(); | ||
|
||
// extensions::ExtensionsRendererClient implementation. | ||
virtual bool IsIncognitoProcess() const OVERRIDE; | ||
virtual int GetLowestIsolatedWorldId() const OVERRIDE; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsRendererClient); | ||
}; | ||
|
||
#endif // CHROME_RENDERER_EXTENSIONS_CHROME_EXTENSIONS_RENDERER_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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/renderer/extensions_renderer_client.h" | ||
|
||
#include "base/basictypes.h" | ||
|
||
namespace extensions { | ||
|
||
namespace { | ||
|
||
ExtensionsRendererClient* g_client = NULL; | ||
|
||
} // namespace | ||
|
||
ExtensionsRendererClient* ExtensionsRendererClient::Get() { return g_client; } | ||
|
||
void ExtensionsRendererClient::Set(ExtensionsRendererClient* client) { | ||
g_client = client; | ||
} | ||
|
||
} // namespace extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_RENDERER_EXTENSIONS_RENDERER_CLIENT_H_ | ||
#define EXTENSIONS_RENDERER_EXTENSIONS_RENDERER_CLIENT_H_ | ||
|
||
namespace extensions { | ||
|
||
// Interface to allow the extensions module to make render-process-specific | ||
// queries of the embedder. Should be Set() once in the render process. | ||
// | ||
// NOTE: Methods that do not require knowledge of renderer concepts should be | ||
// added in ExtensionsClient (extensions/common/extensions_client.h) even if | ||
// they are only used in the renderer process. | ||
class ExtensionsRendererClient { | ||
public: | ||
virtual ~ExtensionsRendererClient() {} | ||
|
||
// Returns true if the current render process was launched incognito. | ||
virtual bool IsIncognitoProcess() const = 0; | ||
|
||
// Returns the lowest isolated world ID available to extensions. | ||
// Must be greater than 0. See blink::WebFrame::executeScriptInIsolatedWorld | ||
// (third_party/WebKit/public/web/WebFrame.h) for additional context. | ||
virtual int GetLowestIsolatedWorldId() const = 0; | ||
|
||
// Returns the single instance of |this|. | ||
static ExtensionsRendererClient* Get(); | ||
|
||
// Initialize the single instance. | ||
static void Set(ExtensionsRendererClient* client); | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // EXTENSIONS_RENDERER_EXTENSIONS_RENDERER_CLIENT_H_ |