forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ServiceIPCServer::MessageHandler in CloudPrintMessageHandler.
* Moves cloud print IPC message handling from ServiceIPCServer to CloudPrintMessageHandler * Removes the last 4 uses of g_service_process from ServiceIPCServer. * Add unit test for ServiceIPCServer BUG=402456 Review URL: https://codereview.chromium.org/1249513003 Cr-Commit-Position: refs/heads/master@{#340664}
- Loading branch information
Showing
11 changed files
with
434 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2015 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/service/cloud_print/cloud_print_message_handler.h" | ||
|
||
#include <vector> | ||
|
||
#include "chrome/common/service_messages.h" | ||
#include "ipc/ipc_sender.h" | ||
|
||
namespace cloud_print { | ||
|
||
CloudPrintMessageHandler::CloudPrintMessageHandler( | ||
IPC::Sender* ipc_sender, | ||
CloudPrintProxy::Provider* proxy_provider) | ||
: ipc_sender_(ipc_sender), proxy_provider_(proxy_provider) { | ||
DCHECK(ipc_sender); | ||
DCHECK(proxy_provider); | ||
} | ||
|
||
CloudPrintMessageHandler::~CloudPrintMessageHandler() { | ||
} | ||
|
||
bool CloudPrintMessageHandler::HandleMessage(const IPC::Message& message) { | ||
bool handled = true; | ||
IPC_BEGIN_MESSAGE_MAP(CloudPrintMessageHandler, message) | ||
IPC_MESSAGE_HANDLER(ServiceMsg_EnableCloudPrintProxyWithRobot, | ||
OnEnableCloudPrintProxyWithRobot) | ||
IPC_MESSAGE_HANDLER(ServiceMsg_DisableCloudPrintProxy, | ||
OnDisableCloudPrintProxy) | ||
IPC_MESSAGE_HANDLER(ServiceMsg_GetCloudPrintProxyInfo, | ||
OnGetCloudPrintProxyInfo) | ||
IPC_MESSAGE_HANDLER(ServiceMsg_GetPrinters, OnGetPrinters) | ||
IPC_MESSAGE_UNHANDLED(handled = false) | ||
IPC_END_MESSAGE_MAP() | ||
return handled; | ||
} | ||
|
||
void CloudPrintMessageHandler::OnEnableCloudPrintProxyWithRobot( | ||
const std::string& robot_auth_code, | ||
const std::string& robot_email, | ||
const std::string& user_email, | ||
const base::DictionaryValue& user_settings) { | ||
proxy_provider_->GetCloudPrintProxy()->EnableForUserWithRobot( | ||
robot_auth_code, robot_email, user_email, user_settings); | ||
} | ||
|
||
void CloudPrintMessageHandler::OnGetCloudPrintProxyInfo() { | ||
CloudPrintProxyInfo info; | ||
proxy_provider_->GetCloudPrintProxy()->GetProxyInfo(&info); | ||
ipc_sender_->Send(new ServiceHostMsg_CloudPrintProxy_Info(info)); | ||
} | ||
|
||
void CloudPrintMessageHandler::OnGetPrinters() { | ||
std::vector<std::string> printers; | ||
proxy_provider_->GetCloudPrintProxy()->GetPrinters(&printers); | ||
ipc_sender_->Send(new ServiceHostMsg_Printers(printers)); | ||
} | ||
|
||
void CloudPrintMessageHandler::OnDisableCloudPrintProxy() { | ||
proxy_provider_->GetCloudPrintProxy()->UnregisterPrintersAndDisableForUser(); | ||
} | ||
|
||
} // namespace cloud_print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2015 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_SERVICE_CLOUD_PRINT_CLOUD_PRINT_MESSAGE_HANDLER_H_ | ||
#define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_MESSAGE_HANDLER_H_ | ||
|
||
#include <string> | ||
|
||
#include "base/macros.h" | ||
#include "chrome/service/cloud_print/cloud_print_proxy.h" | ||
#include "chrome/service/service_ipc_server.h" | ||
|
||
namespace base { | ||
class DictionaryValue; | ||
} | ||
|
||
namespace IPC { | ||
class Message; | ||
class Sender; | ||
} | ||
|
||
namespace cloud_print { | ||
|
||
// Handles IPC messages for Cloud Print. Lives on the main thread. | ||
class CloudPrintMessageHandler : public ServiceIPCServer::MessageHandler { | ||
public: | ||
CloudPrintMessageHandler(IPC::Sender* ipc_sender, | ||
CloudPrintProxy::Provider* proxy_provider); | ||
~CloudPrintMessageHandler() override; | ||
|
||
// ServiceIPCServer::MessageHandler implementation. | ||
bool HandleMessage(const IPC::Message& message) override; | ||
|
||
private: | ||
// IPC message handlers. | ||
void OnEnableCloudPrintProxyWithRobot( | ||
const std::string& robot_auth_code, | ||
const std::string& robot_email, | ||
const std::string& user_email, | ||
const base::DictionaryValue& user_settings); | ||
void OnGetCloudPrintProxyInfo(); | ||
void OnGetPrinters(); | ||
void OnDisableCloudPrintProxy(); | ||
|
||
IPC::Sender* ipc_sender_; // Owned by our owner. | ||
CloudPrintProxy::Provider* proxy_provider_; // Owned by our owner. | ||
|
||
DISALLOW_COPY_AND_ASSIGN(CloudPrintMessageHandler); | ||
}; | ||
|
||
} // namespace cloud_print | ||
|
||
#endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_MESSAGE_HANDLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.