1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
// Copyright (c) 2011 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 CONTENT_BROWSER_MOCK_CONTENT_BROWSER_CLIENT_H_
#define CONTENT_BROWSER_MOCK_CONTENT_BROWSER_CLIENT_H_
#pragma once
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/scoped_temp_dir.h"
#include "content/public/browser/content_browser_client.h"
namespace content {
// Base for unit tests that need to mock the ContentBrowserClient.
class MockContentBrowserClient : public ContentBrowserClient {
public:
MockContentBrowserClient();
virtual ~MockContentBrowserClient();
virtual void CreateBrowserMainParts(
const MainFunctionParams& parameters,
std::vector<BrowserMainParts*>* parts_list) OVERRIDE;
virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* widget) OVERRIDE;
virtual TabContentsView* CreateTabContentsView(
TabContents* tab_contents) OVERRIDE;
virtual void RenderViewHostCreated(
RenderViewHost* render_view_host) OVERRIDE;
virtual void BrowserRenderProcessHostCreated(
BrowserRenderProcessHost* host) OVERRIDE;
virtual void PluginProcessHostCreated(PluginProcessHost* host) OVERRIDE;
virtual void WorkerProcessHostCreated(WorkerProcessHost* host) OVERRIDE;
virtual WebUIFactory* GetWebUIFactory() OVERRIDE;
virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
const GURL& url) OVERRIDE;
virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context,
const GURL& effective_url) OVERRIDE;
virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE;
virtual bool IsSuitableHost(RenderProcessHost* process_host,
const GURL& site_url) OVERRIDE;
virtual bool ShouldSwapProcessesForNavigation(const GURL& current_url,
const GURL& new_url) OVERRIDE;
virtual std::string GetCanonicalEncodingNameByAliasName(
const std::string& alias_name) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) OVERRIDE;
virtual std::string GetApplicationLocale() OVERRIDE;
virtual std::string GetAcceptLangs(const TabContents* tab) OVERRIDE;
virtual SkBitmap* GetDefaultFavicon() OVERRIDE;
virtual bool AllowAppCache(const GURL& manifest_url,
const GURL& first_party,
const content::ResourceContext& context) OVERRIDE;
virtual bool AllowGetCookie(const GURL& url,
const GURL& first_party,
const net::CookieList& cookie_list,
const content::ResourceContext& context,
int render_process_id,
int render_view_id) OVERRIDE;
virtual bool AllowSetCookie(const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
const content::ResourceContext& context,
int render_process_id,
int render_view_id,
net::CookieOptions* options) OVERRIDE;
virtual bool AllowSaveLocalState(
const content::ResourceContext& context) OVERRIDE;
virtual net::URLRequestContext* OverrideRequestContextForURL(
const GURL& url, const content::ResourceContext& context) OVERRIDE;
virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
virtual void OpenItem(const FilePath& path) OVERRIDE;
virtual void ShowItemInFolder(const FilePath& path) OVERRIDE;
virtual void AllowCertificateError(
SSLCertErrorHandler* handler,
bool overridable,
const base::Callback<void(SSLCertErrorHandler*, bool)>& callback)
OVERRIDE;
virtual void SelectClientCertificate(
int render_process_id,
int render_view_id,
SSLClientAuthHandler* handler) OVERRIDE;
virtual void AddNewCertificate(
net::URLRequest* request,
net::X509Certificate* cert,
int render_process_id,
int render_view_id) OVERRIDE;
virtual void RequestDesktopNotificationPermission(
const GURL& source_origin,
int callback_context,
int render_process_id,
int render_view_id) OVERRIDE;
virtual WebKit::WebNotificationPresenter::Permission
CheckDesktopNotificationPermission(
const GURL& source_url,
const content::ResourceContext& context) OVERRIDE;
virtual void ShowDesktopNotification(
const DesktopNotificationHostMsg_Show_Params& params,
int render_process_id,
int render_view_id,
bool worker) OVERRIDE;
virtual void CancelDesktopNotification(
int render_process_id,
int render_view_id,
int notification_id) OVERRIDE;
virtual bool CanCreateWindow(
const GURL& source_url,
WindowContainerType container_type,
const content::ResourceContext& context) OVERRIDE;
virtual std::string GetWorkerProcessTitle(
const GURL& url, const content::ResourceContext& context) OVERRIDE;
virtual ResourceDispatcherHost* GetResourceDispatcherHost() OVERRIDE;
virtual ui::Clipboard* GetClipboard() OVERRIDE;
virtual MHTMLGenerationManager* GetMHTMLGenerationManager() OVERRIDE;
virtual DevToolsManager* GetDevToolsManager() OVERRIDE;
virtual net::NetLog* GetNetLog() OVERRIDE;
virtual speech_input::SpeechInputManager* GetSpeechInputManager() OVERRIDE;
virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
virtual bool IsFastShutdownPossible() OVERRIDE;
virtual WebPreferences GetWebkitPrefs(
content::BrowserContext* browser_context,
bool is_web_ui) OVERRIDE;
virtual void UpdateInspectorSetting(RenderViewHost* rvh,
const std::string& key,
const std::string& value) OVERRIDE;
virtual void ClearInspectorSettings(RenderViewHost* rvh) OVERRIDE;
virtual void BrowserURLHandlerCreated(BrowserURLHandler* handler) OVERRIDE;
virtual void ClearCache(RenderViewHost* rvh) OVERRIDE;
virtual void ClearCookies(RenderViewHost* rvh) OVERRIDE;
virtual FilePath GetDefaultDownloadDirectory() OVERRIDE;
virtual std::string GetDefaultDownloadName() OVERRIDE;
#if defined(OS_POSIX) && !defined(OS_MACOSX)
virtual int GetCrashSignalFD(const CommandLine& command_line) OVERRIDE;
#endif
#if defined(OS_WIN)
virtual const wchar_t* GetResourceDllName() OVERRIDE;
#endif
#if defined(USE_NSS)
virtual
crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate(
const GURL& url) OVERRIDE;
#endif
private:
// Temporary directory for GetDefaultDownloadDirectory.
ScopedTempDir download_dir_;
DISALLOW_COPY_AND_ASSIGN(MockContentBrowserClient);
};
} // namespace content
#endif // CONTENT_BROWSER_MOCK_CONTENT_BROWSER_CLIENT_H_
|