| 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_BROWSER_CONTENT_BROWSER_CLIENT_H_ | |
| 6 #define CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "content/common/window_container_type.h" | |
| 13 #include "content/public/common/content_client.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" | |
| 15 | |
| 16 class AccessTokenStore; | |
| 17 class BrowserRenderProcessHost; | |
| 18 class BrowserURLHandler; | |
| 19 class CommandLine; | |
| 20 class DevToolsManager; | |
| 21 class FilePath; | |
| 22 class GURL; | |
| 23 class MHTMLGenerationManager; | |
| 24 class PluginProcessHost; | |
| 25 class QuotaPermissionContext; | |
| 26 class RenderProcessHost; | |
| 27 class RenderViewHost; | |
| 28 class RenderWidgetHost; | |
| 29 class RenderWidgetHostView; | |
| 30 class ResourceDispatcherHost; | |
| 31 class SSLCertErrorHandler; | |
| 32 class SSLClientAuthHandler; | |
| 33 class SkBitmap; | |
| 34 class TabContents; | |
| 35 class TabContentsView; | |
| 36 class WorkerProcessHost; | |
| 37 struct DesktopNotificationHostMsg_Show_Params; | |
| 38 struct MainFunctionParams; | |
| 39 struct WebPreferences; | |
| 40 | |
| 41 namespace content { | |
| 42 class BrowserMainParts; | |
| 43 } | |
| 44 | |
| 45 namespace crypto { | |
| 46 class CryptoModuleBlockingPasswordDelegate; | |
| 47 } | |
| 48 | |
| 49 namespace net { | |
| 50 class CookieList; | |
| 51 class CookieOptions; | |
| 52 class NetLog; | |
| 53 class URLRequest; | |
| 54 class URLRequestContext; | |
| 55 class URLRequestContextGetter; | |
| 56 class X509Certificate; | |
| 57 } | |
| 58 | |
| 59 namespace speech_input { | |
| 60 class SpeechInputManager; | |
| 61 } | |
| 62 | |
| 63 namespace ui { | |
| 64 class Clipboard; | |
| 65 } | |
| 66 | |
| 67 namespace content { | |
| 68 | |
| 69 class BrowserContext; | |
| 70 class BrowserMainParts; | |
| 71 class ResourceContext; | |
| 72 class WebUIFactory; | |
| 73 | |
| 74 // Embedder API (or SPI) for participating in browser logic, to be implemented | |
| 75 // by the client of the content browser. See ChromeContentBrowserClient for the | |
| 76 // principal implementation. The methods are assumed to be called on the UI | |
| 77 // thread unless otherwise specified. Use this "escape hatch" sparingly, to | |
| 78 // avoid the embedder interface ballooning and becoming very specific to Chrome. | |
| 79 // (Often, the call out to the client can happen in a different part of the code | |
| 80 // that either already has a hook out to the embedder, or calls out to one of | |
| 81 // the observer interfaces.) | |
| 82 class ContentBrowserClient { | |
| 83 public: | |
| 84 virtual ~ContentBrowserClient() {} | |
| 85 | |
| 86 // Allows the embedder to return a customed BrowserMainParts implementation | |
| 87 // for the browser staratup code. Can return NULL, in which case the default | |
| 88 // is used. | |
| 89 virtual BrowserMainParts* CreateBrowserMainParts( | |
| 90 const MainFunctionParams& parameters) = 0; | |
| 91 | |
| 92 // Platform-specific creator. Use this to construct new RenderWidgetHostViews | |
| 93 // rather than using RenderWidgetHostViewWin & friends. | |
| 94 // | |
| 95 // This function must NOT size it, because the RenderView in the renderer | |
| 96 // wouldn't have been created yet. The widget would set its "waiting for | |
| 97 // resize ack" flag, and the ack would never come becasue no RenderView | |
| 98 // received it. | |
| 99 // | |
| 100 // The RenderWidgetHost must already be created (because we can't know if it's | |
| 101 // going to be a regular RenderWidgetHost or a RenderViewHost (a subclass). | |
| 102 virtual RenderWidgetHostView* CreateViewForWidget( | |
| 103 RenderWidgetHost* widget) = 0; | |
| 104 | |
| 105 virtual TabContentsView* CreateTabContentsView(TabContents* tab_contents) = 0; | |
| 106 | |
| 107 // Notifies that a new RenderHostView has been created. | |
| 108 virtual void RenderViewHostCreated(RenderViewHost* render_view_host) = 0; | |
| 109 | |
| 110 // Notifies that a BrowserRenderProcessHost has been created. This is called | |
| 111 // before the content layer adds its own BrowserMessageFilters, so that the | |
| 112 // embedder's IPC filters have priority. | |
| 113 virtual void BrowserRenderProcessHostCreated( | |
| 114 BrowserRenderProcessHost* host) = 0; | |
| 115 | |
| 116 // Notifies that a PluginProcessHost has been created. This is called | |
| 117 // before the content layer adds its own message filters, so that the | |
| 118 // embedder's IPC filters have priority. | |
| 119 virtual void PluginProcessHostCreated(PluginProcessHost* host) = 0; | |
| 120 | |
| 121 // Notifies that a WorkerProcessHost has been created. This is called | |
| 122 // before the content layer adds its own message filters, so that the | |
| 123 // embedder's IPC filters have priority. | |
| 124 virtual void WorkerProcessHostCreated(WorkerProcessHost* host) = 0; | |
| 125 | |
| 126 // Gets the WebUIFactory which will be responsible for generating WebUIs. | |
| 127 virtual WebUIFactory* GetWebUIFactory() = 0; | |
| 128 | |
| 129 // Get the effective URL for the given actual URL, to allow an embedder to | |
| 130 // group different url schemes in the same SiteInstance. | |
| 131 virtual GURL GetEffectiveURL(BrowserContext* browser_context, | |
| 132 const GURL& url) = 0; | |
| 133 | |
| 134 // Returns whether all instances of the specified effective URL should be | |
| 135 // rendered by the same process, rather than using process-per-site-instance. | |
| 136 virtual bool ShouldUseProcessPerSite(BrowserContext* browser_context, | |
| 137 const GURL& effective_url) = 0; | |
| 138 | |
| 139 // Returns whether a specified URL is to be considered the same as any | |
| 140 // SiteInstance. | |
| 141 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) = 0; | |
| 142 | |
| 143 // Returns whether a new view for a given |site_url| can be launched in a | |
| 144 // given |process_host|. | |
| 145 virtual bool IsSuitableHost(RenderProcessHost* process_host, | |
| 146 const GURL& site_url) = 0; | |
| 147 | |
| 148 // Returns true if for the navigation from |current_url| to |new_url|, | |
| 149 // processes should be swapped (even if we are in a process model that | |
| 150 // doesn't usually swap). | |
| 151 virtual bool ShouldSwapProcessesForNavigation(const GURL& current_url, | |
| 152 const GURL& new_url) = 0; | |
| 153 | |
| 154 // See CharacterEncoding's comment. | |
| 155 virtual std::string GetCanonicalEncodingNameByAliasName( | |
| 156 const std::string& alias_name) = 0; | |
| 157 | |
| 158 // Allows the embedder to pass extra command line flags. | |
| 159 // switches::kProcessType will already be set at this point. | |
| 160 virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, | |
| 161 int child_process_id) = 0; | |
| 162 | |
| 163 // Returns the locale used by the application. | |
| 164 virtual std::string GetApplicationLocale() = 0; | |
| 165 | |
| 166 // Returns the languages used in the Accept-Languages HTTP header. | |
| 167 // (Not called GetAcceptLanguages so it doesn't clash with win32). | |
| 168 virtual std::string GetAcceptLangs(const TabContents* tab) = 0; | |
| 169 | |
| 170 // Returns the default favicon. The callee doesn't own the given bitmap. | |
| 171 virtual SkBitmap* GetDefaultFavicon() = 0; | |
| 172 | |
| 173 // Allow the embedder to control if an AppCache can be used for the given url. | |
| 174 // This is called on the IO thread. | |
| 175 virtual bool AllowAppCache(const GURL& manifest_url, | |
| 176 const GURL& first_party, | |
| 177 const content::ResourceContext& context) = 0; | |
| 178 | |
| 179 // Allow the embedder to control if the given cookie can be read. | |
| 180 // This is called on the IO thread. | |
| 181 virtual bool AllowGetCookie(const GURL& url, | |
| 182 const GURL& first_party, | |
| 183 const net::CookieList& cookie_list, | |
| 184 const content::ResourceContext& context, | |
| 185 int render_process_id, | |
| 186 int render_view_id) = 0; | |
| 187 | |
| 188 // Allow the embedder to control if the given cookie can be set. | |
| 189 // This is called on the IO thread. | |
| 190 virtual bool AllowSetCookie(const GURL& url, | |
| 191 const GURL& first_party, | |
| 192 const std::string& cookie_line, | |
| 193 const content::ResourceContext& context, | |
| 194 int render_process_id, | |
| 195 int render_view_id, | |
| 196 net::CookieOptions* options) = 0; | |
| 197 | |
| 198 // This is called on the IO thread. | |
| 199 virtual bool AllowSaveLocalState( | |
| 200 const content::ResourceContext& context) = 0; | |
| 201 | |
| 202 // Allows the embedder to override the request context based on the URL for | |
| 203 // certain operations, like cookie access. Returns NULL to indicate the | |
| 204 // regular request context should be used. | |
| 205 // This is called on the IO thread. | |
| 206 virtual net::URLRequestContext* OverrideRequestContextForURL( | |
| 207 const GURL& url, const content::ResourceContext& context) = 0; | |
| 208 | |
| 209 // Create and return a new quota permission context. | |
| 210 virtual QuotaPermissionContext* CreateQuotaPermissionContext() = 0; | |
| 211 | |
| 212 // Open the given file in the desktop's default manner. | |
| 213 virtual void OpenItem(const FilePath& path) = 0; | |
| 214 | |
| 215 // Show the given file in a file manager. If possible, select the file. | |
| 216 virtual void ShowItemInFolder(const FilePath& path) = 0; | |
| 217 | |
| 218 // Informs the embedder that a certificate error has occured. If overridable | |
| 219 // is true, the user can ignore the error and continue. If it's false, then | |
| 220 // the certificate error is severe and the user isn't allowed to proceed. The | |
| 221 // embedder can call the callback asynchronously. | |
| 222 virtual void AllowCertificateError( | |
| 223 SSLCertErrorHandler* handler, | |
| 224 bool overridable, | |
| 225 const base::Callback<void(SSLCertErrorHandler*, bool)>& callback) = 0; | |
| 226 | |
| 227 // Selects a SSL client certificate and returns it to the |handler|. If no | |
| 228 // certificate was selected NULL is returned to the |handler|. | |
| 229 virtual void SelectClientCertificate( | |
| 230 int render_process_id, | |
| 231 int render_view_id, | |
| 232 SSLClientAuthHandler* handler) = 0; | |
| 233 | |
| 234 // Adds a newly-generated client cert. The embedder should ensure that there's | |
| 235 // a private key for the cert, displays the cert to the user, and adds it upon | |
| 236 // user approval. | |
| 237 virtual void AddNewCertificate( | |
| 238 net::URLRequest* request, | |
| 239 net::X509Certificate* cert, | |
| 240 int render_process_id, | |
| 241 int render_view_id) = 0; | |
| 242 | |
| 243 // Asks permission to show desktop notifications. | |
| 244 virtual void RequestDesktopNotificationPermission( | |
| 245 const GURL& source_origin, | |
| 246 int callback_context, | |
| 247 int render_process_id, | |
| 248 int render_view_id) = 0; | |
| 249 | |
| 250 // Checks if the given page has permission to show desktop notifications. | |
| 251 // This is called on the IO thread. | |
| 252 virtual WebKit::WebNotificationPresenter::Permission | |
| 253 CheckDesktopNotificationPermission( | |
| 254 const GURL& source_url, | |
| 255 const content::ResourceContext& context) = 0; | |
| 256 | |
| 257 // Show a desktop notification. If |worker| is true, the request came from an | |
| 258 // HTML5 web worker, otherwise, it came from a renderer. | |
| 259 virtual void ShowDesktopNotification( | |
| 260 const DesktopNotificationHostMsg_Show_Params& params, | |
| 261 int render_process_id, | |
| 262 int render_view_id, | |
| 263 bool worker) = 0; | |
| 264 | |
| 265 // Cancels a displayed desktop notification. | |
| 266 virtual void CancelDesktopNotification( | |
| 267 int render_process_id, | |
| 268 int render_view_id, | |
| 269 int notification_id) = 0; | |
| 270 | |
| 271 // Returns true if the given page is allowed to open a window of the given | |
| 272 // type. | |
| 273 // This is called on the IO thread. | |
| 274 virtual bool CanCreateWindow( | |
| 275 const GURL& source_url, | |
| 276 WindowContainerType container_type, | |
| 277 const content::ResourceContext& context) = 0; | |
| 278 | |
| 279 // Returns a title string to use in the task manager for a process host with | |
| 280 // the given URL, or the empty string to fall back to the default logic. | |
| 281 // This is called on the IO thread. | |
| 282 virtual std::string GetWorkerProcessTitle( | |
| 283 const GURL& url, const content::ResourceContext& context) = 0; | |
| 284 | |
| 285 // Getters for common objects. | |
| 286 virtual ResourceDispatcherHost* GetResourceDispatcherHost() = 0; | |
| 287 virtual ui::Clipboard* GetClipboard() = 0; | |
| 288 virtual MHTMLGenerationManager* GetMHTMLGenerationManager() = 0; | |
| 289 virtual DevToolsManager* GetDevToolsManager() = 0; | |
| 290 virtual net::NetLog* GetNetLog() = 0; | |
| 291 virtual speech_input::SpeechInputManager* GetSpeechInputManager() = 0; | |
| 292 | |
| 293 // Creates a new AccessTokenStore for gelocation. | |
| 294 virtual AccessTokenStore* CreateAccessTokenStore() = 0; | |
| 295 | |
| 296 // Returns true if fast shutdown is possible. | |
| 297 virtual bool IsFastShutdownPossible() = 0; | |
| 298 | |
| 299 // Returns the WebKit preferences that are used by the renderer. | |
| 300 virtual WebPreferences GetWebkitPrefs(BrowserContext* browser_context, | |
| 301 bool is_web_ui) = 0; | |
| 302 | |
| 303 // Inspector setting was changed and should be persisted. | |
| 304 virtual void UpdateInspectorSetting(RenderViewHost* rvh, | |
| 305 const std::string& key, | |
| 306 const std::string& value) = 0; | |
| 307 | |
| 308 // Clear the Inspector settings. | |
| 309 virtual void ClearInspectorSettings(RenderViewHost* rvh) = 0; | |
| 310 | |
| 311 // Notifies that BrowserURLHandler has been created, so that the embedder can | |
| 312 // optionally add their own handlers. | |
| 313 virtual void BrowserURLHandlerCreated(BrowserURLHandler* handler) = 0; | |
| 314 | |
| 315 // Clears browser cache. | |
| 316 virtual void ClearCache(RenderViewHost* rvh) = 0; | |
| 317 | |
| 318 // Clears browser cookies. | |
| 319 virtual void ClearCookies(RenderViewHost* rvh) = 0; | |
| 320 | |
| 321 // Returns the default download directory. | |
| 322 // This can be called on any thread. | |
| 323 virtual FilePath GetDefaultDownloadDirectory() = 0; | |
| 324 | |
| 325 // Returns the default filename used in downloads when we have no idea what | |
| 326 // else we should do with the file. | |
| 327 virtual std::string GetDefaultDownloadName() = 0; | |
| 328 | |
| 329 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 330 // Can return an optional fd for crash handling, otherwise returns -1. The | |
| 331 // passed |command_line| will be used to start the process in question. | |
| 332 virtual int GetCrashSignalFD(const CommandLine& command_line) = 0; | |
| 333 #endif | |
| 334 | |
| 335 #if defined(OS_WIN) | |
| 336 // Returns the name of the dll that contains cursors and other resources. | |
| 337 virtual const wchar_t* GetResourceDllName() = 0; | |
| 338 #endif | |
| 339 | |
| 340 #if defined(USE_NSS) | |
| 341 // Return a delegate to authenticate and unlock |module|. | |
| 342 // This is called on a worker thread. | |
| 343 virtual | |
| 344 crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate( | |
| 345 const GURL& url) = 0; | |
| 346 #endif | |
| 347 }; | |
| 348 | |
| 349 } // namespace content | |
| 350 | |
| 351 #endif // CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ | |
| OLD | NEW |