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

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

Issue 257823005: [Sheriff] Revert "Revert "Revert 266297 "1. Handle the case of empty embedder_extension_id...""" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/guestview/adview/adview_guest.h ('k') | chrome/browser/guestview/guestview.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 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/guest_view/ad_view/ad_view_guest.h" 5 #include "chrome/browser/guestview/adview/adview_guest.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/browser/guest_view/ad_view/ad_view_constants.h" 8 #include "chrome/browser/guestview/adview/adview_constants.h"
9 #include "chrome/browser/guest_view/guest_view_constants.h" 9 #include "chrome/browser/guestview/guestview_constants.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 12
13 using content::WebContents; 13 using content::WebContents;
14 14
15 AdViewGuest::AdViewGuest(WebContents* guest_web_contents, 15 AdViewGuest::AdViewGuest(WebContents* guest_web_contents,
16 const std::string& extension_id) 16 const std::string& extension_id)
17 : GuestView<AdViewGuest>(guest_web_contents, extension_id), 17 : GuestView(guest_web_contents, extension_id),
18 WebContentsObserver(guest_web_contents) { 18 WebContentsObserver(guest_web_contents) {
19 } 19 }
20 20
21 // static 21 // static
22 const char AdViewGuest::Type[] = "adview"; 22 AdViewGuest* AdViewGuest::From(int embedder_process_id,
23 int guest_instance_id) {
24 GuestView* guest = GuestView::From(embedder_process_id, guest_instance_id);
25 if (!guest)
26 return NULL;
27 return guest->AsAdView();
28 }
29
30 GuestView::Type AdViewGuest::GetViewType() const {
31 return GuestView::ADVIEW;
32 }
33
34 WebViewGuest* AdViewGuest::AsWebView() {
35 return NULL;
36 }
37
38 AdViewGuest* AdViewGuest::AsAdView() {
39 return this;
40 }
23 41
24 AdViewGuest::~AdViewGuest() { 42 AdViewGuest::~AdViewGuest() {
25 } 43 }
26 44
27 void AdViewGuest::DidCommitProvisionalLoadForFrame( 45 void AdViewGuest::DidCommitProvisionalLoadForFrame(
28 int64 frame_id, 46 int64 frame_id,
29 const base::string16& frame_unique_name, 47 const base::string16& frame_unique_name,
30 bool is_main_frame, 48 bool is_main_frame,
31 const GURL& url, 49 const GURL& url,
32 content::PageTransition transition_type, 50 content::PageTransition transition_type,
33 content::RenderViewHost* render_view_host) { 51 content::RenderViewHost* render_view_host) {
34 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 52 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
35 args->SetString(guestview::kUrl, url.spec()); 53 args->SetString(guestview::kUrl, url.spec());
36 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); 54 args->SetBoolean(guestview::kIsTopLevel, is_main_frame);
37 DispatchEvent( 55 DispatchEvent(new GuestView::Event(adview::kEventLoadCommit, args.Pass()));
38 new GuestViewBase::Event(adview::kEventLoadCommit, args.Pass()));
39 } 56 }
40 57
41 void AdViewGuest::DidFailProvisionalLoad( 58 void AdViewGuest::DidFailProvisionalLoad(
42 int64 frame_id, 59 int64 frame_id,
43 const base::string16& frame_unique_name, 60 const base::string16& frame_unique_name,
44 bool is_main_frame, 61 bool is_main_frame,
45 const GURL& validated_url, 62 const GURL& validated_url,
46 int error_code, 63 int error_code,
47 const base::string16& error_description, 64 const base::string16& error_description,
48 content::RenderViewHost* render_view_host) { 65 content::RenderViewHost* render_view_host) {
49 // Translate the |error_code| into an error string. 66 // Translate the |error_code| into an error string.
50 std::string error_type; 67 std::string error_type;
51 base::RemoveChars(net::ErrorToString(error_code), "net::", &error_type); 68 base::RemoveChars(net::ErrorToString(error_code), "net::", &error_type);
52 69
53 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 70 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
54 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); 71 args->SetBoolean(guestview::kIsTopLevel, is_main_frame);
55 args->SetString(guestview::kUrl, validated_url.spec()); 72 args->SetString(guestview::kUrl, validated_url.spec());
56 args->SetString(guestview::kReason, error_type); 73 args->SetString(guestview::kReason, error_type);
57 DispatchEvent(new GuestViewBase::Event(adview::kEventLoadAbort, args.Pass())); 74 DispatchEvent(new GuestView::Event(adview::kEventLoadAbort, args.Pass()));
58 } 75 }
OLDNEW
« no previous file with comments | « chrome/browser/guestview/adview/adview_guest.h ('k') | chrome/browser/guestview/guestview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698