Print Preview: Refactoring print/cancel button and print summary.
[chromium-blink-merge.git] / content / common / content_client.h
blobd3abd435de129242b6e087175d94f9cbe801345d
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_
7 #pragma once
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/string16.h"
14 #include "build/build_config.h"
16 class CommandLine;
17 class GURL;
18 struct GPUInfo;
19 struct PepperPluginInfo;
21 namespace IPC {
22 class Message;
25 namespace base {
26 class StringPiece;
29 namespace sandbox {
30 class TargetPolicy;
33 namespace content {
35 class ContentBrowserClient;
36 class ContentClient;
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.
47 class ContentClient {
48 public:
49 ContentClient();
50 ~ContentClient();
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
80 // websites.
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;
89 #if defined(OS_WIN)
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;
93 #endif
95 private:
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_