• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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_TEST_CHROMEDRIVER_CHROME_DOM_TRACKER_H_
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_DOM_TRACKER_H_
7 
8 #include <map>
9 #include <string>
10 
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h"
14 
15 namespace base {
16 class DictionaryValue;
17 class Value;
18 }
19 
20 class DevToolsClient;
21 class Status;
22 
23 // Tracks the state of the DOM and execution context creation.
24 class DomTracker : public DevToolsEventListener {
25  public:
26   explicit DomTracker(DevToolsClient* client);
27   virtual ~DomTracker();
28 
29   Status GetFrameIdForNode(int node_id, std::string* frame_id);
30 
31   // Overridden from DevToolsEventListener:
32   virtual Status OnConnected(DevToolsClient* client) OVERRIDE;
33   virtual Status OnEvent(DevToolsClient* client,
34                          const std::string& method,
35                          const base::DictionaryValue& params) OVERRIDE;
36 
37  private:
38   bool ProcessNodeList(const base::Value* nodes);
39   bool ProcessNode(const base::Value* node);
40 
41   std::map<int, std::string> node_to_frame_map_;
42 
43   DISALLOW_COPY_AND_ASSIGN(DomTracker);
44 };
45 
46 #endif  // CHROME_TEST_CHROMEDRIVER_CHROME_DOM_TRACKER_H_
47