Depend directly on chrome targets and unfork code (issue #1947)

This commit is contained in:
Marshall Greenblatt
2016-07-13 21:35:07 -04:00
parent 62d177455b
commit 3cc539b506
71 changed files with 811 additions and 1860 deletions

View File

@@ -1,50 +0,0 @@
diff --git web_contents_impl.cc web_contents_impl.cc
index db8263e..07f1989 100644
--- web_contents_impl.cc
+++ web_contents_impl.cc
@@ -1502,6 +1502,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
std::string unique_name = params.main_frame_name;
frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name);
+ if (params.view && params.delegate_view) {
+ view_.reset(params.view);
+ render_view_host_delegate_view_ = params.delegate_view;
+ }
+
+ if (!view_) {
WebContentsViewDelegate* delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
@@ -1534,6 +1540,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
std::move(view_),
&render_view_host_delegate_view_));
}
+ }
CHECK(render_view_host_delegate_view_);
CHECK(view_.get());
@@ -1977,11 +1984,14 @@ void WebContentsImpl::CreateNewWindow(
static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace);
CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context));
+ content::WebContentsView* view = NULL;
+ content::RenderViewHostDelegateView* delegate_view = NULL;
+
if (delegate_ &&
!delegate_->ShouldCreateWebContents(
this, route_id, main_frame_route_id, main_frame_widget_route_id,
params.window_container_type, params.frame_name, params.target_url,
- partition_id, session_storage_namespace)) {
+ partition_id, session_storage_namespace, &view, &delegate_view)) {
if (route_id != MSG_ROUTING_NONE &&
!RenderViewHost::FromID(render_process_id, route_id)) {
// If the embedder didn't create a WebContents for this route, we need to
@@ -2005,6 +2015,8 @@ void WebContentsImpl::CreateNewWindow(
create_params.opener_render_process_id = render_process_id;
create_params.opener_render_frame_id = params.opener_render_frame_id;
create_params.opener_suppressed = params.opener_suppressed;
+ create_params.view = view;
+ create_params.delegate_view = delegate_view;
if (params.disposition == NEW_BACKGROUND_TAB)
create_params.initially_hidden = true;
create_params.renderer_initiated_creation =

View File

@@ -1,30 +0,0 @@
diff --git ui/browser.cc ui/browser.cc
index b10b2df..a47dd18 100644
--- ui/browser.cc
+++ ui/browser.cc
@@ -1618,7 +1618,9 @@ bool Browser::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
// If a BackgroundContents is created, suppress the normal WebContents.
return !MaybeCreateBackgroundContents(
diff --git ui/browser.h ui/browser.h
index 693e84d..be1f1dd 100644
--- ui/browser.h
+++ ui/browser.h
@@ -617,7 +617,9 @@ class Browser : public TabStripModelObserver,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override;
void WebContentsCreated(content::WebContents* source_contents,
int opener_render_frame_id,
const std::string& frame_name,

View File

@@ -0,0 +1,41 @@
diff --git chrome/browser/chrome_browser_main_mac.mm chrome/browser/chrome_browser_main_mac.mm
index 11d7ff4..1013b2ce 100644
--- chrome/browser/chrome_browser_main_mac.mm
+++ chrome/browser/chrome_browser_main_mac.mm
@@ -186,7 +186,7 @@ void EnsureMetadataNeverIndexFile(const base::FilePath& user_data_dir) {
ChromeBrowserMainPartsPosix::PostProfileInit();
g_browser_process->metrics_service()->RecordBreakpadRegistration(
- crash_reporter::GetUploadsEnabled());
+ false);
// TODO(calamity): Make this gated on first_run::IsChromeFirstRun() in M45.
content::BrowserThread::PostAfterStartupTask(
diff --git chrome/browser/crash_upload_list/crash_upload_list_crashpad.cc chrome/browser/crash_upload_list/crash_upload_list_crashpad.cc
index af1bbec..6b92a7c 100644
--- chrome/browser/crash_upload_list/crash_upload_list_crashpad.cc
+++ chrome/browser/crash_upload_list/crash_upload_list_crashpad.cc
@@ -73,8 +73,6 @@ void CrashUploadListCrashpad::LoadUploadList(
// database lives in the .exe, so we need to grab a pointer to a helper in the
// exe to get our reports list.
GetReportsThunk(&reports);
-#else
- crash_reporter::GetReports(&reports);
#endif
for (const crash_reporter::Report& report : reports) {
diff --git chrome/browser/google/google_update_settings_posix.cc chrome/browser/google/google_update_settings_posix.cc
index 059672e..cdecb1a 100644
--- chrome/browser/google/google_update_settings_posix.cc
+++ chrome/browser/google/google_update_settings_posix.cc
@@ -63,10 +63,6 @@ bool GoogleUpdateSettings::GetCollectStatsConsent() {
// static
bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) {
-#if defined(OS_MACOSX)
- crash_reporter::SetUploadsEnabled(consented);
-#endif
-
base::FilePath consent_dir;
PathService::Get(chrome::DIR_USER_DATA, &consent_dir);
if (!base::DirectoryExists(consent_dir))

View File

@@ -0,0 +1,14 @@
diff --git chrome/common/chrome_content_client.cc chrome/common/chrome_content_client.cc
index 57355af2..01cde06 100644
--- chrome/common/chrome_content_client.cc
+++ chrome/common/chrome_content_client.cc
@@ -76,7 +76,7 @@
#endif
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
- !defined(WIDEVINE_CDM_IS_COMPONENT)
+ !defined(WIDEVINE_CDM_IS_COMPONENT) && defined(WIDEVINE_CDM_VERSION_STRING)
#define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT
#include "chrome/common/widevine_cdm_constants.h"
#endif

View File

@@ -1,30 +0,0 @@
diff --git browser/guest_view/extension_options/extension_options_guest.cc browser/guest_view/extension_options/extension_options_guest.cc
index 3849b7e..a974f34 100644
--- browser/guest_view/extension_options/extension_options_guest.cc
+++ browser/guest_view/extension_options/extension_options_guest.cc
@@ -203,7 +203,9 @@ bool ExtensionOptionsGuest::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
// This method handles opening links from within the guest. Since this guest
// view is used for displaying embedded extension options, we want any
// external links to be opened in a new tab, not in a new guest view.
diff --git browser/guest_view/extension_options/extension_options_guest.h browser/guest_view/extension_options/extension_options_guest.h
index e0309f7..f6a3878 100644
--- browser/guest_view/extension_options/extension_options_guest.h
+++ browser/guest_view/extension_options/extension_options_guest.h
@@ -56,7 +56,9 @@ class ExtensionOptionsGuest
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) final;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) final;
// content::WebContentsObserver implementation.
void DidNavigateMainFrame(const content::LoadCommittedDetails& details,

View File

@@ -23,19 +23,6 @@ index 23e67d9..c3d4ec6 100644
"//chrome/test:telemetry_perf_unittests",
"//chrome/test:unit_tests",
"//components:components_browsertests",
diff --git build/config/features.gni build/config/features.gni
index 9d33d91..d460e86 100644
--- build/config/features.gni
+++ build/config/features.gni
@@ -148,7 +148,7 @@ enable_web_speech = !is_android && !is_ios
enable_task_manager = !is_ios && !is_android
-enable_themes = !is_android && !is_ios
+enable_themes = !is_android && !is_ios && !is_linux
# Whether we are using the rlz library or not. Platforms like Android send
# rlz codes for searches but do not use the library.
diff --git build/config/mac/base_rules.gni build/config/mac/base_rules.gni
index 109710d..d2c442e 100644
--- build/config/mac/base_rules.gni

View File

@@ -0,0 +1,17 @@
diff --git chrome_elf/chrome_elf.gyp chrome_elf/chrome_elf.gyp
index 7a49fe8..b4be214 100644
--- chrome_elf/chrome_elf.gyp
+++ chrome_elf/chrome_elf.gyp
@@ -59,12 +59,6 @@
],
# Set /SUBSYSTEM:WINDOWS.
'SubSystem': '2',
- 'AdditionalDependencies!': [
- 'user32.lib',
- ],
- 'IgnoreDefaultLibraryNames': [
- 'user32.lib',
- ],
},
},
},

View File

@@ -1,7 +1,37 @@
diff --git printing/common/print_messages.cc printing/common/print_messages.cc
diff --git chrome/browser/ui/cocoa/applescript/tab_applescript.mm chrome/browser/ui/cocoa/applescript/tab_applescript.mm
index b43b88b..7779496 100644
--- chrome/browser/ui/cocoa/applescript/tab_applescript.mm
+++ chrome/browser/ui/cocoa/applescript/tab_applescript.mm
@@ -9,7 +9,9 @@
#include "base/logging.h"
#import "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
+#if defined(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_view_manager.h"
+#endif
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/cocoa/applescript/apple_event_util.h"
#include "chrome/browser/ui/cocoa/applescript/error_applescript.h"
@@ -227,11 +229,15 @@ - (void)handlesStopScriptCommand:(NSScriptCommand*)command {
- (void)handlesPrintScriptCommand:(NSScriptCommand*)command {
AppleScript::LogAppleScriptUMA(AppleScript::AppleScriptCommand::TAB_PRINT);
+#if defined(ENABLE_PRINT_PREVIEW)
bool initiated =
printing::PrintViewManager::FromWebContents(webContents_)->PrintNow();
if (!initiated) {
AppleScript::SetError(AppleScript::errInitiatePrinting);
}
+#else
+ NOTIMPLEMENTED();
+#endif
}
- (void)handlesSaveScriptCommand:(NSScriptCommand*)command {
diff --git components/printing/common/print_messages.cc components/printing/common/print_messages.cc
index 6798e35..215777f 100644
--- printing/common/print_messages.cc
+++ printing/common/print_messages.cc
--- components/printing/common/print_messages.cc
+++ components/printing/common/print_messages.cc
@@ -103,7 +103,6 @@ void PrintMsg_PrintPages_Params::Reset() {
pages = std::vector<int>();
}
@@ -15,10 +45,10 @@ index 6798e35..215777f 100644
~PrintHostMsg_SetOptionsFromDocument_Params() {
}
-#endif // defined(ENABLE_PRINT_PREVIEW)
diff --git printing/common/print_messages.h printing/common/print_messages.h
diff --git components/printing/common/print_messages.h components/printing/common/print_messages.h
index 705211b..a524333 100644
--- printing/common/print_messages.h
+++ printing/common/print_messages.h
--- components/printing/common/print_messages.h
+++ components/printing/common/print_messages.h
@@ -71,7 +71,6 @@ struct PrintMsg_PrintPages_Params {
std::vector<int> pages;
};
@@ -135,10 +165,10 @@ index 705211b..a524333 100644
IPC_MESSAGE_ROUTED1(PrintHostMsg_SetOptionsFromDocument,
PrintHostMsg_SetOptionsFromDocument_Params /* params */)
-#endif // defined(ENABLE_PRINT_PREVIEW)
diff --git printing/renderer/print_web_view_helper.cc printing/renderer/print_web_view_helper.cc
diff --git components/printing/renderer/print_web_view_helper.cc components/printing/renderer/print_web_view_helper.cc
index b25340c..47d419e 100644
--- printing/renderer/print_web_view_helper.cc
+++ printing/renderer/print_web_view_helper.cc
--- components/printing/renderer/print_web_view_helper.cc
+++ components/printing/renderer/print_web_view_helper.cc
@@ -83,6 +83,9 @@ const float kPrintingMinimumShrinkFactor = 1.333f;
#if defined(ENABLE_PRINT_PREVIEW)
@@ -394,10 +424,10 @@ index b25340c..47d419e 100644
PrintWebViewHelper::PrintPreviewContext::PrintPreviewContext()
: total_page_count_(0),
diff --git printing/renderer/print_web_view_helper.h printing/renderer/print_web_view_helper.h
diff --git components/printing/renderer/print_web_view_helper.h components/printing/renderer/print_web_view_helper.h
index fe33d5e..3f1b7b5 100644
--- printing/renderer/print_web_view_helper.h
+++ printing/renderer/print_web_view_helper.h
--- components/printing/renderer/print_web_view_helper.h
+++ components/printing/renderer/print_web_view_helper.h
@@ -137,9 +137,7 @@ class PrintWebViewHelper
OK,
FAIL_PRINT_INIT,
@@ -491,10 +521,10 @@ index fe33d5e..3f1b7b5 100644
PrintPreviewContext print_preview_context_;
bool is_loading_;
bool is_scripted_preview_delayed_;
diff --git printing/renderer/print_web_view_helper_mac.mm printing/renderer/print_web_view_helper_mac.mm
diff --git components/printing/renderer/print_web_view_helper_mac.mm components/printing/renderer/print_web_view_helper_mac.mm
index d227c5e..f362093 100644
--- printing/renderer/print_web_view_helper_mac.mm
+++ printing/renderer/print_web_view_helper_mac.mm
--- components/printing/renderer/print_web_view_helper_mac.mm
+++ components/printing/renderer/print_web_view_helper_mac.mm
@@ -68,7 +68,6 @@ void PrintWebViewHelper::PrintPageInternal(
Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params));
}
@@ -526,10 +556,10 @@ index d227c5e..f362093 100644
RenderPageContent(frame, page_number, canvas_area, content_area,
scale_factor, static_cast<blink::WebCanvas*>(canvas));
}
diff --git resources/printing_resources.grdp resources/printing_resources.grdp
diff --git components/resources/printing_resources.grdp components/resources/printing_resources.grdp
index 7213746..32b8b1e 100644
--- resources/printing_resources.grdp
+++ resources/printing_resources.grdp
--- components/resources/printing_resources.grdp
+++ components/resources/printing_resources.grdp
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<grit-part>

View File

@@ -1,83 +0,0 @@
diff --git web_contents.cc web_contents.cc
index fa0afb5..d677b31 100644
--- web_contents.cc
+++ web_contents.cc
@@ -29,7 +29,9 @@ WebContents::CreateParams::CreateParams(BrowserContext* context,
guest_delegate(nullptr),
context(nullptr),
renderer_initiated_creation(false),
- initialize_renderer(false) {
+ initialize_renderer(false),
+ view(nullptr),
+ delegate_view(nullptr) {
}
WebContents::CreateParams::CreateParams(const CreateParams& other) = default;
diff --git web_contents.h web_contents.h
index 9ccb6fe..d8561f9 100644
--- web_contents.h
+++ web_contents.h
@@ -55,8 +55,10 @@ class PageState;
class RenderFrameHost;
class RenderProcessHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class RenderWidgetHostView;
class WebContentsDelegate;
+class WebContentsView;
struct CustomContextMenuContext;
struct DropData;
struct Manifest;
@@ -157,6 +159,10 @@ class WebContents : public PageNavigator,
// Note that the pre-created renderer process may not be used if the first
// navigation requires a dedicated or privileged process, such as a WebUI.
bool initialize_renderer;
+
+ // Optionally specify the view and delegate view.
+ content::WebContentsView* view;
+ content::RenderViewHostDelegateView* delegate_view;
};
// Creates a new WebContents.
diff --git web_contents_delegate.cc web_contents_delegate.cc
index df97348..8e2168e 100644
--- web_contents_delegate.cc
+++ web_contents_delegate.cc
@@ -144,7 +144,9 @@ bool WebContentsDelegate::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace) {
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
return true;
}
diff --git web_contents_delegate.h web_contents_delegate.h
index 2816c4d..387821f 100644
--- web_contents_delegate.h
+++ web_contents_delegate.h
@@ -42,9 +42,11 @@ class JavaScriptDialogManager;
class PageState;
class RenderFrameHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class SessionStorageNamespace;
class WebContents;
class WebContentsImpl;
+class WebContentsView;
struct ColorSuggestion;
struct ContextMenuParams;
struct DropData;
@@ -307,7 +309,9 @@ class CONTENT_EXPORT WebContentsDelegate {
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace);
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view);
// Notifies the delegate about the creation of a new WebContents. This
// typically happens when popups are created.

View File

@@ -1,30 +0,0 @@
diff --git web_dialog_view.cc web_dialog_view.cc
index d8afe6e..59259b7 100644
--- web_dialog_view.cc
+++ web_dialog_view.cc
@@ -341,7 +341,9 @@ bool WebDialogView::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
if (delegate_)
return delegate_->HandleShouldCreateWebContents();
return true;
diff --git web_dialog_view.h web_dialog_view.h
index 65be6d54..7802d6d 100644
--- web_dialog_view.h
+++ web_dialog_view.h
@@ -123,7 +123,9 @@ class WEBVIEW_EXPORT WebDialogView : public views::ClientView,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override;
private:
FRIEND_TEST_ALL_PREFIXES(WebDialogBrowserTest, WebContentRendered);

View File

@@ -0,0 +1,283 @@
diff --git chrome/browser/extensions/api/tab_capture/offscreen_tab.cc chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
index ddc31cf..81b7d1c 100644
--- chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
+++ chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
@@ -203,7 +203,9 @@ bool OffscreenTab::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
DCHECK_EQ(offscreen_tab_web_contents_.get(), contents);
// Disallow creating separate WebContentses. The WebContents implementation
// uses this to spawn new windows/tabs, which is also not allowed for
diff --git chrome/browser/extensions/api/tab_capture/offscreen_tab.h chrome/browser/extensions/api/tab_capture/offscreen_tab.h
index 712c117..4dc59be 100644
--- chrome/browser/extensions/api/tab_capture/offscreen_tab.h
+++ chrome/browser/extensions/api/tab_capture/offscreen_tab.h
@@ -149,7 +149,9 @@ class OffscreenTab : protected content::WebContentsDelegate,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) final;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) final;
bool EmbedsFullscreenWidget() const final;
void EnterFullscreenModeForTab(content::WebContents* contents,
const GURL& origin) final;
diff --git chrome/browser/prerender/prerender_contents.cc chrome/browser/prerender/prerender_contents.cc
index d646060..697bf1b 100644
--- chrome/browser/prerender/prerender_contents.cc
+++ chrome/browser/prerender/prerender_contents.cc
@@ -129,7 +129,9 @@ class PrerenderContents::WebContentsDelegateImpl
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace) override {
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override {
// Since we don't want to permit child windows that would have a
// window.opener property, terminate prerendering.
prerender_contents_->Destroy(FINAL_STATUS_CREATE_NEW_WINDOW);
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
index b10b2df..a47dd18 100644
--- chrome/browser/ui/browser.cc
+++ chrome/browser/ui/browser.cc
@@ -1618,7 +1618,9 @@ bool Browser::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
// If a BackgroundContents is created, suppress the normal WebContents.
return !MaybeCreateBackgroundContents(
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
index 693e84d..be1f1dd 100644
--- chrome/browser/ui/browser.h
+++ chrome/browser/ui/browser.h
@@ -617,7 +617,9 @@ class Browser : public TabStripModelObserver,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override;
void WebContentsCreated(content::WebContents* source_contents,
int opener_render_frame_id,
const std::string& frame_name,
diff --git content/browser/web_contents/web_contents_impl.cc content/browser/web_contents/web_contents_impl.cc
index db8263e..07f1989 100644
--- content/browser/web_contents/web_contents_impl.cc
+++ content/browser/web_contents/web_contents_impl.cc
@@ -1502,6 +1502,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
std::string unique_name = params.main_frame_name;
frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name);
+ if (params.view && params.delegate_view) {
+ view_.reset(params.view);
+ render_view_host_delegate_view_ = params.delegate_view;
+ }
+
+ if (!view_) {
WebContentsViewDelegate* delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
@@ -1534,6 +1540,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
std::move(view_),
&render_view_host_delegate_view_));
}
+ }
CHECK(render_view_host_delegate_view_);
CHECK(view_.get());
@@ -1977,11 +1984,14 @@ void WebContentsImpl::CreateNewWindow(
static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace);
CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context));
+ content::WebContentsView* view = NULL;
+ content::RenderViewHostDelegateView* delegate_view = NULL;
+
if (delegate_ &&
!delegate_->ShouldCreateWebContents(
this, route_id, main_frame_route_id, main_frame_widget_route_id,
params.window_container_type, params.frame_name, params.target_url,
- partition_id, session_storage_namespace)) {
+ partition_id, session_storage_namespace, &view, &delegate_view)) {
if (route_id != MSG_ROUTING_NONE &&
!RenderViewHost::FromID(render_process_id, route_id)) {
// If the embedder didn't create a WebContents for this route, we need to
@@ -2005,6 +2015,8 @@ void WebContentsImpl::CreateNewWindow(
create_params.opener_render_process_id = render_process_id;
create_params.opener_render_frame_id = params.opener_render_frame_id;
create_params.opener_suppressed = params.opener_suppressed;
+ create_params.view = view;
+ create_params.delegate_view = delegate_view;
if (params.disposition == NEW_BACKGROUND_TAB)
create_params.initially_hidden = true;
create_params.renderer_initiated_creation =
diff --git content/public/browser/web_contents.cc content/public/browser/web_contents.cc
index fa0afb5..d677b31 100644
--- content/public/browser/web_contents.cc
+++ content/public/browser/web_contents.cc
@@ -29,7 +29,9 @@ WebContents::CreateParams::CreateParams(BrowserContext* context,
guest_delegate(nullptr),
context(nullptr),
renderer_initiated_creation(false),
- initialize_renderer(false) {
+ initialize_renderer(false),
+ view(nullptr),
+ delegate_view(nullptr) {
}
WebContents::CreateParams::CreateParams(const CreateParams& other) = default;
diff --git content/public/browser/web_contents.h content/public/browser/web_contents.h
index 9ccb6fe..d8561f9 100644
--- content/public/browser/web_contents.h
+++ content/public/browser/web_contents.h
@@ -55,8 +55,10 @@ class PageState;
class RenderFrameHost;
class RenderProcessHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class RenderWidgetHostView;
class WebContentsDelegate;
+class WebContentsView;
struct CustomContextMenuContext;
struct DropData;
struct Manifest;
@@ -157,6 +159,10 @@ class WebContents : public PageNavigator,
// Note that the pre-created renderer process may not be used if the first
// navigation requires a dedicated or privileged process, such as a WebUI.
bool initialize_renderer;
+
+ // Optionally specify the view and delegate view.
+ content::WebContentsView* view;
+ content::RenderViewHostDelegateView* delegate_view;
};
// Creates a new WebContents.
diff --git content/public/browser/web_contents_delegate.cc content/public/browser/web_contents_delegate.cc
index df97348..8e2168e 100644
--- content/public/browser/web_contents_delegate.cc
+++ content/public/browser/web_contents_delegate.cc
@@ -144,7 +144,9 @@ bool WebContentsDelegate::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace) {
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
return true;
}
diff --git content/public/browser/web_contents_delegate.h content/public/browser/web_contents_delegate.h
index 2816c4d..387821f 100644
--- content/public/browser/web_contents_delegate.h
+++ content/public/browser/web_contents_delegate.h
@@ -42,9 +42,11 @@ class JavaScriptDialogManager;
class PageState;
class RenderFrameHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class SessionStorageNamespace;
class WebContents;
class WebContentsImpl;
+class WebContentsView;
struct ColorSuggestion;
struct ContextMenuParams;
struct DropData;
@@ -307,7 +309,9 @@ class CONTENT_EXPORT WebContentsDelegate {
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace);
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view);
// Notifies the delegate about the creation of a new WebContents. This
// typically happens when popups are created.
diff --git extensions/browser/guest_view/extension_options/extension_options_guest.cc extensions/browser/guest_view/extension_options/extension_options_guest.cc
index 3849b7e..a974f34 100644
--- extensions/browser/guest_view/extension_options/extension_options_guest.cc
+++ extensions/browser/guest_view/extension_options/extension_options_guest.cc
@@ -203,7 +203,9 @@ bool ExtensionOptionsGuest::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
// This method handles opening links from within the guest. Since this guest
// view is used for displaying embedded extension options, we want any
// external links to be opened in a new tab, not in a new guest view.
diff --git extensions/browser/guest_view/extension_options/extension_options_guest.h extensions/browser/guest_view/extension_options/extension_options_guest.h
index e0309f7..f6a3878 100644
--- extensions/browser/guest_view/extension_options/extension_options_guest.h
+++ extensions/browser/guest_view/extension_options/extension_options_guest.h
@@ -56,7 +56,9 @@ class ExtensionOptionsGuest
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) final;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) final;
// content::WebContentsObserver implementation.
void DidNavigateMainFrame(const content::LoadCommittedDetails& details,
diff --git ui/keyboard/content/keyboard_ui_content.cc ui/keyboard/content/keyboard_ui_content.cc
index cd6a2ab..ef2c820 100644
--- ui/keyboard/content/keyboard_ui_content.cc
+++ ui/keyboard/content/keyboard_ui_content.cc
@@ -64,7 +64,9 @@ class KeyboardContentsDelegate : public content::WebContentsDelegate,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override {
return false;
}
diff --git ui/views/controls/webview/web_dialog_view.cc ui/views/controls/webview/web_dialog_view.cc
index d8afe6e..59259b7 100644
--- ui/views/controls/webview/web_dialog_view.cc
+++ ui/views/controls/webview/web_dialog_view.cc
@@ -341,7 +341,9 @@ bool WebDialogView::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
if (delegate_)
return delegate_->HandleShouldCreateWebContents();
return true;
diff --git ui/views/controls/webview/web_dialog_view.h ui/views/controls/webview/web_dialog_view.h
index 65be6d54..7802d6d 100644
--- ui/views/controls/webview/web_dialog_view.h
+++ ui/views/controls/webview/web_dialog_view.h
@@ -123,7 +123,9 @@ class WEBVIEW_EXPORT WebDialogView : public views::ClientView,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override;
private:
FRIEND_TEST_ALL_PREFIXES(WebDialogBrowserTest, WebContentRendered);