Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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_BROWSER_AUTOMATION_AUTOMATION_EVENT_OBSERVER_H_ | |
| 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_OBSERVER_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/values.h" | |
| 10 #include "chrome/browser/automation/automation_provider_observers.h" | |
| 11 #include "chrome/browser/automation/automation_event_queue.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 | |
| 15 // AutomationEventObserver watches for a specific event, and pushes an | |
| 16 // AutomationEvent into the AutomationEventQueue for each occurance. | |
| 17 class AutomationEventObserver { | |
| 18 public: | |
| 19 explicit AutomationEventObserver(AutomationEventQueue& event_queue); | |
| 20 virtual ~AutomationEventObserver(); | |
| 21 | |
| 22 void Init(int observer_id); | |
| 23 void NotifyEvent(DictionaryValue* value); | |
| 24 int GetId() const; | |
| 25 | |
| 26 private: | |
| 27 AutomationEventQueue& event_queue_; | |
| 28 int observer_id_; | |
| 29 | |
| 30 DISALLOW_COPY_AND_ASSIGN(AutomationEventObserver); | |
| 31 }; | |
| 32 | |
| 33 // AutomationEventObserver implementation that listens for explicitly raised | |
| 34 // events. A webpage currently raises events by calling: | |
| 35 // window.domAutomationController.setAutomationId(42); // Any integer works. | |
| 36 // window.domAutomationController("EVENT_NAME"); | |
| 37 // TODO(craigdh): This method is a temporary hack. | |
| 38 class RaisedEventObserver | |
|
Nirnimesh
2012/02/24 23:18:09
Add 'Dom'
craigdh
2012/02/27 22:43:38
Done.
| |
| 39 : public AutomationEventObserver, public DomOperationObserver { | |
| 40 public: | |
| 41 RaisedEventObserver(AutomationEventQueue& event_queue, | |
| 42 std::string& event_name); | |
| 43 virtual ~RaisedEventObserver(); | |
| 44 | |
| 45 virtual void OnDomOperationCompleted(const std::string& json) OVERRIDE; | |
| 46 virtual void OnModalDialogShown() OVERRIDE; | |
| 47 virtual void OnJavascriptBlocked() OVERRIDE; | |
| 48 | |
| 49 private: | |
| 50 std::string event_name_; | |
| 51 content::NotificationRegistrar registrar_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(RaisedEventObserver); | |
| 54 }; | |
| 55 | |
| 56 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_OBSERVER_H_ | |
| OLD | NEW |