Chromium Code Reviews| Index: chrome/common/automation_id.h |
| diff --git a/chrome/common/automation_id.h b/chrome/common/automation_id.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e4f89e78c977f6097e9f7b1e3bd3565ac0629cd6 |
| --- /dev/null |
| +++ b/chrome/common/automation_id.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright (c) 2011 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_COMMON_AUTOMATION_ID_H_ |
| +#define CHROME_COMMON_AUTOMATION_ID_H_ |
| +#pragma once |
| + |
| +#include <string> |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +class Value; |
| +} |
| + |
| +// A unique ID that JSON automation clients can use to refer to browser |
| +// entities. The ID has a type so that: |
| +// 1) supplying an ID of the wrong type can be detected |
|
dennis_jeffrey
2011/12/03 00:58:59
add period at end of sentence
|
| +// 2) the client does not have to explicitly supply the type in case multiple |
| +// ID types can be accepted (e.g., can use a tab ID or extension popup ID for |
| +// executing javascript). |
| +class AutomationId { |
| + public: |
| + // The value of each entry should be preserved. |
| + enum Type { |
| + kTypeInvalid = 0, |
| + kTypeTab, |
| + kTypeExtensionPopup, |
| + kTypeExtensionBgPage, |
| + kTypeExtensionInfobar, |
| + kTypeExtension, |
| + }; |
| + |
| + static bool FromValue( |
| + base::Value* value, AutomationId* id, std::string* error); |
| + static bool FromValueInDictionary( |
| + base::DictionaryValue* dict, const std::string& key, AutomationId* id, |
| + std::string* error); |
| + |
| + // Constructs a invalid ID. |
|
dennis_jeffrey
2011/12/03 00:58:59
'a invalid' --> 'an invalid'
|
| + AutomationId(); |
| + |
| + // Constructs an ID from the given type and type-specific ID. |
| + AutomationId(Type type, const std::string& id); |
| + |
| + bool operator==(const AutomationId& id) const; |
| + |
| + // Returns a new dictionary equivalent to this ID. |
| + base::DictionaryValue* ToValue() const; |
| + |
| + // Returns whether the automation ID is valid. |
| + bool is_valid() const; |
| + |
| + Type type() const; |
| + const std::string& id() const; |
| + |
| + private: |
| + Type type_; |
| + std::string id_; |
| +}; |
| + |
| +#endif // CHROME_COMMON_AUTOMATION_ID_H_ |