OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_COMMON_CONTENT_CLIENT_H_ | |
6 #define CONTENT_COMMON_CONTENT_CLIENT_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/string16.h" | |
14 #include "build/build_config.h" | |
15 #include "content/common/content_export.h" | |
16 | |
17 class CommandLine; | |
18 class GURL; | |
19 struct GPUInfo; | |
20 struct PepperPluginInfo; | |
21 | |
22 namespace IPC { | |
23 class Message; | |
24 } | |
25 | |
26 namespace base { | |
27 class StringPiece; | |
28 } | |
29 | |
30 namespace sandbox { | |
31 class TargetPolicy; | |
32 } | |
33 | |
34 namespace content { | |
35 | |
36 class ContentBrowserClient; | |
37 class ContentClient; | |
38 class ContentPluginClient; | |
39 class ContentRendererClient; | |
40 class ContentUtilityClient; | |
41 | |
42 // Setter and getter for the client. The client should be set early, before any | |
43 // content code is called. | |
44 CONTENT_EXPORT void SetContentClient(ContentClient* client); | |
45 CONTENT_EXPORT ContentClient* GetContentClient(); | |
46 | |
47 // Returns the user agent string being used by the browser. SetContentClient() | |
48 // must be called prior to calling this, and this routine must be used | |
49 // instead of webkit_glue::GetUserAgent() in order to ensure that we use | |
50 // the same user agent string everywhere. | |
51 // TODO(dpranke): This is caused by webkit_glue being a library that can | |
52 // get linked into multiple linkable objects, causing us to have multiple | |
53 // static values of the user agent. This will be fixed when we clean up | |
54 // webkit_glue. | |
55 CONTENT_EXPORT const std::string& GetUserAgent(const GURL& url); | |
56 | |
57 // Interface that the embedder implements. | |
58 class CONTENT_EXPORT ContentClient { | |
59 public: | |
60 ContentClient(); | |
61 virtual ~ContentClient(); | |
62 | |
63 ContentBrowserClient* browser() { return browser_; } | |
64 void set_browser(ContentBrowserClient* c) { browser_ = c; } | |
65 ContentPluginClient* plugin() { return plugin_; } | |
66 void set_plugin(ContentPluginClient* p) { plugin_ = p; } | |
67 ContentRendererClient* renderer() { return renderer_; } | |
68 void set_renderer(ContentRendererClient* r) { renderer_ = r; } | |
69 ContentUtilityClient* utility() { return utility_; } | |
70 void set_utility(ContentUtilityClient* u) { utility_ = u; } | |
71 | |
72 // Sets the currently active URL. Use GURL() to clear the URL. | |
73 virtual void SetActiveURL(const GURL& url) = 0; | |
74 | |
75 // Sets the data on the current gpu. | |
76 virtual void SetGpuInfo(const GPUInfo& gpu_info) = 0; | |
77 | |
78 // Gives the embedder a chance to register its own pepper plugins. | |
79 virtual void AddPepperPlugins(std::vector<PepperPluginInfo>* plugins) = 0; | |
80 | |
81 // Returns whether the given message should be allowed to be sent from a | |
82 // swapped out renderer. | |
83 virtual bool CanSendWhileSwappedOut(const IPC::Message* msg) = 0; | |
84 | |
85 // Returns whether the given message should be processed in the browser on | |
86 // behalf of a swapped out renderer. | |
87 virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) = 0; | |
88 | |
89 // Returns the user agent and a flag indicating whether the returned | |
90 // string should always be used (if false, callers may override the | |
91 // value as needed to work around various user agent sniffing bugs). | |
92 virtual std::string GetUserAgent(bool *overriding) const = 0; | |
93 | |
94 // Returns a string resource given its id. | |
95 virtual string16 GetLocalizedString(int message_id) const = 0; | |
96 | |
97 // Return the contents of a resource in a StringPiece given the resource id. | |
98 virtual base::StringPiece GetDataResource(int resource_id) const = 0; | |
99 | |
100 #if defined(OS_WIN) | |
101 // Allows the embedder to sandbox a plugin, and apply a custom policy. | |
102 virtual bool SandboxPlugin(CommandLine* command_line, | |
103 sandbox::TargetPolicy* policy) = 0; | |
104 #endif | |
105 | |
106 private: | |
107 // The embedder API for participating in browser logic. | |
108 ContentBrowserClient* browser_; | |
109 // The embedder API for participating in plugin logic. | |
110 ContentPluginClient* plugin_; | |
111 // The embedder API for participating in renderer logic. | |
112 ContentRendererClient* renderer_; | |
113 // The embedder API for participating in utility logic. | |
114 ContentUtilityClient* utility_; | |
115 }; | |
116 | |
117 } // namespace content | |
118 | |
119 #endif // CONTENT_COMMON_CONTENT_CLIENT_H_ | |
OLD | NEW |