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 #include "chrome/browser/automation/automation_event_observer.h" | |
6 #include "chrome/browser/automation/automation_event_queue.h" | |
7 | |
8 #include "chrome/browser/automation/automation_provider.h" | |
9 #include "chrome/browser/automation/automation_provider_json.h" | |
10 #include "content/public/browser/notification_service.h" | |
11 #include "content/public/browser/notification_types.h" | |
12 | |
13 AutomationEventObserver::AutomationEventObserver( | |
14 AutomationEventQueue& event_queue) | |
15 : event_queue_(event_queue), observer_id_(-1) { | |
16 event_queue_.AddObserver(this); | |
17 } | |
18 | |
19 AutomationEventObserver::~AutomationEventObserver() {} | |
20 | |
21 void AutomationEventObserver::NotifyEvent(DictionaryValue* value) { | |
22 event_queue_.NotifyEvent( | |
23 new AutomationEventQueue::AutomationEvent( | |
24 GetId(), value)); | |
25 } | |
26 | |
27 void AutomationEventObserver::Init(int observer_id) { | |
28 if (observer_id_ < 0) { | |
29 observer_id_ = observer_id; | |
30 } | |
31 } | |
32 | |
33 int AutomationEventObserver::GetId() const { | |
34 return observer_id_; | |
35 } | |
36 | |
37 RaisedEventObserver::RaisedEventObserver(AutomationEventQueue& event_queue, | |
38 std::string& event_name) | |
39 : AutomationEventObserver(event_queue), event_name_(event_name) {} | |
40 | |
41 RaisedEventObserver::~RaisedEventObserver() {} | |
42 | |
43 void RaisedEventObserver::OnDomOperationCompleted(const std::string& json) { | |
44 DictionaryValue* dict = new DictionaryValue; | |
45 dict->SetString("type", "raised"); | |
46 dict->SetString("name", json); | |
47 dict->SetInteger("observer_id", GetId()); | |
48 NotifyEvent(dict); | |
49 } | |
50 | |
51 void RaisedEventObserver::OnModalDialogShown() { | |
52 DictionaryValue* dict = new DictionaryValue; | |
53 dict->SetString("error", "Blocked by modal dialogue"); | |
54 NotifyEvent(dict); | |
55 } | |
56 | |
57 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
| |
58 DictionaryValue* dict = new DictionaryValue; | |
59 dict->SetString("error", "Javascript execution was blocked"); | |
60 NotifyEvent(dict); | |
61 } | |
OLD | NEW |