diff options
author | Andras Becsi <andras.becsi@digia.com> | 2013-07-05 18:34:45 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-07-09 13:45:41 +0200 |
commit | 1daab3653e56469868656b32fa87b7f9585ec577 (patch) | |
tree | 10a9cfe812347ed2582a7f68a7ffdc27726e81c0 | |
parent | a912e57e189847509efd75d8a4563ad8c7aa1079 (diff) |
Get rid of the need to export content::GetContentClient()
ContentBrowserClientQt is a singleton which makes it possible
to access it from WebContentsViewQt and removes the need for
patching chromium.
This is similar to how ShellContentBrowserClient is managed
in the content shell.
Change-Id: I67f35520935388888c7230806ad543a58b3211c3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | lib/content_browser_client_qt.cpp | 23 | ||||
-rw-r--r-- | lib/content_browser_client_qt.h | 4 | ||||
-rw-r--r-- | lib/web_contents_view_qt.cpp | 2 | ||||
-rw-r--r-- | patches/0001-My-local-fixes.patch | 13 | ||||
-rw-r--r-- | qtwebengine.gypi | 2 |
5 files changed, 27 insertions, 17 deletions
diff --git a/lib/content_browser_client_qt.cpp b/lib/content_browser_client_qt.cpp index 2a56fdeab..e4fcb5acb 100644 --- a/lib/content_browser_client_qt.cpp +++ b/lib/content_browser_client_qt.cpp @@ -47,6 +47,12 @@ #include "browser_context_qt.h" #include "web_contents_view_qt.h" +namespace { + +ContentBrowserClientQt* gBrowserClient = 0; // Owned by ContentMainDelegateQt. + +} // namespace + class BrowserMainPartsQt : public content::BrowserMainParts { public: @@ -101,6 +107,23 @@ content::WebContentsViewPort* ContentBrowserClientQt::OverrideCreateWebContentsV return rv; } +ContentBrowserClientQt::ContentBrowserClientQt() + : m_browserMainParts(0) +{ + Q_ASSERT(!gBrowserClient); + gBrowserClient = this; +} + +ContentBrowserClientQt::~ContentBrowserClientQt() +{ + gBrowserClient = 0; +} + +ContentBrowserClientQt *ContentBrowserClientQt::Get() +{ + return gBrowserClient; +} + content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams ¶meters) { m_browserMainParts = new BrowserMainPartsQt(parameters); diff --git a/lib/content_browser_client_qt.h b/lib/content_browser_client_qt.h index 32481ad60..5ba9363db 100644 --- a/lib/content_browser_client_qt.h +++ b/lib/content_browser_client_qt.h @@ -65,10 +65,12 @@ class BrowserMainPartsQt; class ContentBrowserClientQt : public content::ContentBrowserClient { public: + ContentBrowserClientQt(); + ~ContentBrowserClientQt(); + static ContentBrowserClientQt* Get(); virtual content::WebContentsViewPort* OverrideCreateWebContentsView(content::WebContents* , content::RenderViewHostDelegateView**) Q_DECL_OVERRIDE; virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams& parameters) Q_DECL_OVERRIDE; - BrowserContextQt* browser_context(); net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *content_browser_context, content::ProtocolHandlerMap *protocol_handlers); diff --git a/lib/web_contents_view_qt.cpp b/lib/web_contents_view_qt.cpp index 1ac83ca47..2a44da7ab 100644 --- a/lib/web_contents_view_qt.cpp +++ b/lib/web_contents_view_qt.cpp @@ -51,7 +51,7 @@ WebContentsViewQtClient::WebContentsViewQtClient() // This has to be the first thing we do. : context(WebEngineContext::current()) { - content::BrowserContext* browser_context = static_cast<ContentBrowserClientQt*>(content::GetContentClient()->browser())->browser_context(); + content::BrowserContext* browser_context = ContentBrowserClientQt::Get()->browser_context(); webContentsDelegate.reset(new WebContentsDelegateQt(browser_context, NULL, MSG_ROUTING_NONE, gfx::Size())); } diff --git a/patches/0001-My-local-fixes.patch b/patches/0001-My-local-fixes.patch index 87a08aab9..ab9e927d7 100644 --- a/patches/0001-My-local-fixes.patch +++ b/patches/0001-My-local-fixes.patch @@ -42,19 +42,6 @@ index bed5ff2..992e0d0 100644 public: virtual ~ContentMainRunner() {} -diff --git a/content/public/common/content_client.h b/content/public/common/content_client.h -index 4c1d110..ddf6a32 100644 ---- a/content/public/common/content_client.h -+++ b/content/public/common/content_client.h -@@ -63,7 +63,7 @@ CONTENT_EXPORT void SetContentClient(ContentClient* client); - - #if defined(CONTENT_IMPLEMENTATION) - // Content's embedder API should only be used by content. --ContentClient* GetContentClient(); -+CONTENT_EXPORT ContentClient* GetContentClient(); - #endif - - // Used for tests to override the relevant embedder interfaces. Each method -- 1.8.3 diff --git a/qtwebengine.gypi b/qtwebengine.gypi index a518d46fd..5d793b0ea 100644 --- a/qtwebengine.gypi +++ b/qtwebengine.gypi @@ -11,8 +11,6 @@ }], ], }, -# Needed to get access to content::GetContentClient() - 'defines': ['CONTENT_IMPLEMENTATION'], 'dependencies': [ '<(chromium_src_dir)/content/content.gyp:content', '<(chromium_src_dir)/content/content.gyp:content_app', |