Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / android / web_contents_observer_proxy.h
blob0f21400a4aecb8becdc78c0bcda829bdd7c9fe49
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_
8 #include <jni.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"
16 #include "url/gurl.h"
18 namespace content {
20 class RenderViewHost;
21 class WebContents;
23 // Extends WebContentsObserver for providing a public Java API for some of the
24 // the calls it receives.
25 class WebContentsObserverProxy : public WebContentsObserver {
26 public:
27 WebContentsObserverProxy(JNIEnv* env, jobject obj, WebContents* web_contents);
28 ~WebContentsObserverProxy() override;
30 void Destroy(JNIEnv* env, jobject obj);
32 private:
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,
39 int error_code,
40 const base::string16& error_description) override;
41 void DidFailLoad(RenderFrameHost* render_frame_host,
42 const GURL& validated_url,
43 int error_code,
44 const base::string16& error_description) override;
45 void DidNavigateMainFrame(const LoadCommittedDetails& details,
46 const FrameNavigateParams& params) override;
47 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
48 const LoadCommittedDetails& details,
49 const FrameNavigateParams& params) override;
50 void DocumentAvailableInMainFrame() override;
51 void DidFirstVisuallyNonEmptyPaint() override;
52 void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
53 const GURL& validated_url,
54 bool is_error_page,
55 bool is_iframe_srcdoc) override;
56 void DidCommitProvisionalLoadForFrame(
57 RenderFrameHost* render_frame_host,
58 const GURL& url,
59 ui::PageTransition transition_type) override;
60 void DidFinishLoad(RenderFrameHost* render_frame_host,
61 const GURL& validated_url) override;
62 void DocumentLoadedInFrame(RenderFrameHost* render_frame_host) override;
63 void NavigationEntryCommitted(
64 const LoadCommittedDetails& load_details) override;
65 void WebContentsDestroyed() override;
66 void DidAttachInterstitialPage() override;
67 void DidDetachInterstitialPage() override;
68 void DidChangeThemeColor(SkColor color) override;
69 void DidStartNavigationToPendingEntry(
70 const GURL& url,
71 NavigationController::ReloadType reload_type) override;
73 void DidFailLoadInternal(bool is_provisional_load,
74 bool is_main_frame,
75 int error_code,
76 const base::string16& description,
77 const GURL& url);
79 base::android::ScopedJavaGlobalRef<jobject> java_observer_;
81 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverProxy);
84 bool RegisterWebContentsObserverProxy(JNIEnv* env);
85 } // namespace content
87 #endif // CONTENT_BROWSER_ANDROID_WEB_CONTENTS_OBSERVER_PROXY_H_