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/extensions/event_router.h" | 8 #include "chrome/browser/extensions/event_router.h" |
9 #include "chrome/browser/guestview/guestview_constants.h" | 9 #include "chrome/browser/guestview/guestview_constants.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // static | 60 // static |
61 GuestView* GuestView::From(int embedder_process_id, int guest_instance_id) { | 61 GuestView* GuestView::From(int embedder_process_id, int guest_instance_id) { |
62 EmbedderGuestViewMap* guest_map = embedder_guestview_map.Pointer(); | 62 EmbedderGuestViewMap* guest_map = embedder_guestview_map.Pointer(); |
63 EmbedderGuestViewMap::iterator it = guest_map->find( | 63 EmbedderGuestViewMap::iterator it = guest_map->find( |
64 std::make_pair(embedder_process_id, guest_instance_id)); | 64 std::make_pair(embedder_process_id, guest_instance_id)); |
65 return it == guest_map->end() ? NULL : it->second; | 65 return it == guest_map->end() ? NULL : it->second; |
66 } | 66 } |
67 | 67 |
68 void GuestView::Attach(content::WebContents* embedder_web_contents, | 68 void GuestView::Attach(content::WebContents* embedder_web_contents, |
69 const std::string& extension_id, | 69 const std::string& extension_id, |
70 int view_instance_id, | |
71 const base::DictionaryValue& args) { | 70 const base::DictionaryValue& args) { |
72 embedder_web_contents_ = embedder_web_contents; | 71 embedder_web_contents_ = embedder_web_contents; |
73 embedder_render_process_id_ = | 72 embedder_render_process_id_ = |
74 embedder_web_contents->GetRenderProcessHost()->GetID(); | 73 embedder_web_contents->GetRenderProcessHost()->GetID(); |
75 extension_id_ = extension_id; | 74 extension_id_ = extension_id; |
76 view_instance_id_ = view_instance_id; | 75 args.GetInteger(guestview::kParameterInstanceId, &view_instance_id_); |
77 | 76 |
78 std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_); | 77 std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_); |
79 embedder_guestview_map.Get().insert(std::make_pair(key, this)); | 78 embedder_guestview_map.Get().insert(std::make_pair(key, this)); |
80 | 79 |
81 // GuestView::Attach is called prior to initialization (and initial | 80 // GuestView::Attach is called prior to initialization (and initial |
82 // navigation) of the guest in the content layer in order to permit mapping | 81 // navigation) of the guest in the content layer in order to permit mapping |
83 // the necessary associations between the <*view> element and its guest. This | 82 // the necessary associations between the <*view> element and its guest. This |
84 // is needed by the <webview> WebRequest API to allow intercepting resource | 83 // is needed by the <webview> WebRequest API to allow intercepting resource |
85 // requests during navigation. However, queued events should be fired after | 84 // requests during navigation. However, queued events should be fired after |
86 // content layer initialization in order to ensure that load events (such as | 85 // content layer initialization in order to ensure that load events (such as |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void GuestView::SendQueuedEvents() { | 139 void GuestView::SendQueuedEvents() { |
141 if (!attached()) | 140 if (!attached()) |
142 return; | 141 return; |
143 | 142 |
144 while (!pending_events_.empty()) { | 143 while (!pending_events_.empty()) { |
145 Event* event = pending_events_.front(); | 144 Event* event = pending_events_.front(); |
146 pending_events_.pop(); | 145 pending_events_.pop(); |
147 DispatchEvent(event); | 146 DispatchEvent(event); |
148 } | 147 } |
149 } | 148 } |
OLD | NEW |