OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/guestview/guestview.h" | 5 #include "chrome/browser/guestview/guestview.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "chrome/browser/guestview/adview/adview_guest.h" | 8 #include "chrome/browser/guestview/adview/adview_guest.h" |
9 #include "chrome/browser/guestview/guestview_constants.h" | 9 #include "chrome/browser/guestview/guestview_constants.h" |
10 #include "chrome/browser/guestview/webview/webview_guest.h" | 10 #include "chrome/browser/guestview/webview/webview_guest.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 static base::LazyInstance<EmbedderGuestViewMap> embedder_guestview_map = | 25 static base::LazyInstance<EmbedderGuestViewMap> embedder_guestview_map = |
26 LAZY_INSTANCE_INITIALIZER; | 26 LAZY_INSTANCE_INITIALIZER; |
27 | 27 |
28 typedef std::map<WebContents*, GuestView*> WebContentsGuestViewMap; | 28 typedef std::map<WebContents*, GuestView*> WebContentsGuestViewMap; |
29 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map = | 29 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map = |
30 LAZY_INSTANCE_INITIALIZER; | 30 LAZY_INSTANCE_INITIALIZER; |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 GuestView::Event::Event(const std::string& name, | 34 GuestView::Event::Event(const std::string& name, |
35 scoped_ptr<DictionaryValue> args) | 35 scoped_ptr<base::DictionaryValue> args) |
36 : name_(name), | 36 : name_(name), |
37 args_(args.Pass()) { | 37 args_(args.Pass()) { |
38 } | 38 } |
39 | 39 |
40 GuestView::Event::~Event() { | 40 GuestView::Event::~Event() { |
41 } | 41 } |
42 | 42 |
43 scoped_ptr<DictionaryValue> GuestView::Event::GetArguments() { | 43 scoped_ptr<base::DictionaryValue> GuestView::Event::GetArguments() { |
44 return args_.Pass(); | 44 return args_.Pass(); |
45 } | 45 } |
46 | 46 |
47 GuestView::GuestView(WebContents* guest_web_contents, | 47 GuestView::GuestView(WebContents* guest_web_contents, |
48 const std::string& extension_id) | 48 const std::string& extension_id) |
49 : guest_web_contents_(guest_web_contents), | 49 : guest_web_contents_(guest_web_contents), |
50 embedder_web_contents_(NULL), | 50 embedder_web_contents_(NULL), |
51 extension_id_(extension_id), | 51 extension_id_(extension_id), |
52 embedder_render_process_id_(0), | 52 embedder_render_process_id_(0), |
53 browser_context_(guest_web_contents->GetBrowserContext()), | 53 browser_context_(guest_web_contents->GetBrowserContext()), |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if (!attached()) { | 188 if (!attached()) { |
189 pending_events_.push(event); | 189 pending_events_.push(event); |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 Profile* profile = Profile::FromBrowserContext(browser_context_); | 193 Profile* profile = Profile::FromBrowserContext(browser_context_); |
194 | 194 |
195 extensions::EventFilteringInfo info; | 195 extensions::EventFilteringInfo info; |
196 info.SetURL(GURL()); | 196 info.SetURL(GURL()); |
197 info.SetInstanceID(guest_instance_id_); | 197 info.SetInstanceID(guest_instance_id_); |
198 scoped_ptr<ListValue> args(new ListValue()); | 198 scoped_ptr<base::ListValue> args(new base::ListValue()); |
199 args->Append(event->GetArguments().release()); | 199 args->Append(event->GetArguments().release()); |
200 | 200 |
201 extensions::EventRouter::DispatchEvent( | 201 extensions::EventRouter::DispatchEvent( |
202 embedder_web_contents_, profile, extension_id_, | 202 embedder_web_contents_, profile, extension_id_, |
203 event->name(), args.Pass(), | 203 event->name(), args.Pass(), |
204 extensions::EventRouter::USER_GESTURE_UNKNOWN, info); | 204 extensions::EventRouter::USER_GESTURE_UNKNOWN, info); |
205 | 205 |
206 delete event; | 206 delete event; |
207 } | 207 } |
208 | 208 |
209 void GuestView::SendQueuedEvents() { | 209 void GuestView::SendQueuedEvents() { |
210 if (!attached()) | 210 if (!attached()) |
211 return; | 211 return; |
212 | 212 |
213 while (!pending_events_.empty()) { | 213 while (!pending_events_.empty()) { |
214 Event* event = pending_events_.front(); | 214 Event* event = pending_events_.front(); |
215 pending_events_.pop(); | 215 pending_events_.pop(); |
216 DispatchEvent(event); | 216 DispatchEvent(event); |
217 } | 217 } |
218 } | 218 } |
OLD | NEW |