equal
deleted
inserted
replaced
|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.sdk.internal; |
|
6 |
|
7 import java.util.HashMap; |
|
8 import java.util.Map; |
|
9 |
|
10 import org.chromium.sdk.internal.transport.Message; |
|
11 import org.chromium.sdk.internal.transport.Message.Header; |
|
12 |
|
13 /** |
|
14 * A facility that creates transport {@link Message}s for sending requests to |
|
15 * Chromium using the available ChromeDevTools Protocol commands. |
|
16 */ |
|
17 public class MessageFactory { |
|
18 public static Message createMessage(String tool, String destination, String content) { |
|
19 Map<String, String> headers = new HashMap<String, String>(); |
|
20 if (tool != null) { |
|
21 headers.put(Header.TOOL.name, tool); |
|
22 } |
|
23 if (destination != null) { |
|
24 headers.put(Header.DESTINATION.name, destination); |
|
25 } |
|
26 return new Message(headers, content); |
|
27 } |
|
28 |
|
29 private MessageFactory() { |
|
30 // not instantiable |
|
31 } |
|
32 } |