1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_BROWSER_ANDROID_WEB_CONTENTS_OBSERVER_ANDROID_H_
6 #define CONTENT_BROWSER_ANDROID_WEB_CONTENTS_OBSERVER_ANDROID_H_
10 #include "base/android/jni_weak_ref.h"
11 #include "base/basictypes.h"
12 #include "base/process/kill.h"
13 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/common/frame_navigate_params.h"
23 // Extends WebContentsObserver for providing a public Java API for some of the
24 // the calls it receives.
25 class WebContentsObserverAndroid
: public WebContentsObserver
{
27 WebContentsObserverAndroid(JNIEnv
* env
,
29 WebContents
* web_contents
);
30 virtual ~WebContentsObserverAndroid();
32 void Destroy(JNIEnv
* env
, jobject obj
);
35 virtual void RenderProcessGone(
36 base::TerminationStatus termination_status
) OVERRIDE
;
37 virtual void DidStartLoading(RenderViewHost
* render_view_host
) OVERRIDE
;
38 virtual void DidStopLoading(RenderViewHost
* render_view_host
) OVERRIDE
;
39 virtual void DidFailProvisionalLoad(
41 const base::string16
& frame_unique_name
,
43 const GURL
& validated_url
,
45 const base::string16
& error_description
,
46 RenderViewHost
* render_view_host
) OVERRIDE
;
47 virtual void DidFailLoad(int64 frame_id
,
48 const GURL
& validated_url
,
51 const base::string16
& error_description
,
52 RenderViewHost
* render_view_host
) OVERRIDE
;
53 virtual void DidNavigateMainFrame(const LoadCommittedDetails
& details
,
54 const FrameNavigateParams
& params
) OVERRIDE
;
55 virtual void DidNavigateAnyFrame(const LoadCommittedDetails
& details
,
56 const FrameNavigateParams
& params
) OVERRIDE
;
57 virtual void DidFirstVisuallyNonEmptyPaint() OVERRIDE
;
58 virtual void DidStartProvisionalLoadForFrame(
60 int64 parent_frame_id
,
62 const GURL
& validated_url
,
64 bool is_iframe_srcdoc
,
65 RenderViewHost
* render_view_host
) OVERRIDE
;
66 virtual void DidCommitProvisionalLoadForFrame(
68 const base::string16
& frame_unique_name
,
71 PageTransition transition_type
,
72 RenderViewHost
* render_view_host
) OVERRIDE
;
73 virtual void DidFinishLoad(int64 frame_id
,
74 const GURL
& validated_url
,
76 RenderViewHost
* render_view_host
) OVERRIDE
;
77 virtual void DocumentLoadedInFrame(int64 frame_id
,
78 RenderViewHost
* render_view_host
) OVERRIDE
;
79 virtual void NavigationEntryCommitted(
80 const LoadCommittedDetails
& load_details
) OVERRIDE
;
81 virtual void WebContentsDestroyed() OVERRIDE
;
82 virtual void DidAttachInterstitialPage() OVERRIDE
;
83 virtual void DidDetachInterstitialPage() OVERRIDE
;
85 void DidFailLoadInternal(bool is_provisional_load
,
88 const base::string16
& description
,
91 JavaObjectWeakGlobalRef weak_java_observer_
;
93 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverAndroid
);
96 bool RegisterWebContentsObserverAndroid(JNIEnv
* env
);
97 } // namespace content
99 #endif // CONTENT_BROWSER_ANDROID_WEB_CONTENTS_OBSERVER_ANDROID_H_