1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_CONTENT_CLIENT_H_
6 #define CONTENT_COMMON_CONTENT_CLIENT_H_
12 #include "base/basictypes.h"
13 #include "base/string16.h"
14 #include "build/build_config.h"
19 struct PepperPluginInfo
;
35 class ContentBrowserClient
;
37 class ContentPluginClient
;
38 class ContentRendererClient
;
39 class ContentUtilityClient
;
41 // Setter and getter for the client. The client should be set early, before any
42 // content code is called.
43 void SetContentClient(ContentClient
* client
);
44 ContentClient
* GetContentClient();
46 // Interface that the embedder implements.
52 ContentBrowserClient
* browser() { return browser_
; }
53 void set_browser(ContentBrowserClient
* c
) { browser_
= c
; }
54 ContentPluginClient
* plugin() { return plugin_
; }
55 void set_plugin(ContentPluginClient
* p
) { plugin_
= p
; }
56 ContentRendererClient
* renderer() { return renderer_
; }
57 void set_renderer(ContentRendererClient
* r
) { renderer_
= r
; }
58 ContentUtilityClient
* utility() { return utility_
; }
59 void set_utility(ContentUtilityClient
* u
) { utility_
= u
; }
61 // Sets the currently active URL. Use GURL() to clear the URL.
62 virtual void SetActiveURL(const GURL
& url
) = 0;
64 // Sets the data on the current gpu.
65 virtual void SetGpuInfo(const GPUInfo
& gpu_info
) = 0;
67 // Gives the embedder a chance to register its own pepper plugins.
68 virtual void AddPepperPlugins(std::vector
<PepperPluginInfo
>* plugins
) = 0;
70 // Returns whether the given message should be allowed to be sent from a
71 // swapped out renderer.
72 virtual bool CanSendWhileSwappedOut(const IPC::Message
* msg
) = 0;
74 // Returns whether the given message should be processed in the browser on
75 // behalf of a swapped out renderer.
76 virtual bool CanHandleWhileSwappedOut(const IPC::Message
& msg
) = 0;
78 // Returns the user agent. If mimic_windows is true then the embedder can
79 // return a fake Windows user agent. This is a workaround for broken
81 virtual std::string
GetUserAgent(bool mimic_windows
) const = 0;
83 // Returns a string resource given its id.
84 virtual string16
GetLocalizedString(int message_id
) const = 0;
86 // Return the contents of a resource in a StringPiece given the resource id.
87 virtual base::StringPiece
GetDataResource(int resource_id
) const = 0;
90 // Allows the embedder to sandbox a plugin, and apply a custom policy.
91 virtual bool SandboxPlugin(CommandLine
* command_line
,
92 sandbox::TargetPolicy
* policy
) = 0;
96 // The embedder API for participating in browser logic.
97 ContentBrowserClient
* browser_
;
98 // The embedder API for participating in plugin logic.
99 ContentPluginClient
* plugin_
;
100 // The embedder API for participating in renderer logic.
101 ContentRendererClient
* renderer_
;
102 // The embedder API for participating in utility logic.
103 ContentUtilityClient
* utility_
;
106 } // namespace content
108 #endif // CONTENT_COMMON_CONTENT_CLIENT_H_