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

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

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: Made CompareEventId predicate class private to AutomationEventQueue. 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.cc
diff --git a/chrome/browser/automation/automation_event_observer.cc b/chrome/browser/automation/automation_event_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6372548ee0742865c424466eb5b25c95e9ba19d9
--- /dev/null
+++ b/chrome/browser/automation/automation_event_observer.cc
@@ -0,0 +1,64 @@
+// 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.
+
+#include "chrome/browser/automation/automation_event_observer.h"
+#include "chrome/browser/automation/automation_event_queue.h"
+
Nirnimesh 2012/03/01 10:34:12 remove blank line
craigdh 2012/03/01 21:34:18 Done.
+#include "base/logging.h"
Nirnimesh 2012/03/01 10:34:12 should go before line 5
craigdh 2012/03/01 21:34:18 Done.
+#include "chrome/browser/automation/automation_provider.h"
+#include "chrome/browser/automation/automation_provider_json.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
+
+AutomationEventObserver::AutomationEventObserver(
+ AutomationEventQueue* event_queue)
+ : event_queue_(event_queue), observer_id_(-1) {
+ DCHECK(event_queue_ != NULL);
+}
+
+AutomationEventObserver::~AutomationEventObserver() {}
+
+void AutomationEventObserver::NotifyEvent(DictionaryValue* value) {
+ if (event_queue_) {
+ event_queue_->NotifyEvent(
+ new AutomationEventQueue::AutomationEvent(
+ GetId(), value));
+ }
+}
+
+void AutomationEventObserver::Init(int observer_id) {
+ if (observer_id_ < 0) {
+ observer_id_ = observer_id;
+ }
+}
+
+int AutomationEventObserver::GetId() const {
+ return observer_id_;
+}
+
+DomRaisedEventObserver::DomRaisedEventObserver(
+ AutomationEventQueue* event_queue, const std::string& event_name)
+ : AutomationEventObserver(event_queue), event_name_(event_name) {}
+
+DomRaisedEventObserver::~DomRaisedEventObserver() {}
+
+void DomRaisedEventObserver::OnDomOperationCompleted(const std::string& json) {
+ DictionaryValue* dict = new DictionaryValue;
+ dict->SetString("type", "raised");
+ dict->SetString("name", json);
+ dict->SetInteger("observer_id", GetId());
+ NotifyEvent(dict);
+}
+
+void DomRaisedEventObserver::OnModalDialogShown() {
+ DictionaryValue* dict = new DictionaryValue;
+ dict->SetString("error", "Blocked by modal dialogue");
+ NotifyEvent(dict);
+}
+
+void DomRaisedEventObserver::OnJavascriptBlocked() {
+ DictionaryValue* dict = new DictionaryValue;
+ dict->SetString("error", "Javascript execution was blocked");
+ NotifyEvent(dict);
+}

Powered by Google App Engine
This is Rietveld 408576698