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