summaryrefslogtreecommitdiffstats
path: root/chrome/common/automation_constants.cc
blob: 1b8d32de7eaae5ccc5dcec14ca0a134b8b65b51f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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/common/automation_constants.h"

namespace automation {

// JSON value labels for proxy settings that are passed in via
// AutomationMsg_SetProxyConfig.
const char kJSONProxyAutoconfig[] = "proxy.autoconfig";
const char kJSONProxyNoProxy[] = "proxy.no_proxy";
const char kJSONProxyPacUrl[] = "proxy.pac_url";
const char kJSONProxyPacMandatory[] = "proxy.pac_mandatory";
const char kJSONProxyBypassList[] = "proxy.bypass_list";
const char kJSONProxyServer[] = "proxy.server";

// Named testing interface is used when you want to connect an
// AutomationProxy to an already-running browser instance.
const char kNamedInterfacePrefix[] = "NamedTestingInterface:";

const int kChromeDriverAutomationVersion = 1;

namespace {

// Returns the string equivalent of the given |ErrorCode|.
const char* DefaultMessageForErrorCode(ErrorCode code) {
  switch (code) {
    case kUnknownError:
      return "Unknown error";
    case kNoJavaScriptModalDialogOpen:
      return "No JavaScript modal dialog is open";
    case kBlockedByModalDialog:
      return "Command blocked by an open modal dialog";
    case kInvalidId:
      return "ID is invalid or does not refer to an existing object";
    default:
      return "<unknown>";
  }
}

}  // namespace

Error::Error() : code_(kUnknownError) { }

Error::Error(ErrorCode code)
    : code_(code),
      message_(DefaultMessageForErrorCode(code)) { }

Error::Error(const std::string& error_msg)
    : code_(kUnknownError), message_(error_msg) { }

Error::Error(ErrorCode code, const std::string& error_msg)
    : code_(code), message_(error_msg) { }

Error::~Error() { }

ErrorCode Error::code() const {
  return code_;
}

const std::string& Error::message() const {
  return message_;
}

}  // namespace automation