refactor: more cleanup of chromium_src (#15424)

This commit is contained in:
Milan Burda 2018-11-05 15:29:33 +01:00 committed by John Kleinschmidt
parent c422011d58
commit a19d20cfb8
13 changed files with 54 additions and 301 deletions

View file

@ -18,6 +18,7 @@
#include "atom/browser/atom_paths.h" #include "atom/browser/atom_paths.h"
#include "atom/browser/atom_web_ui_controller_factory.h" #include "atom/browser/atom_web_ui_controller_factory.h"
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "atom/browser/browser_process_impl.h"
#include "atom/browser/io_thread.h" #include "atom/browser/io_thread.h"
#include "atom/browser/javascript_environment.h" #include "atom/browser/javascript_environment.h"
#include "atom/browser/media/media_capture_devices_dispatcher.h" #include "atom/browser/media/media_capture_devices_dispatcher.h"
@ -34,7 +35,6 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/icon_manager.h" #include "chrome/browser/icon_manager.h"
#include "chrome/browser/net/chrome_net_log_helper.h" #include "chrome/browser/net/chrome_net_log_helper.h"
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/browser_process_impl.h" #include "atom/browser/browser_process_impl.h"
#include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/print_job_manager.h"
#include "printing/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h"

View file

@ -7,8 +7,8 @@
// will return NULL if the service is not available, so callers must check for // will return NULL if the service is not available, so callers must check for
// this condition. // this condition.
#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ #ifndef ATOM_BROWSER_BROWSER_PROCESS_IMPL_H_
#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ #define ATOM_BROWSER_BROWSER_PROCESS_IMPL_H_
#include <memory> #include <memory>
#include <string> #include <string>
@ -104,4 +104,4 @@ class BrowserProcessImpl : public BrowserProcess {
DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
}; };
#endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ #endif // ATOM_BROWSER_BROWSER_PROCESS_IMPL_H_

View file

@ -40,6 +40,8 @@ static_library("chrome") {
"//chrome/browser/net/proxy_service_factory.h", "//chrome/browser/net/proxy_service_factory.h",
"//chrome/browser/ssl/security_state_tab_helper.cc", "//chrome/browser/ssl/security_state_tab_helper.cc",
"//chrome/browser/ssl/security_state_tab_helper.h", "//chrome/browser/ssl/security_state_tab_helper.h",
"//chrome/browser/win/chrome_process_finder.cc",
"//chrome/browser/win/chrome_process_finder.h",
"//extensions/browser/app_window/size_constraints.cc", "//extensions/browser/app_window/size_constraints.cc",
"//extensions/browser/app_window/size_constraints.h", "//extensions/browser/app_window/size_constraints.h",
] ]

View file

@ -1,85 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chrome_process_finder_win.h"
#include <shellapi.h>
#include <string>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/process/process.h"
#include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/message_window.h"
#include "base/win/scoped_handle.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
namespace {
int timeout_in_milliseconds = 20 * 1000;
} // namespace
namespace chrome {
HWND FindRunningChromeWindow(const base::FilePath& user_data_dir) {
return base::win::MessageWindow::FindWindow(user_data_dir.value());
}
NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window,
bool fast_start) {
DCHECK(remote_window);
DWORD process_id = 0;
DWORD thread_id = GetWindowThreadProcessId(remote_window, &process_id);
if (!thread_id || !process_id)
return NOTIFY_FAILED;
// Send the command line to the remote chrome window.
// Format is "START\0<<<current directory>>>\0<<<commandline>>>".
std::wstring to_send(L"START\0", 6); // want the NULL in the string.
base::FilePath cur_dir;
if (!base::GetCurrentDirectory(&cur_dir))
return NOTIFY_FAILED;
to_send.append(cur_dir.value());
to_send.append(L"\0", 1); // Null separator.
to_send.append(::GetCommandLineW());
to_send.append(L"\0", 1); // Null separator.
// Allow the current running browser window to make itself the foreground
// window (otherwise it will just flash in the taskbar).
::AllowSetForegroundWindow(process_id);
COPYDATASTRUCT cds;
cds.dwData = 0;
cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t));
cds.lpData = const_cast<wchar_t*>(to_send.c_str());
DWORD_PTR result = 0;
if (::SendMessageTimeout(remote_window, WM_COPYDATA, NULL,
reinterpret_cast<LPARAM>(&cds), SMTO_ABORTIFHUNG,
timeout_in_milliseconds, &result)) {
return result ? NOTIFY_SUCCESS : NOTIFY_FAILED;
}
// It is possible that the process owning this window may have died by now.
if (!::IsWindow(remote_window))
return NOTIFY_FAILED;
// If the window couldn't be notified but still exists, assume it is hung.
return NOTIFY_WINDOW_HUNG;
}
base::TimeDelta SetNotificationTimeoutForTesting(base::TimeDelta new_timeout) {
base::TimeDelta old_timeout =
base::TimeDelta::FromMilliseconds(timeout_in_milliseconds);
timeout_in_milliseconds = new_timeout.InMilliseconds();
return old_timeout;
}
} // namespace chrome

View file

