Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 #ifndef CHROME_COMMON_AUTOMATION_ID_H_ | |
| 6 #define CHROME_COMMON_AUTOMATION_ID_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 namespace base { | |
| 12 class DictionaryValue; | |
| 13 class Value; | |
| 14 } | |
| 15 | |
| 16 // A unique ID that JSON automation clients can use to refer to browser | |
| 17 // entities. The ID has a type so that: | |
| 18 // 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
| |
| 19 // 2) the client does not have to explicitly supply the type in case multiple | |
| 20 // ID types can be accepted (e.g., can use a tab ID or extension popup ID for | |
| 21 // executing javascript). | |
| 22 class AutomationId { | |
| 23 public: | |
| 24 // The value of each entry should be preserved. | |
| 25 enum Type { | |
| 26 kTypeInvalid = 0, | |
| 27 kTypeTab, | |
| 28 kTypeExtensionPopup, | |
| 29 kTypeExtensionBgPage, | |
| 30 kTypeExtensionInfobar, | |
| 31 kTypeExtension, | |
| 32 }; | |
| 33 | |
| 34 static bool FromValue( | |
| 35 base::Value* value, AutomationId* id, std::string* error); | |
| 36 static bool FromValueInDictionary( | |
| 37 base::DictionaryValue* dict, const std::string& key, AutomationId* id, | |
| 38 std::string* error); | |
| 39 | |
| 40 // Constructs a invalid ID. | |
|
dennis_jeffrey
2011/12/03 00:58:59
'a invalid' --> 'an invalid'
| |
| 41 AutomationId(); | |
| 42 | |
| 43 // Constructs an ID from the given type and type-specific ID. | |
| 44 AutomationId(Type type, const std::string& id); | |
| 45 | |
| 46 bool operator==(const AutomationId& id) const; | |
| 47 | |
| 48 // Returns a new dictionary equivalent to this ID. | |
| 49 base::DictionaryValue* ToValue() const; | |
| 50 | |
| 51 // Returns whether the automation ID is valid. | |
| 52 bool is_valid() const; | |
| 53 | |
| 54 Type type() const; | |
| 55 const std::string& id() const; | |
| 56 | |
| 57 private: | |
| 58 Type type_; | |
| 59 std::string id_; | |
| 60 }; | |
| 61 | |
| 62 #endif // CHROME_COMMON_AUTOMATION_ID_H_ | |
| OLD | NEW |