| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ | 5 #ifndef CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ |
| 6 #define CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ | 6 #define CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // by the client of the content browser. See ChromeContentBrowserClient for the | 53 // by the client of the content browser. See ChromeContentBrowserClient for the |
| 54 // principle implementation. The methods are assumed to | 54 // principle implementation. The methods are assumed to |
| 55 // be called on the UI thread unless otherwise specified. | 55 // be called on the UI thread unless otherwise specified. |
| 56 // Use this "escape hatch" sparingly, to avoid the embedder interface ballooning | 56 // Use this "escape hatch" sparingly, to avoid the embedder interface ballooning |
| 57 // and becoming very specific to Chrome. (Often, the call out to the client can | 57 // and becoming very specific to Chrome. (Often, the call out to the client can |
| 58 // happen in a different part of the code that either already has a hook out to | 58 // happen in a different part of the code that either already has a hook out to |
| 59 // the embedder, or calls out to one of the observer interfaces.) | 59 // the embedder, or calls out to one of the observer interfaces.) |
| 60 class ContentBrowserClient { | 60 class ContentBrowserClient { |
| 61 public: | 61 public: |
| 62 // Notifies that a new RenderHostView has been created. | 62 // Notifies that a new RenderHostView has been created. |
| 63 virtual void RenderViewHostCreated(RenderViewHost* render_view_host); | 63 virtual void RenderViewHostCreated(RenderViewHost* render_view_host) = 0; |
| 64 | 64 |
| 65 // Notifies that a BrowserRenderProcessHost has been created. This is called | 65 // Notifies that a BrowserRenderProcessHost has been created. This is called |
| 66 // before the content layer adds its own BrowserMessageFilters, so that the | 66 // before the content layer adds its own BrowserMessageFilters, so that the |
| 67 // embedder's IPC filters have priority. | 67 // embedder's IPC filters have priority. |
| 68 virtual void BrowserRenderProcessHostCreated(BrowserRenderProcessHost* host); | 68 virtual void BrowserRenderProcessHostCreated( |
| 69 BrowserRenderProcessHost* host) = 0; |
| 69 | 70 |
| 70 // Notifies that a PluginProcessHost has been created. This is called | 71 // Notifies that a PluginProcessHost has been created. This is called |
| 71 // before the content layer adds its own message filters, so that the | 72 // before the content layer adds its own message filters, so that the |
| 72 // embedder's IPC filters have priority. | 73 // embedder's IPC filters have priority. |
| 73 virtual void PluginProcessHostCreated(PluginProcessHost* host); | 74 virtual void PluginProcessHostCreated(PluginProcessHost* host) = 0; |
| 74 | 75 |
| 75 // Notifies that a WorkerProcessHost has been created. This is called | 76 // Notifies that a WorkerProcessHost has been created. This is called |
| 76 // before the content layer adds its own message filters, so that the | 77 // before the content layer adds its own message filters, so that the |
| 77 // embedder's IPC filters have priority. | 78 // embedder's IPC filters have priority. |
| 78 virtual void WorkerProcessHostCreated(WorkerProcessHost* host); | 79 virtual void WorkerProcessHostCreated(WorkerProcessHost* host) = 0; |
| 79 | 80 |
| 80 // Gets the WebUIFactory which will be responsible for generating WebUIs. | 81 // Gets the WebUIFactory which will be responsible for generating WebUIs. |
| 81 virtual WebUIFactory* GetWebUIFactory(); | 82 virtual WebUIFactory* GetWebUIFactory() = 0; |
| 82 | 83 |
| 83 // Get the effective URL for the given actual URL, to allow an embedder to | 84 // Get the effective URL for the given actual URL, to allow an embedder to |
| 84 // group different url schemes in the same SiteInstance. | 85 // group different url schemes in the same SiteInstance. |
| 85 virtual GURL GetEffectiveURL(Profile* profile, const GURL& url); | 86 virtual GURL GetEffectiveURL(Profile* profile, const GURL& url) = 0; |
| 86 | 87 |
| 87 // Returns whether a specified URL is to be considered the same as any | 88 // Returns whether a specified URL is to be considered the same as any |
| 88 // SiteInstance. | 89 // SiteInstance. |
| 89 virtual bool IsURLSameAsAnySiteInstance(const GURL& url); | 90 virtual bool IsURLSameAsAnySiteInstance(const GURL& url) = 0; |
| 90 | 91 |
| 91 // See CharacterEncoding's comment. | 92 // See CharacterEncoding's comment. |
| 92 virtual std::string GetCanonicalEncodingNameByAliasName( | 93 virtual std::string GetCanonicalEncodingNameByAliasName( |
| 93 const std::string& alias_name); | 94 const std::string& alias_name) = 0; |
| 94 | 95 |
| 95 // Allows the embedder to pass extra command line flags. | 96 // Allows the embedder to pass extra command line flags. |
| 96 // switches::kProcessType will already be set at this point. | 97 // switches::kProcessType will already be set at this point. |
| 97 virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, | 98 virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, |
| 98 int child_process_id); | 99 int child_process_id) = 0; |
| 99 | 100 |
| 100 // Returns the locale used by the application. | 101 // Returns the locale used by the application. |
| 101 virtual std::string GetApplicationLocale(); | 102 virtual std::string GetApplicationLocale() = 0; |
| 102 | 103 |
| 103 // Returns the languages used in the Accept-Languages HTTP header. | 104 // Returns the languages used in the Accept-Languages HTTP header. |
| 104 // (Not called GetAcceptLanguages so it doesn't clash with win32). | 105 // (Not called GetAcceptLanguages so it doesn't clash with win32). |
| 105 virtual std::string GetAcceptLangs(const TabContents* tab); | 106 virtual std::string GetAcceptLangs(const TabContents* tab) = 0; |
| 106 | 107 |
| 107 // Returns the default favicon. The callee doesn't own the given bitmap. | 108 // Returns the default favicon. The callee doesn't own the given bitmap. |
| 108 virtual SkBitmap* GetDefaultFavicon(); | 109 virtual SkBitmap* GetDefaultFavicon() = 0; |
| 109 | 110 |
| 110 // Allow the embedder to control if an AppCache can be used for the given url. | 111 // Allow the embedder to control if an AppCache can be used for the given url. |
| 111 // This is called on the IO thread. | 112 // This is called on the IO thread. |
| 112 virtual bool AllowAppCache(const GURL& manifest_url, | 113 virtual bool AllowAppCache(const GURL& manifest_url, |
| 113 const content::ResourceContext& context); | 114 const content::ResourceContext& context) = 0; |
| 114 | 115 |
| 115 // Allow the embedder to control if the given cookie can be read. | 116 // Allow the embedder to control if the given cookie can be read. |
| 116 // This is called on the IO thread. | 117 // This is called on the IO thread. |
| 117 virtual bool AllowGetCookie(const GURL& url, | 118 virtual bool AllowGetCookie(const GURL& url, |
| 118 const GURL& first_party, | 119 const GURL& first_party, |
| 119 const net::CookieList& cookie_list, | 120 const net::CookieList& cookie_list, |
| 120 const content::ResourceContext& context, | 121 const content::ResourceContext& context, |
| 121 int render_process_id, | 122 int render_process_id, |
| 122 int render_view_id); | 123 int render_view_id) = 0; |
| 123 | 124 |
| 124 // Allow the embedder to control if the given cookie can be set. | 125 // Allow the embedder to control if the given cookie can be set. |
| 125 // This is called on the IO thread. | 126 // This is called on the IO thread. |
| 126 virtual bool AllowSetCookie(const GURL& url, | 127 virtual bool AllowSetCookie(const GURL& url, |
| 127 const GURL& first_party, | 128 const GURL& first_party, |
| 128 const std::string& cookie_line, | 129 const std::string& cookie_line, |
| 129 const content::ResourceContext& context, | 130 const content::ResourceContext& context, |
| 130 int render_process_id, | 131 int render_process_id, |
| 131 int render_view_id, | 132 int render_view_id, |
| 132 net::CookieOptions* options); | 133 net::CookieOptions* options) = 0; |
| 133 | 134 |
| 134 // Create and return a new quota permission context. | 135 // Create and return a new quota permission context. |
| 135 virtual QuotaPermissionContext* CreateQuotaPermissionContext(); | 136 virtual QuotaPermissionContext* CreateQuotaPermissionContext() = 0; |
| 136 | 137 |
| 137 // Shows the given path using the OS file manager. | 138 // Shows the given path using the OS file manager. |
| 138 virtual void RevealFolderInOS(const FilePath& path); | 139 virtual void RevealFolderInOS(const FilePath& path) = 0; |
| 139 | 140 |
| 140 // Informs the embedder that a certificate error has occured. If overridable | 141 // Informs the embedder that a certificate error has occured. If overridable |
| 141 // is true, the user can ignore the error and continue. If it's false, then | 142 // is true, the user can ignore the error and continue. If it's false, then |
| 142 // the certificate error is severe and the user isn't allowed to proceed. The | 143 // the certificate error is severe and the user isn't allowed to proceed. The |
| 143 // embedder can call the callback asynchronously. | 144 // embedder can call the callback asynchronously. |
| 144 virtual void AllowCertificateError( | 145 virtual void AllowCertificateError( |
| 145 SSLCertErrorHandler* handler, | 146 SSLCertErrorHandler* handler, |
| 146 bool overridable, | 147 bool overridable, |
| 147 Callback2<SSLCertErrorHandler*, bool>::Type* callback); | 148 Callback2<SSLCertErrorHandler*, bool>::Type* callback) = 0; |
| 148 | 149 |
| 149 // Shows the user a SSL client certificate selection dialog. When the user has | 150 // Shows the user a SSL client certificate selection dialog. When the user has |
| 150 // made a selection, the dialog will report back to |delegate|. |delegate| is | 151 // made a selection, the dialog will report back to |delegate|. |delegate| is |
| 151 // notified when the dialog closes in call cases; if the user cancels the | 152 // notified when the dialog closes in call cases; if the user cancels the |
| 152 // dialog, we call with a NULL certificate. | 153 // dialog, we call with a NULL certificate. |
| 153 virtual void ShowClientCertificateRequestDialog( | 154 virtual void ShowClientCertificateRequestDialog( |
| 154 int render_process_id, | 155 int render_process_id, |
| 155 int render_view_id, | 156 int render_view_id, |
| 156 SSLClientAuthHandler* handler); | 157 SSLClientAuthHandler* handler) = 0; |
| 157 | 158 |
| 158 // Adds a newly-generated client cert. The embedder should ensure that there's | 159 // Adds a newly-generated client cert. The embedder should ensure that there's |
| 159 // a private key for the cert, displays the cert to the user, and adds it upon | 160 // a private key for the cert, displays the cert to the user, and adds it upon |
| 160 // user approval. | 161 // user approval. |
| 161 virtual void AddNewCertificate( | 162 virtual void AddNewCertificate( |
| 162 net::URLRequest* request, | 163 net::URLRequest* request, |
| 163 net::X509Certificate* cert, | 164 net::X509Certificate* cert, |
| 164 int render_process_id, | 165 int render_process_id, |
| 165 int render_view_id); | 166 int render_view_id) = 0; |
| 166 | 167 |
| 167 // Asks permission to show desktop notifications. | 168 // Asks permission to show desktop notifications. |
| 168 virtual void RequestDesktopNotificationPermission( | 169 virtual void RequestDesktopNotificationPermission( |
| 169 const GURL& source_origin, | 170 const GURL& source_origin, |
| 170 int callback_context, | 171 int callback_context, |
| 171 int render_process_id, | 172 int render_process_id, |
| 172 int render_view_id); | 173 int render_view_id) = 0; |
| 173 | 174 |
| 174 // Checks if the given page has permission to show desktop notifications. | 175 // Checks if the given page has permission to show desktop notifications. |
| 175 // This is called on the IO thread. | 176 // This is called on the IO thread. |
| 176 virtual WebKit::WebNotificationPresenter::Permission | 177 virtual WebKit::WebNotificationPresenter::Permission |
| 177 CheckDesktopNotificationPermission( | 178 CheckDesktopNotificationPermission( |
| 178 const GURL& source_url, | 179 const GURL& source_url, |
| 179 const content::ResourceContext& context); | 180 const content::ResourceContext& context) = 0; |
| 180 | 181 |
| 181 // Show a desktop notification. If |worker| is true, the request came from an | 182 // Show a desktop notification. If |worker| is true, the request came from an |
| 182 // HTML5 web worker, otherwise, it came from a renderer. | 183 // HTML5 web worker, otherwise, it came from a renderer. |
| 183 virtual void ShowDesktopNotification( | 184 virtual void ShowDesktopNotification( |
| 184 const DesktopNotificationHostMsg_Show_Params& params, | 185 const DesktopNotificationHostMsg_Show_Params& params, |
| 185 int render_process_id, | 186 int render_process_id, |
| 186 int render_view_id, | 187 int render_view_id, |
| 187 bool worker); | 188 bool worker) = 0; |
| 188 | 189 |
| 189 // Cancels a displayed desktop notification. | 190 // Cancels a displayed desktop notification. |
| 190 virtual void CancelDesktopNotification( | 191 virtual void CancelDesktopNotification( |
| 191 int render_process_id, | 192 int render_process_id, |
| 192 int render_view_id, | 193 int render_view_id, |
| 193 int notification_id); | 194 int notification_id) = 0; |
| 194 | 195 |
| 195 // Returns true if the given page is allowed to open a window of the given | 196 // Returns true if the given page is allowed to open a window of the given |
| 196 // type. | 197 // type. |
| 197 // This is called on the IO thread. | 198 // This is called on the IO thread. |
| 198 virtual bool CanCreateWindow( | 199 virtual bool CanCreateWindow( |
| 199 const GURL& source_url, | 200 const GURL& source_url, |
| 200 WindowContainerType container_type, | 201 WindowContainerType container_type, |
| 201 const content::ResourceContext& context); | 202 const content::ResourceContext& context) = 0; |
| 202 | 203 |
| 203 // Returns a title string to use in the task manager for a process host with | 204 // Returns a title string to use in the task manager for a process host with |
| 204 // the given URL, or the empty string to fall back to the default logic. | 205 // the given URL, or the empty string to fall back to the default logic. |
| 205 // This is called on the IO thread. | 206 // This is called on the IO thread. |
| 206 virtual std::string GetWorkerProcessTitle( | 207 virtual std::string GetWorkerProcessTitle( |
| 207 const GURL& url, const content::ResourceContext& context); | 208 const GURL& url, const content::ResourceContext& context) = 0; |
| 208 | 209 |
| 209 // Getters for common objects. | 210 // Getters for common objects. |
| 210 virtual ResourceDispatcherHost* GetResourceDispatcherHost(); | 211 virtual ResourceDispatcherHost* GetResourceDispatcherHost() = 0; |
| 211 virtual ui::Clipboard* GetClipboard(); | 212 virtual ui::Clipboard* GetClipboard() = 0; |
| 212 | 213 |
| 213 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 214 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 214 // Can return an optional fd for crash handling, otherwise returns -1. | 215 // Can return an optional fd for crash handling, otherwise returns -1. |
| 215 virtual int GetCrashSignalFD(const std::string& process_type); | 216 virtual int GetCrashSignalFD(const std::string& process_type) = 0; |
| 216 #endif | 217 #endif |
| 217 | 218 |
| 218 #if defined(USE_NSS) | 219 #if defined(USE_NSS) |
| 219 // Return a delegate to authenticate and unlock |module|. | 220 // Return a delegate to authenticate and unlock |module|. |
| 220 // This is called on a worker thread. | 221 // This is called on a worker thread. |
| 221 virtual | 222 virtual |
| 222 crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate( | 223 crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate( |
| 223 const GURL& url); | 224 const GURL& url) = 0; |
| 224 #endif | 225 #endif |
| 225 }; | 226 }; |
| 226 | 227 |
| 227 } // namespace content | 228 } // namespace content |
| 228 | 229 |
| 229 #endif // CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ | 230 #endif // CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ |
| OLD | NEW |