Removing flow to demote App Launcher to App Host, so app_host.exe can be deleted...
[chromium-blink-merge.git] / chrome / common / automation_id.h
blobb05f060fa98b9c09012d6d79482f97ff558bb7d2
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.
5 #ifndef CHROME_COMMON_AUTOMATION_ID_H_
6 #define CHROME_COMMON_AUTOMATION_ID_H_
8 #include <string>
10 namespace base {
11 class DictionaryValue;
12 class Value;
15 // A unique ID that JSON automation clients can use to refer to browser
16 // entities. The ID has a type so that:
17 // 1) supplying an ID of the wrong type can be detected.
18 // 2) the client does not have to explicitly supply the type in case multiple
19 // ID types can be accepted (e.g., can use a tab ID or extension popup ID for
20 // executing javascript).
21 class AutomationId {
22 public:
23 // The value of each entry should be preserved.
24 enum Type {
25 kTypeInvalid = 0,
26 kTypeTab,
27 kTypeExtensionPopup,
28 kTypeExtensionBgPage,
29 kTypeExtensionInfobar,
30 kTypeExtension,
31 kTypeAppShell,
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);
40 // Constructs an invalid ID.
41 AutomationId();
43 // Constructs an ID from the given type and type-specific ID.
44 AutomationId(Type type, const std::string& id);
46 bool operator==(const AutomationId& id) const;
48 // Returns a new dictionary equivalent to this ID.
49 base::DictionaryValue* ToValue() const;
51 // Returns whether the automation ID is valid.
52 bool is_valid() const;
54 Type type() const;
55 const std::string& id() const;
57 private:
58 Type type_;
59 std::string id_;
62 #endif // CHROME_COMMON_AUTOMATION_ID_H_