1 // Copyright 2015 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_PROXY_H_
6 #define CONTENT_BROWSER_ANDROID_WEB_CONTENTS_OBSERVER_PROXY_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 WebContentsObserverProxy
: public WebContentsObserver
{
27 WebContentsObserverProxy(JNIEnv
* env
, jobject obj
, WebContents
* web_contents
);
28 ~WebContentsObserverProxy() override
;
30 void Destroy(JNIEnv
* env
, jobject obj
);
33 void RenderViewReady() override
;
34 void RenderProcessGone(base::TerminationStatus termination_status
) override
;
35 void DidStartLoading() override
;
36 void DidStopLoading() override
;
37 void DidFailProvisionalLoad(RenderFrameHost
* render_frame_host
,
38 const GURL
& validated_url
,
40 const base::string16
& error_description
,
41 bool was_ignored_by_handler
) override
;
42 void DidFailLoad(RenderFrameHost
* render_frame_host
,
43 const GURL
& validated_url
,
45 const base::string16
& error_description
,
46 bool was_ignored_by_handler
) override
;
47 void DidNavigateMainFrame(const LoadCommittedDetails
& details
,
48 const FrameNavigateParams
& params
) override
;
49 void DidNavigateAnyFrame(RenderFrameHost
* render_frame_host
,
50 const LoadCommittedDetails
& details
,
51 const FrameNavigateParams
& params
) override
;
52 void DocumentAvailableInMainFrame() override
;
53 void DidFirstVisuallyNonEmptyPaint() override
;
54 void DidStartProvisionalLoadForFrame(RenderFrameHost
* render_frame_host
,
55 const GURL
& validated_url
,
57 bool is_iframe_srcdoc
) override
;
58 void DidCommitProvisionalLoadForFrame(
59 RenderFrameHost
* render_frame_host
,
61 ui::PageTransition transition_type
) override
;
62 void DidFinishLoad(RenderFrameHost
* render_frame_host
,
63 const GURL
& validated_url
) override
;
64 void DocumentLoadedInFrame(RenderFrameHost
* render_frame_host
) override
;
65 void NavigationEntryCommitted(
66 const LoadCommittedDetails
& load_details
) override
;
67 void WebContentsDestroyed() override
;
68 void DidAttachInterstitialPage() override
;
69 void DidDetachInterstitialPage() override
;
70 void DidChangeThemeColor(SkColor color
) override
;
71 void DidStartNavigationToPendingEntry(
73 NavigationController::ReloadType reload_type
) override
;
74 void MediaSessionStateChanged(bool is_controllable
,
75 bool is_suspended
) override
;
77 void DidFailLoadInternal(bool is_provisional_load
,
80 const base::string16
& description
,
82 bool was_ignored_by_handler
);
84 base::android::ScopedJavaGlobalRef
<jobject
> java_observer_
;
86 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverProxy
);
89 bool RegisterWebContentsObserverProxy(JNIEnv
* env
);
90 } // namespace content
92 #endif // CONTENT_BROWSER_ANDROID_WEB_CONTENTS_OBSERVER_PROXY_H_