Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_protocol.h
blob9b15b9e3ac445939199b0a9b02483bcd7e1cde8b
1 // Copyright (c) 2013 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.
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/values.h"
14 // Utility class for processing DevTools remote debugging messages.
15 // This is a stripped down clone of content::DevTools which is not accessible
16 // from chrome component (see content/browser/devtools/devtools_protocol.*).
17 class DevToolsProtocol {
18 public:
19 class Message {
20 public:
21 virtual ~Message();
23 std::string method() { return method_; }
24 base::DictionaryValue* params() { return params_.get(); }
26 protected:
27 // Takes ownership of |params|.
28 Message(const std::string& method, base::DictionaryValue* params);
30 std::string method_;
31 scoped_ptr<base::DictionaryValue> params_;
33 private:
34 DISALLOW_COPY_AND_ASSIGN(Message);
37 class Command : public Message {
38 public:
39 // Takes ownership of |params|.
40 Command(int id, const std::string& method, base::DictionaryValue* params);
41 virtual ~Command();
43 int id() { return id_; }
44 std::string Serialize();
46 private:
47 int id_;
49 DISALLOW_COPY_AND_ASSIGN(Command);
52 class Response {
53 public:
54 virtual ~Response();
56 int id() { return id_; }
57 int error_code() { return error_code_; }
59 private:
60 friend class DevToolsProtocol;
62 Response(int id, int error_code);
63 int id_;
64 int error_code_;
66 DISALLOW_COPY_AND_ASSIGN(Response);
69 class Notification : public Message {
70 public:
71 virtual ~Notification();
73 private:
74 friend class DevToolsProtocol;
76 // Takes ownership of |params|.
77 Notification(const std::string& method,
78 base::DictionaryValue* params);
80 DISALLOW_COPY_AND_ASSIGN(Notification);
83 // Result ownership is passed to the caller.
84 static Notification* ParseNotification(const std::string& json);
86 // Result ownership is passed to the caller.
87 static Response* ParseResponse(const std::string& json);
89 private:
91 DevToolsProtocol() {}
92 ~DevToolsProtocol() {}
95 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_