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 | |
17 AutomationEventObserver::~AutomationEventObserver() {} | |
18 | |
19 void AutomationEventObserver::NotifyEvent(DictionaryValue* value) { | |
20 event_queue_.NotifyEvent( | |
21 new AutomationEventQueue::AutomationEvent( | |
Nirnimesh
2012/02/29 03:22:08
who deletes this?
craigdh
2012/02/29 22:53:43
The AutomationEventQueue (when it handles the even
| |
22 GetId(), value)); | |
23 } | |
24 | |
25 void AutomationEventObserver::Init(int observer_id) { | |
26 if (observer_id_ < 0) { | |
27 observer_id_ = observer_id; | |
28 } | |
29 } | |
30 | |
31 int AutomationEventObserver::GetId() const { | |
32 return observer_id_; | |
33 } | |
34 | |
35 DomRaisedEventObserver::DomRaisedEventObserver( | |
36 AutomationEventQueue& event_queue, std::string& event_name) | |
37 : AutomationEventObserver(event_queue), event_name_(event_name) {} | |
38 | |
39 DomRaisedEventObserver::~DomRaisedEventObserver() {} | |
40 | |
41 void DomRaisedEventObserver::OnDomOperationCompleted(const std::string& json) { | |
42 DictionaryValue* dict = new DictionaryValue; | |
Nirnimesh
2012/02/29 03:22:08
where is this deleted? (and line 50, 56)
craigdh
2012/02/29 22:53:43
It is owned by the AutomationEvent (as a scoped_pt
| |
43 dict->SetString("type", "raised"); | |
44 dict->SetString("name", json); | |
45 dict->SetInteger("observer_id", GetId()); | |
46 NotifyEvent(dict); | |
47 } | |
48 | |
49 void DomRaisedEventObserver::OnModalDialogShown() { | |
50 DictionaryValue* dict = new DictionaryValue; | |
51 dict->SetString("error", "Blocked by modal dialogue"); | |
52 NotifyEvent(dict); | |
53 } | |
54 | |
55 void DomRaisedEventObserver::OnJavascriptBlocked() { | |
56 DictionaryValue* dict = new DictionaryValue; | |
57 dict->SetString("error", "Javascript execution was blocked"); | |
58 NotifyEvent(dict); | |
59 } | |
OLD | NEW |