@ -1,39 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROME_PROCESS_FINDER_WIN_H_
#define CHROME_BROWSER_CHROME_PROCESS_FINDER_WIN_H_
#include <windows.h>
#include "base/time/time.h"
namespace base {
class FilePath;
}
namespace chrome {
enum NotifyChromeResult {
NOTIFY_SUCCESS,
NOTIFY_FAILED,
NOTIFY_WINDOW_HUNG,
};
// Finds an already running Chrome window if it exists.
HWND FindRunningChromeWindow(const base::FilePath& user_data_dir);
// Attempts to send the current command line to an already running instance of
// Chrome via a WM_COPYDATA message.
// Returns true if a running Chrome is found and successfully notified.
// |fast_start| is true when this is being called on the window fast start path.
NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window,
bool fast_start);
// Changes the notification timeout to |new_timeout|, returns the old timeout.
base::TimeDelta SetNotificationTimeoutForTesting(base::TimeDelta new_timeout);
} // namespace chrome
#endif // CHROME_BROWSER_CHROME_PROCESS_FINDER_WIN_H_

View file

@ -20,7 +20,7 @@
#include "base/win/registry.h" #include "base/win/registry.h"
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "chrome/browser/chrome_process_finder_win.h" #include "chrome/browser/win/chrome_process_finder.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"

View file

@ -1,113 +0,0 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/pdf/renderer/pepper_pdf_host.h"
#include "atom/common/api/api_messages.h"
#include "base/memory/ptr_util.h"
#include "content/public/common/referrer.h"
#include "content/public/renderer/pepper_plugin_instance.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace pdf {
PepperPDFHost::PepperPDFHost(content::RendererPpapiHost* host,
PP_Instance instance,
PP_Resource resource)
: ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource),
host_(host) {}
PepperPDFHost::~PepperPDFHost() {}
int32_t PepperPDFHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
PPAPI_BEGIN_MESSAGE_MAP(PepperPDFHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStartLoading,
OnHostMsgDidStartLoading)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_DidStopLoading,
OnHostMsgDidStopLoading)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_PDF_SaveAs,
OnHostMsgSaveAs)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetSelectedText,
OnHostMsgSetSelectedText)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_PDF_SetLinkUnderCursor,
OnHostMsgSetLinkUnderCursor)
PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
int32_t PepperPDFHost::OnHostMsgDidStartLoading(
ppapi::host::HostMessageContext* context) {
content::RenderFrame* render_frame = GetRenderFrame();
if (!render_frame)
return PP_ERROR_FAILED;
render_frame->PluginDidStartLoading();
return PP_OK;
}
int32_t PepperPDFHost::OnHostMsgDidStopLoading(
ppapi::host::HostMessageContext* context) {
content::RenderFrame* render_frame = GetRenderFrame();
if (!render_frame)
return PP_ERROR_FAILED;
render_frame->PluginDidStopLoading();
return PP_OK;
}
int32_t PepperPDFHost::OnHostMsgSaveAs(
ppapi::host::HostMessageContext* context) {
content::PepperPluginInstance* instance =
host_->GetPluginInstance(pp_instance());
if (!instance)
return PP_ERROR_FAILED;
content::RenderFrame* render_frame = instance->GetRenderFrame();
if (!render_frame)
return PP_ERROR_FAILED;
GURL url = instance->GetPluginURL();
content::Referrer referrer;
referrer.url = url;
referrer.policy = blink::kWebReferrerPolicyDefault;
referrer = content::Referrer::SanitizeForRequest(url, referrer);
render_frame->Send(new AtomFrameHostMsg_PDFSaveURLAs(
render_frame->GetRoutingID(), url, referrer));
return PP_OK;
}
int32_t PepperPDFHost::OnHostMsgSetSelectedText(
ppapi::host::HostMessageContext* context,
const base::string16& selected_text) {
content::PepperPluginInstance* instance =
host_->GetPluginInstance(pp_instance());
if (!instance)
return PP_ERROR_FAILED;
instance->SetSelectedText(selected_text);
return PP_OK;
}
int32_t PepperPDFHost::OnHostMsgSetLinkUnderCursor(
ppapi::host::HostMessageContext* context,
const std::string& url) {
content::PepperPluginInstance* instance =
host_->GetPluginInstance(pp_instance());
if (!instance)
return PP_ERROR_FAILED;
instance->SetLinkUnderCursor(url);
return PP_OK;
}
content::RenderFrame* PepperPDFHost::GetRenderFrame() {
content::PepperPluginInstance* instance =
host_->GetPluginInstance(pp_instance());
return instance ? instance->GetRenderFrame() : nullptr;
}
} // namespace pdf

View file

