Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4860)

Unified Diff: chrome/browser/automation/automation_event_observer.h

Issue 9372120: Implementation of AutomationEventQueue and associated framework to support generic non-blocking aut… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Nirnimesh's second round of comments. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/automation_event_observer.h
diff --git a/chrome/browser/automation/automation_event_observer.h b/chrome/browser/automation/automation_event_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..e1ad721c4deb6afe8abc0bcd6d5281750a5f4257
--- /dev/null
+++ b/chrome/browser/automation/automation_event_observer.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 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_BROWSER_AUTOMATION_AUTOMATION_EVENT_OBSERVER_H_
+#define CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_OBSERVER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "chrome/browser/automation/automation_provider_observers.h"
+#include "chrome/browser/automation/automation_event_queue.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+// AutomationEventObserver watches for a specific event, and pushes an
+// AutomationEvent into the AutomationEventQueue for each occurance.
+class AutomationEventObserver {
+ public:
+ explicit AutomationEventObserver(AutomationEventQueue& event_queue);
frankf 2012/02/29 02:29:00 All reference parameters should be const. If the f
+ virtual ~AutomationEventObserver();
+
+ void Init(int observer_id);
+ void NotifyEvent(DictionaryValue* value);
+ int GetId() const;
+
+ private:
+ AutomationEventQueue& event_queue_;
+ int observer_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutomationEventObserver);
+};
+
+// AutomationEventObserver implementation that listens for explicitly raised
+// events. A webpage currently raises events by calling:
+// window.domAutomationController.setAutomationId(42); // Any integer works.
+// window.domAutomationController("EVENT_NAME");
+// TODO(craigdh): This method is a temporary hack.
+class DomRaisedEventObserver
+ : public AutomationEventObserver, public DomOperationObserver {
+ public:
+ DomRaisedEventObserver(AutomationEventQueue& event_queue,
frankf 2012/02/29 02:29:00 Same here.
+ std::string& event_name);
frankf 2012/02/29 02:29:00 alignment.
+ virtual ~DomRaisedEventObserver();
+
+ virtual void OnDomOperationCompleted(const std::string& json) OVERRIDE;
+ virtual void OnModalDialogShown() OVERRIDE;
+ virtual void OnJavascriptBlocked() OVERRIDE;
+
+ private:
+ std::string event_name_;
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(DomRaisedEventObserver);
+};
+
+#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698