Update Windows printing code to latest
This commit is contained in:
parent
d483352f78
commit
1ed8743da8
9 changed files with 133 additions and 144 deletions
|
@ -4,38 +4,13 @@
|
|||
|
||||
#include "atom/utility/atom_content_utility_client.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/time/time.h"
|
||||
#include "chrome/common/chrome_utility_messages.h"
|
||||
#include "chrome/utility/utility_message_handler.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/utility/utility_thread.h"
|
||||
#include "ipc/ipc_channel.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "chrome/utility/printing_handler_win.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
bool Send(IPC::Message* message) {
|
||||
return content::UtilityThread::Get()->Send(message);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace atom {
|
||||
|
||||
int64_t AtomContentUtilityClient::max_ipc_message_size_ =
|
||||
IPC::Channel::kMaximumMessageSize;
|
||||
|
||||
AtomContentUtilityClient::AtomContentUtilityClient()
|
||||
: filter_messages_(false) {
|
||||
AtomContentUtilityClient::AtomContentUtilityClient() {
|
||||
#if defined(OS_WIN)
|
||||
handlers_.push_back(new printing::PrintingHandlerWin());
|
||||
#endif
|
||||
|
@ -44,31 +19,4 @@ AtomContentUtilityClient::AtomContentUtilityClient()
|
|||
AtomContentUtilityClient::~AtomContentUtilityClient() {
|
||||
}
|
||||
|
||||
void AtomContentUtilityClient::UtilityThreadStarted() {
|
||||
}
|
||||
|
||||
bool AtomContentUtilityClient::OnMessageReceived(
|
||||
const IPC::Message& message) {
|
||||
if (filter_messages_ &&
|
||||
!base::ContainsKey(message_id_whitelist_, message.type()))
|
||||
return false;
|
||||
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(AtomContentUtilityClient, message)
|
||||
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
for (auto it = handlers_.begin(); !handled && it != handlers_.end(); ++it) {
|
||||
handled = (*it)->OnMessageReceived(message);
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
void AtomContentUtilityClient::OnStartupPing() {
|
||||
Send(new ChromeUtilityHostMsg_ProcessStarted);
|
||||
// Don't release the process, we assume further messages are on the way.
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -5,19 +5,11 @@
|
|||
#ifndef ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
|
||||
#define ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_vector.h"
|
||||
#include "content/public/utility/content_utility_client.h"
|
||||
#include "ipc/ipc_platform_file.h"
|
||||
|
||||
namespace base {
|
||||
class FilePath;
|
||||
struct FileDescriptor;
|
||||
}
|
||||
|
||||
class UtilityMessageHandler;
|
||||
|
||||
|
@ -28,26 +20,10 @@ class AtomContentUtilityClient : public content::ContentUtilityClient {
|
|||
AtomContentUtilityClient();
|
||||
~AtomContentUtilityClient() override;
|
||||
|
||||
void UtilityThreadStarted() override;
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
|
||||
static void set_max_ipc_message_size_for_test(int64_t max_message_size) {
|
||||
max_ipc_message_size_ = max_message_size;
|
||||
}
|
||||
|
||||
private:
|
||||
void OnStartupPing();
|
||||
|
||||
typedef ScopedVector<UtilityMessageHandler> Handlers;
|
||||
Handlers handlers_;
|
||||
|
||||
// Flag to enable whitelisting.
|
||||
bool filter_messages_;
|
||||
// A list of message_ids to filter.
|
||||
std::set<int> message_id_whitelist_;
|
||||
// Maximum IPC msg size (default to kMaximumMessageSize; override for testing)
|
||||
static int64_t max_ipc_message_size_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomContentUtilityClient);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue