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

Side by Side Diff: content/browser/android/render_widget_host_connector.h

Issue 2792063003: Factor out RenderWidgetHostConnector (Closed)
Patch Set: RenderWidgetHostConnnector Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2017 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 #ifndef CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_
6 #define CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "content/public/browser/web_contents_observer.h"
10
11 namespace content {
12
13 class RenderWidgetHostViewAndroid;
14
15 // An base class used to connect an object of the content layer lifecycle
16 // to |RenderWidgetHostViewAndroid|. The inherting class needs to
17 // override |UpdateRenderProcessConnection| to set itself to the RWHVA
18 // brought up foreground, and null out its reference in the RWHVA going
19 // away so it won't access the object any more.
20 class RenderWidgetHostConnector {
21 public:
22 explicit RenderWidgetHostConnector(WebContents* web_contents);
23 virtual ~RenderWidgetHostConnector();
24
25 // Method to set itself to the |new_rwhva|, and null out the reference
26 // in |old_rwvha|. Example:
27 //
28 // if (old_rwhva)
29 // old_rwhva->set_object(nullptr);
30 // if (new_rwhva)
31 // new_rwhva->set_object(this);
32 virtual void UpdateRenderProcessConnection(
33 RenderWidgetHostViewAndroid* old_rwhva,
34 RenderWidgetHostViewAndroid* new_rhwva) = 0;
35
36 RenderWidgetHostViewAndroid* rwhva() const {
boliu 2017/04/10 18:08:43 I mean this getter is not really needed explicitly
Jinsuk Kim 2017/04/11 01:41:58 Removed rwhva() but let ImeAdapterAndroid keep the
boliu 2017/04/11 01:47:04 Yeah I prefer explicit destroy now. That was a on
Jinsuk Kim 2017/04/11 02:28:09 Done. Could you let me know if there's a reason we
boliu 2017/04/11 02:34:24 It's purely to make this interface simpler. If you
37 return render_widget_observer_.rwhva();
38 }
39
40 private:
41 // Observes RenderWidgetHostViewAndroid updates and keeps the up-to-date
42 // instance through the interface |WebContentsObserver|.
43 class Observer : public WebContentsObserver {
44 public:
45 Observer(WebContents* web_contents, RenderWidgetHostConnector* connector);
46 ~Observer() override;
47
48 // WebContentsObserver implementation.
49 void RenderViewReady() override;
50 void RenderViewHostChanged(RenderViewHost* old_host,
51 RenderViewHost* new_host) override;
52 void DidAttachInterstitialPage() override;
53 void DidDetachInterstitialPage() override;
54 void WebContentsDestroyed() override;
55
56 RenderWidgetHostViewAndroid* rwhva() const { return rwhva_.get(); }
57
58 private:
59 void UpdateRenderWidgetHostView(RenderWidgetHostViewAndroid* rwhva);
60 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid() const;
61
62 RenderWidgetHostConnector* connector_;
63 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva_;
64
65 DISALLOW_COPY_AND_ASSIGN(Observer);
66 };
67
68 const Observer render_widget_observer_;
69
70 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostConnector);
71 };
72
73 } // namespace content
74
75 #endif // CONTENT_BROWSER_ANDROID_RENDER_WIDGET_HOST_CONNECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698