2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-04-12 09:46:58 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 08:58:59 +08:00
|
|
|
#ifndef ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
|
|
|
|
#define ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
|
2013-04-12 09:46:58 +08:00
|
|
|
|
2015-08-11 15:39:17 +08:00
|
|
|
#include <map>
|
2014-05-29 21:24:22 +08:00
|
|
|
#include <string>
|
2015-06-12 13:28:23 +05:30
|
|
|
#include <vector>
|
2014-05-29 21:24:22 +08:00
|
|
|
|
2013-04-12 09:46:58 +08:00
|
|
|
#include "brightray/browser/browser_client.h"
|
2015-08-11 15:39:17 +08:00
|
|
|
#include "content/public/browser/render_process_host_observer.h"
|
2013-04-12 09:46:58 +08:00
|
|
|
|
2015-05-12 17:52:30 +05:30
|
|
|
namespace content {
|
|
|
|
class QuotaPermissionContext;
|
2015-06-04 02:27:06 +05:30
|
|
|
class ClientCertificateDelegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace net {
|
|
|
|
class SSLCertRequestInfo;
|
2015-05-12 17:52:30 +05:30
|
|
|
}
|
|
|
|
|
2013-04-12 09:46:58 +08:00
|
|
|
namespace atom {
|
|
|
|
|
2015-09-29 17:47:26 +05:30
|
|
|
class AtomResourceDispatcherHostDelegate;
|
|
|
|
|
2015-08-11 15:39:17 +08:00
|
|
|
class AtomBrowserClient : public brightray::BrowserClient,
|
|
|
|
public content::RenderProcessHostObserver {
|
2013-04-12 23:16:16 +08:00
|
|
|
public:
|
2013-04-12 09:46:58 +08:00
|
|
|
AtomBrowserClient();
|
2013-04-12 23:16:16 +08:00
|
|
|
virtual ~AtomBrowserClient();
|
2013-04-12 09:46:58 +08:00
|
|
|
|
2015-11-18 10:07:03 +08:00
|
|
|
using Delegate = content::ContentBrowserClient;
|
|
|
|
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
|
|
|
|
|
2015-05-11 14:40:40 +08:00
|
|
|
// Don't force renderer process to restart for once.
|
|
|
|
static void SuppressRendererProcessRestartForOnce();
|
2015-06-12 13:28:23 +05:30
|
|
|
// Custom schemes to be registered to standard.
|
|
|
|
static void SetCustomSchemes(const std::vector<std::string>& schemes);
|
2015-12-09 00:51:46 +05:30
|
|
|
// Custom schemes to be registered to handle service worker.
|
|
|
|
static void SetCustomServiceWorkerSchemes(
|
|
|
|
const std::vector<std::string>& schemes);
|
2015-05-11 14:40:40 +08:00
|
|
|
|
2013-04-12 23:16:16 +08:00
|
|
|
protected:
|
2014-07-28 17:57:54 +08:00
|
|
|
// content::ContentBrowserClient:
|
2014-10-31 22:53:15 +08:00
|
|
|
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
2014-10-31 18:26:01 +08:00
|
|
|
content::SpeechRecognitionManagerDelegate*
|
2015-03-10 15:56:40 -07:00
|
|
|
CreateSpeechRecognitionManagerDelegate() override;
|
2014-10-31 18:26:01 +08:00
|
|
|
content::AccessTokenStore* CreateAccessTokenStore() override;
|
|
|
|
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
|
|
|
|
content::WebPreferences* prefs) override;
|
|
|
|
std::string GetApplicationLocale() override;
|
2015-04-26 12:28:27 +08:00
|
|
|
void OverrideSiteInstanceForNavigation(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
content::SiteInstance* current_instance,
|
|
|
|
const GURL& dest_url,
|
2015-06-26 11:43:39 +02:00
|
|
|
content::SiteInstance** new_instance) override;
|
2014-10-31 18:26:01 +08:00
|
|
|
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
|
|
|
int child_process_id) override;
|
2015-04-28 21:15:58 +05:30
|
|
|
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
2015-05-12 17:52:30 +05:30
|
|
|
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
2015-11-18 10:39:25 +08:00
|
|
|
void AllowCertificateError(
|
|
|
|
int render_process_id,
|
|
|
|
int render_frame_id,
|
|
|
|
int cert_error,
|
|
|
|
const net::SSLInfo& ssl_info,
|
|
|
|
const GURL& request_url,
|
|
|
|
content::ResourceType resource_type,
|
|
|
|
bool overridable,
|
|
|
|
bool strict_enforcement,
|
|
|
|
bool expired_previous_decision,
|
|
|
|
const base::Callback<void(bool)>& callback,
|
|
|
|
content::CertificateRequestResultType* request) override;
|
2015-06-04 02:27:06 +05:30
|
|
|
void SelectClientCertificate(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
net::SSLCertRequestInfo* cert_request_info,
|
|
|
|
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
|
2015-09-29 17:47:26 +05:30
|
|
|
void ResourceDispatcherHostCreated() override;
|
2013-04-12 20:48:02 +08:00
|
|
|
|
2015-08-11 15:39:17 +08:00
|
|
|
// brightray::BrowserClient:
|
2014-10-31 18:26:01 +08:00
|
|
|
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
|
|
|
const content::MainFunctionParams&) override;
|
2013-04-12 09:46:58 +08:00
|
|
|
|
2015-08-11 15:39:17 +08:00
|
|
|
// content::RenderProcessHostObserver:
|
|
|
|
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// pending_render_process => current_render_process.
|
|
|
|
std::map<int, int> pending_processes_;
|
|
|
|
|
2015-09-29 17:47:26 +05:30
|
|
|
scoped_ptr<AtomResourceDispatcherHostDelegate>
|
|
|
|
resource_dispatcher_host_delegate_;
|
|
|
|
|
2015-11-18 10:07:03 +08:00
|
|
|
Delegate* delegate_;
|
|
|
|
|
2013-04-12 09:46:58 +08:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
2014-03-16 08:58:59 +08:00
|
|
|
#endif // ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
|