refactor: more cleanup of chromium_src (#15424)
This commit is contained in:
parent
c422011d58
commit
a19d20cfb8
13 changed files with 54 additions and 301 deletions
|
@ -40,6 +40,8 @@ static_library("chrome") {
|
|||
"//chrome/browser/net/proxy_service_factory.h",
|
||||
"//chrome/browser/ssl/security_state_tab_helper.cc",
|
||||
"//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.h",
|
||||
]
|
||||
|
|
|
@ -1,220 +0,0 @@
|
|||
// Copyright (c) 2012 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/browser_process_impl.h"
|
||||
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
BrowserProcessImpl::BrowserProcessImpl() : print_job_manager_(nullptr) {
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
print_job_manager_.reset(new printing::PrintJobManager());
|
||||
#endif
|
||||
g_browser_process = this;
|
||||
}
|
||||
|
||||
BrowserProcessImpl::~BrowserProcessImpl() {
|
||||
g_browser_process = nullptr;
|
||||
}
|
||||
|
||||
bool BrowserProcessImpl::IsShuttingDown() {
|
||||
return false;
|
||||
}
|
||||
|
||||
metrics_services_manager::MetricsServicesManager*
|
||||
BrowserProcessImpl::GetMetricsServicesManager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
metrics::MetricsService* BrowserProcessImpl::metrics_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rappor::RapporServiceImpl* BrowserProcessImpl::rappor_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ProfileManager* BrowserProcessImpl::profile_manager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PrefService* BrowserProcessImpl::local_state() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
BrowserProcessImpl::shared_url_loader_factory() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
variations::VariationsService* BrowserProcessImpl::variations_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BrowserProcessPlatformPart* BrowserProcessImpl::platform_part() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
extensions::EventRouterForwarder*
|
||||
BrowserProcessImpl::extension_event_router_forwarder() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NotificationPlatformBridge* BrowserProcessImpl::notification_platform_bridge() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IOThread* BrowserProcessImpl::io_thread() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SystemNetworkContextManager*
|
||||
BrowserProcessImpl::system_network_context_manager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
network::NetworkQualityTracker* BrowserProcessImpl::network_quality_tracker() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WatchDogThread* BrowserProcessImpl::watchdog_thread() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
policy::ChromeBrowserPolicyConnector*
|
||||
BrowserProcessImpl::browser_policy_connector() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
policy::PolicyService* BrowserProcessImpl::policy_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IconManager* BrowserProcessImpl::icon_manager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GpuModeManager* BrowserProcessImpl::gpu_mode_manager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
printing::PrintPreviewDialogController*
|
||||
BrowserProcessImpl::print_preview_dialog_controller() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
printing::BackgroundPrintingManager*
|
||||
BrowserProcessImpl::background_printing_manager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BackgroundModeManager* BrowserProcessImpl::background_mode_manager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
StatusTray* BrowserProcessImpl::status_tray() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
safe_browsing::SafeBrowsingService*
|
||||
BrowserProcessImpl::safe_browsing_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
safe_browsing::ClientSideDetectionService*
|
||||
BrowserProcessImpl::safe_browsing_detection_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
subresource_filter::ContentRulesetService*
|
||||
BrowserProcessImpl::subresource_filter_ruleset_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
optimization_guide::OptimizationGuideService*
|
||||
BrowserProcessImpl::optimization_guide_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
net_log::ChromeNetLog* BrowserProcessImpl::net_log() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
component_updater::ComponentUpdateService*
|
||||
BrowserProcessImpl::component_updater() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
component_updater::SupervisedUserWhitelistInstaller*
|
||||
BrowserProcessImpl::supervised_user_whitelist_installer() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MediaFileSystemRegistry* BrowserProcessImpl::media_file_system_registry() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WebRtcLogUploader* BrowserProcessImpl::webrtc_log_uploader() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
network_time::NetworkTimeTracker* BrowserProcessImpl::network_time_tracker() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gcm::GCMDriver* BrowserProcessImpl::gcm_driver() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
resource_coordinator::TabManager* BrowserProcessImpl::GetTabManager() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
shell_integration::DefaultWebClientState
|
||||
BrowserProcessImpl::CachedDefaultWebClientState() {
|
||||
return shell_integration::UNKNOWN_DEFAULT;
|
||||
}
|
||||
|
||||
prefs::InProcessPrefServiceFactory* BrowserProcessImpl::pref_service_factory()
|
||||
const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
content::NetworkConnectionTracker*
|
||||
BrowserProcessImpl::network_connection_tracker() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) {
|
||||
locale_ = locale;
|
||||
}
|
||||
|
||||
const std::string& BrowserProcessImpl::GetApplicationLocale() {
|
||||
return locale_;
|
||||
}
|
||||
|
||||
printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
|
||||
return print_job_manager_.get();
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
// Copyright (c) 2012 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.
|
||||
|
||||
// This interface is for managing the global services of the application. Each
|
||||
// service is lazily created when requested the first time. The service getters
|
||||
// will return NULL if the service is not available, so callers must check for
|
||||
// this condition.
|
||||
|
||||
#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
|
||||
#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
||||
|
||||
namespace printing {
|
||||
class PrintJobManager;
|
||||
}
|
||||
|
||||
// Empty definition for std::unique_ptr
|
||||
class BackgroundModeManager {};
|
||||
|
||||
// NOT THREAD SAFE, call only from the main thread.
|
||||
// These functions shouldn't return NULL unless otherwise noted.
|
||||
class BrowserProcessImpl : public BrowserProcess {
|
||||
public:
|
||||
BrowserProcessImpl();
|
||||
~BrowserProcessImpl() override;
|
||||
|
||||
void ResourceDispatcherHostCreated() override {}
|
||||
void EndSession() override {}
|
||||
void FlushLocalStateAndReply(base::OnceClosure reply) override {}
|
||||
bool IsShuttingDown() override;
|
||||
|
||||
metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
|
||||
override;
|
||||
metrics::MetricsService* metrics_service() override;
|
||||
rappor::RapporServiceImpl* rappor_service() override;
|
||||
ProfileManager* profile_manager() override;
|
||||
PrefService* local_state() override;
|
||||
net::URLRequestContextGetter* system_request_context() override;
|
||||
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory()
|
||||
override;
|
||||
variations::VariationsService* variations_service() override;
|
||||
BrowserProcessPlatformPart* platform_part() override;
|
||||
extensions::EventRouterForwarder* extension_event_router_forwarder() override;
|
||||
NotificationUIManager* notification_ui_manager() override;
|
||||
NotificationPlatformBridge* notification_platform_bridge() override;
|
||||
IOThread* io_thread() override;
|
||||
SystemNetworkContextManager* system_network_context_manager() override;
|
||||
network::NetworkQualityTracker* network_quality_tracker() override;
|
||||
WatchDogThread* watchdog_thread() override;
|
||||
policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
|
||||
policy::PolicyService* policy_service() override;
|
||||
IconManager* icon_manager() override;
|
||||
GpuModeManager* gpu_mode_manager() override;
|
||||
printing::PrintPreviewDialogController* print_preview_dialog_controller()
|
||||
override;
|
||||
printing::BackgroundPrintingManager* background_printing_manager() override;
|
||||
IntranetRedirectDetector* intranet_redirect_detector() override;
|
||||
DownloadStatusUpdater* download_status_updater() override;
|
||||
DownloadRequestLimiter* download_request_limiter() override;
|
||||
BackgroundModeManager* background_mode_manager() override;
|
||||
StatusTray* status_tray() override;
|
||||
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
|
||||
safe_browsing::ClientSideDetectionService* safe_browsing_detection_service()
|
||||
override;
|
||||
subresource_filter::ContentRulesetService*
|
||||
subresource_filter_ruleset_service() override;
|
||||
optimization_guide::OptimizationGuideService* optimization_guide_service()
|
||||
override;
|
||||
net_log::ChromeNetLog* net_log() override;
|
||||
component_updater::ComponentUpdateService* component_updater() override;
|
||||
component_updater::SupervisedUserWhitelistInstaller*
|
||||
supervised_user_whitelist_installer() override;
|
||||
MediaFileSystemRegistry* media_file_system_registry() override;
|
||||
WebRtcLogUploader* webrtc_log_uploader() override;
|
||||
network_time::NetworkTimeTracker* network_time_tracker() override;
|
||||
gcm::GCMDriver* gcm_driver() override;
|
||||
resource_coordinator::TabManager* GetTabManager() override;
|
||||
shell_integration::DefaultWebClientState CachedDefaultWebClientState()
|
||||
override;
|
||||
prefs::InProcessPrefServiceFactory* pref_service_factory() const override;
|
||||
content::NetworkConnectionTracker* network_connection_tracker() override;
|
||||
void CreateDevToolsProtocolHandler() override {}
|
||||
void CreateDevToolsAutoOpener() override {}
|
||||
void set_background_mode_manager_for_test(
|
||||
std::unique_ptr<BackgroundModeManager> manager) override {}
|
||||
#if (defined(OS_WIN) || defined(OS_LINUX))
|
||||
void StartAutoupdateTimer() override {}
|
||||
#endif
|
||||
void SetApplicationLocale(const std::string& locale) override;
|
||||
const std::string& GetApplicationLocale() override;
|
||||
printing::PrintJobManager* print_job_manager() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
|
||||
std::string locale_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
|
||||
};
|
||||
|
||||
#endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
|
|
@ -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
|
|
@ -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_
|
|
@ -20,7 +20,7 @@
|
|||
#include "base/win/registry.h"
|
||||
#include "base/win/scoped_handle.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 "net/base/escape.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
|
|
@ -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
|
|
@ -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_
|
Loading…
Add table
Add a link
Reference in a new issue