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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_GUESTVIEW_ADVIEW_ADVIEW_GUEST_H_ 6 #define CHROME_BROWSER_GUESTVIEW_ADVIEW_ADVIEW_GUEST_H_ 7 8 #include "base/values.h" 9 #include "chrome/browser/guestview/guestview.h" 10 #include "content/public/browser/web_contents_observer.h" 11 12 // An AdViewGuest is a WebContentsObserver on the guest WebContents of a 13 // <adview> tag. It provides the browser-side implementation of the <adview> 14 // API and manages the lifetime of <adview> extension events. AdViewGuest is 15 // created on attachment. When a guest WebContents is associated with 16 // a particular embedder WebContents, we call this "attachment". 17 // TODO(fsamuel): There might be an opportunity here to refactor and reuse code 18 // between AdViewGuest and WebViewGuest. 19 class AdViewGuest : public GuestView, 20 public content::WebContentsObserver { 21 public: 22 explicit AdViewGuest(content::WebContents* guest_web_contents); 23 24 static AdViewGuest* From(int embedder_process_id, int instance_id); 25 26 // GuestView implementation. 27 virtual GuestView::Type GetViewType() const OVERRIDE; 28 virtual WebViewGuest* AsWebView() OVERRIDE; 29 virtual AdViewGuest* AsAdView() OVERRIDE; 30 31 private: 32 virtual ~AdViewGuest(); 33 34 virtual void DidCommitProvisionalLoadForFrame( 35 int64 frame_id, 36 bool is_main_frame, 37 const GURL& url, 38 content::PageTransition transition_type, 39 content::RenderViewHost* render_view_host) OVERRIDE; 40 virtual void DidFailProvisionalLoad( 41 int64 frame_id, 42 bool is_main_frame, 43 const GURL& validated_url, 44 int error_code, 45 const string16& error_description, 46 content::RenderViewHost* render_view_host) OVERRIDE; 47 48 DISALLOW_COPY_AND_ASSIGN(AdViewGuest); 49 }; 50 51 #endif // CHROME_BROWSER_GUESTVIEW_ADVIEW_ADVIEW_GUEST_H_ 52