| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h" | |
| 6 | |
| 7 #include "base/strings/string_util.h" | |
| 8 #include "chrome/browser/guest_view/ad_view/ad_view_constants.h" | |
| 9 #include "chrome/browser/guest_view/guest_view_constants.h" | |
| 10 #include "content/public/browser/web_contents.h" | |
| 11 #include "net/base/net_errors.h" | |
| 12 | |
| 13 using content::WebContents; | |
| 14 | |
| 15 AdViewGuest::AdViewGuest(int guest_instance_id, | |
| 16 WebContents* guest_web_contents, | |
| 17 const std::string& extension_id) | |
| 18 : GuestView<AdViewGuest>(guest_instance_id, | |
| 19 guest_web_contents, | |
| 20 extension_id) { | |
| 21 } | |
| 22 | |
| 23 // static | |
| 24 const char AdViewGuest::Type[] = "adview"; | |
| 25 | |
| 26 AdViewGuest::~AdViewGuest() { | |
| 27 } | |
| 28 | |
| 29 void AdViewGuest::DidCommitProvisionalLoadForFrame( | |
| 30 int64 frame_id, | |
| 31 const base::string16& frame_unique_name, | |
| 32 bool is_main_frame, | |
| 33 const GURL& url, | |
| 34 content::PageTransition transition_type, | |
| 35 content::RenderViewHost* render_view_host) { | |
| 36 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | |
| 37 args->SetString(guestview::kUrl, url.spec()); | |
| 38 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); | |
| 39 DispatchEvent( | |
| 40 new GuestViewBase::Event(adview::kEventLoadCommit, args.Pass())); | |
| 41 } | |
| 42 | |
| 43 void AdViewGuest::DidFailProvisionalLoad( | |
| 44 int64 frame_id, | |
| 45 const base::string16& frame_unique_name, | |
| 46 bool is_main_frame, | |
| 47 const GURL& validated_url, | |
| 48 int error_code, | |
| 49 const base::string16& error_description, | |
| 50 content::RenderViewHost* render_view_host) { | |
| 51 // Translate the |error_code| into an error string. | |
| 52 std::string error_type(net::ErrorToString(error_code)); | |
| 53 DCHECK(StartsWithASCII(error_type, "net::", true)); | |
| 54 error_type.erase(0, 5); | |
| 55 | |
| 56 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | |
| 57 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); | |
| 58 args->SetString(guestview::kUrl, validated_url.spec()); | |
| 59 args->SetString(guestview::kReason, error_type); | |
| 60 DispatchEvent(new GuestViewBase::Event(adview::kEventLoadAbort, args.Pass())); | |
| 61 } | |
| OLD | NEW |