Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/guestview/guestview.cc

Issue 237533008: Refactor GuestView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 base::MessageLoop::current()->PostTask( 161 base::MessageLoop::current()->PostTask(
162 FROM_HERE, 162 FROM_HERE,
163 base::Bind(&GuestView::SendQueuedEvents, 163 base::Bind(&GuestView::SendQueuedEvents,
164 weak_ptr_factory_.GetWeakPtr())); 164 weak_ptr_factory_.GetWeakPtr()));
165 } 165 }
166 166
167 GuestView::Type GuestView::GetViewType() const { 167 GuestView::Type GuestView::GetViewType() const {
168 return GuestView::UNKNOWN; 168 return GuestView::UNKNOWN;
169 } 169 }
170 170
171 WebViewGuest* GuestView::AsWebView() {
172 return NULL;
173 }
174
175 AdViewGuest* GuestView::AsAdView() {
176 return NULL;
177 }
178
179 GuestView::~GuestView() { 171 GuestView::~GuestView() {
180 std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_); 172 std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_);
181 embedder_guestview_map.Get().erase(key); 173 embedder_guestview_map.Get().erase(key);
182 174
183 webcontents_guestview_map.Get().erase(guest_web_contents()); 175 webcontents_guestview_map.Get().erase(guest_web_contents());
184 176
185 while (!pending_events_.empty()) { 177 while (!pending_events_.empty()) {
186 delete pending_events_.front(); 178 delete pending_events_.front();
187 pending_events_.pop(); 179 pending_events_.pop();
188 } 180 }
189 } 181 }
190 182
191 void GuestView::DispatchEvent(Event* event) { 183 void GuestView::DispatchEvent(Event* event) {
192 if (!in_extension()) 184 if (!in_extension()) {
193 return; 185 delete event;
186 return;
187 }
194 188
195 if (!attached()) { 189 if (!attached()) {
196 pending_events_.push(event); 190 pending_events_.push(event);
197 return; 191 return;
198 } 192 }
199 193
200 Profile* profile = Profile::FromBrowserContext(browser_context_); 194 Profile* profile = Profile::FromBrowserContext(browser_context_);
201 195
202 extensions::EventFilteringInfo info; 196 extensions::EventFilteringInfo info;
203 info.SetURL(GURL()); 197 info.SetURL(GURL());
(...skipping 12 matching lines...) Expand all
216 void GuestView::SendQueuedEvents() { 210 void GuestView::SendQueuedEvents() {
217 if (!attached()) 211 if (!attached())
218 return; 212 return;
219 213
220 while (!pending_events_.empty()) { 214 while (!pending_events_.empty()) {
221 Event* event = pending_events_.front(); 215 Event* event = pending_events_.front();
222 pending_events_.pop(); 216 pending_events_.pop();
223 DispatchEvent(event); 217 DispatchEvent(event);
224 } 218 }
225 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698