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

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: Addressed Dennis' 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.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..f50620815fb169447fbea752f28b334de30873e0
--- /dev/null
+++ b/chrome/browser/automation/automation_event_observer.cc
@@ -0,0 +1,61 @@
+// 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"
+
+#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) {
+ event_queue_.AddObserver(this);
+}
+
+AutomationEventObserver::~AutomationEventObserver() {}
+
+void AutomationEventObserver::NotifyEvent(DictionaryValue* value) {
+ 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_;
+}
+
+RaisedEventObserver::RaisedEventObserver(AutomationEventQueue& event_queue,
+ std::string& event_name)
+ : AutomationEventObserver(event_queue), event_name_(event_name) {}
+
+RaisedEventObserver::~RaisedEventObserver() {}
+
+void RaisedEventObserver::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 RaisedEventObserver::OnModalDialogShown() {
+ DictionaryValue* dict = new DictionaryValue;
+ dict->SetString("error", "Blocked by modal dialogue");
+ NotifyEvent(dict);
+}
+
+void RaisedEventObserver::OnJavascriptBlocked() {
Nirnimesh 2012/02/24 23:18:09 Add a test for one of the failure scenarios. Maybe
craigdh 2012/02/27 22:43:38 I'll add the suggested failure test to my upcoming
+ DictionaryValue* dict = new DictionaryValue;
+ dict->SetString("error", "Javascript execution was blocked");
+ NotifyEvent(dict);
+}

Powered by Google App Engine
This is Rietveld 408576698