@ -1,52 +0,0 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
#define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "ppapi/host/resource_host.h"
namespace content {
class RenderFrame;
class RendererPpapiHost;
} // namespace content
namespace pdf {
class PdfAccessibilityTree;
class PepperPDFHost : public ppapi::host::ResourceHost {
public:
PepperPDFHost(content::RendererPpapiHost* host,
PP_Instance instance,
PP_Resource resource);
~PepperPDFHost() override;
// ppapi::host::ResourceHost:
int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) override;
private:
int32_t OnHostMsgDidStartLoading(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgDidStopLoading(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgSaveAs(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgSetSelectedText(ppapi::host::HostMessageContext* context,
const base::string16& selected_text);
int32_t OnHostMsgSetLinkUnderCursor(ppapi::host::HostMessageContext* context,
const std::string& url);
content::RenderFrame* GetRenderFrame();
content::RendererPpapiHost* const host_;
DISALLOW_COPY_AND_ASSIGN(PepperPDFHost);
};
} // namespace pdf
#endif // COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_

View file

@ -240,6 +240,8 @@ filenames = {
"atom/browser/browser_mac.mm", "atom/browser/browser_mac.mm",
"atom/browser/browser_win.cc", "atom/browser/browser_win.cc",
"atom/browser/browser_observer.h", "atom/browser/browser_observer.h",
"atom/browser/browser_process_impl.cc",
"atom/browser/browser_process_impl.h",
"atom/browser/child_web_contents_tracker.h", "atom/browser/child_web_contents_tracker.h",
"atom/browser/common_web_contents_delegate_mac.mm", "atom/browser/common_web_contents_delegate_mac.mm",
"atom/browser/common_web_contents_delegate_views.cc", "atom/browser/common_web_contents_delegate_views.cc",
@ -654,10 +656,6 @@ filenames = {
"atom/renderer/web_worker_observer.h", "atom/renderer/web_worker_observer.h",
"atom/utility/atom_content_utility_client.cc", "atom/utility/atom_content_utility_client.cc",
"atom/utility/atom_content_utility_client.h", "atom/utility/atom_content_utility_client.h",
"chromium_src/chrome/browser/browser_process_impl.cc",
"chromium_src/chrome/browser/browser_process_impl.h",
"chromium_src/chrome/browser/chrome_process_finder_win.cc",
"chromium_src/chrome/browser/chrome_process_finder_win.h",
"chromium_src/chrome/browser/process_singleton_posix.cc", "chromium_src/chrome/browser/process_singleton_posix.cc",
"chromium_src/chrome/browser/process_singleton_win.cc", "chromium_src/chrome/browser/process_singleton_win.cc",
"chromium_src/chrome/browser/process_singleton.h", "chromium_src/chrome/browser/process_singleton.h",

View file

@ -75,3 +75,4 @@ tts.patch
color_chooser.patch color_chooser.patch
printing.patch printing.patch
verbose_generate_breakpad_symbols.patch verbose_generate_breakpad_symbols.patch
chrome_process_finder.patch

View file

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Milan Burda <miburda@microsoft.com>
Date: Fri, 26 Oct 2018 20:45:49 +0200
Subject: chrome_process_finder.patch
Fix some problems when using app.makeSingleInstance on POSIX systems
* The original command line of new instances are passed instead
of the one modified by Chromium.
* The command line is passed as Array.
Reference: https://github.com/electron/electron/pull/3175
diff --git a/chrome/browser/win/chrome_process_finder.cc b/chrome/browser/win/chrome_process_finder.cc
index 4fdea2af27020303a66a747304c5ecce5cc698d5..598ba8171631dbcf7ad23bc4b5c74a750bbaa47c 100644
--- a/chrome/browser/win/chrome_process_finder.cc
+++ b/chrome/browser/win/chrome_process_finder.cc
@@ -43,15 +43,6 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window,
if (!thread_id || !process_id)
return NOTIFY_FAILED;
- base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
- command_line.AppendSwitchASCII(
- switches::kOriginalProcessStartTime,
- base::Int64ToString(
- base::CurrentProcessInfo::CreationTime().ToInternalValue()));
-
- if (fast_start)
- command_line.AppendSwitch(switches::kFastStart);
-
// Send the command line to the remote chrome window.
// Format is "START\0<<<current directory>>>\0<<<commandline>>>".
std::wstring to_send(L"START\0", 6); // want the NULL in the string.
@@ -60,7 +51,7 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window,
return NOTIFY_FAILED;
to_send.append(cur_dir.value());
to_send.append(L"\0", 1); // Null separator.
- to_send.append(command_line.GetCommandLineString());
+ to_send.append(::GetCommandLineW());
to_send.append(L"\0", 1); // Null separator.
// Allow the current running browser window to make itself the foreground

View file

@ -7,10 +7,10 @@ Backports https://chromium-review.googlesource.com/c/chromium/src/+/1161391
Fixes webview not working after renderer process restarted. Fixes webview not working after renderer process restarted.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 88211169a7d731cb805f34c48ae4caf2fdcd1c84..7b2715aea2afb9e939a6d5cf7fa7ec23f330194a 100644 index 64ad6ca91d9331a09d09f7e29b7c24a0c12852a2..ec3d1ccbad7e3e4184205f87b6b3fb7dcd4c07f2 100644
--- a/content/browser/web_contents/web_contents_impl.cc --- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4906,6 +4906,12 @@ void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, @@ -4886,6 +4886,12 @@ void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host,
view_->RenderViewHostChanged(old_host, new_host); view_->RenderViewHostChanged(old_host, new_host);