OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 BLIMP_ENGINE_SESSION_TAB_H_ |
| 6 #define BLIMP_ENGINE_SESSION_TAB_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "blimp/engine/session/page_load_tracker.h" |
| 10 #include "content/public/browser/invalidate_type.h" |
| 11 #include "content/public/browser/web_contents_observer.h" |
| 12 |
| 13 namespace content { |
| 14 class RenderViewHost; |
| 15 class WebContents; |
| 16 } |
| 17 |
| 18 namespace blimp { |
| 19 |
| 20 class BlimpMessageProcessor; |
| 21 |
| 22 namespace engine { |
| 23 |
| 24 class EngineRenderWidgetFeature; |
| 25 |
| 26 // Owns WebContents, handles operations such as navigation requests in the tab, |
| 27 // and has one-to-one mapping to a client tab. |
| 28 class Tab : public content::WebContentsObserver, public PageLoadTrackerClient { |
| 29 public: |
| 30 // Caller ensures |render_widget_feature| and |navigation_message_sender| |
| 31 // outlives this object. |
| 32 // |web_contents|: the WebContents this tab owns. |
| 33 // |tab_id|: the ID of this tab. |
| 34 // |render_widget_feature|: render widget feature. |
| 35 // |navigation_message_sender|: for sending navigation messages to client. |
| 36 Tab(std::unique_ptr<content::WebContents> web_contents, |
| 37 const int tab_id, |
| 38 EngineRenderWidgetFeature* render_widget_feature, |
| 39 BlimpMessageProcessor* navigation_message_sender); |
| 40 ~Tab() override; |
| 41 |
| 42 content::WebContents* web_contents() { return web_contents_.get(); } |
| 43 int tab_id() const { return tab_id_; } |
| 44 |
| 45 // Resizes the tab to |size_in_dips| with |device_pixel_ratio|. |
| 46 void Resize(float device_pixel_ratio, const gfx::Size& size_in_dips); |
| 47 |
| 48 // Handles tab navigation. |
| 49 void LoadUrl(const GURL& url); |
| 50 void GoBack(); |
| 51 void GoForward(); |
| 52 void Reload(); |
| 53 |
| 54 // Handles navigation state changed event. |
| 55 void NavigationStateChanged(content::InvalidateTypes changed_flags); |
| 56 |
| 57 // PageLoadTrackerClient implementation. |
| 58 void SendPageLoadStatusUpdate(PageLoadStatus load_status) override; |
| 59 |
| 60 private: |
| 61 // content::WebContentsObserver implementation. |
| 62 void RenderViewCreated(content::RenderViewHost* render_view_host) override; |
| 63 void RenderViewHostChanged(content::RenderViewHost* old_host, |
| 64 content::RenderViewHost* new_host) override; |
| 65 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; |
| 66 |
| 67 std::unique_ptr<content::WebContents> web_contents_; |
| 68 const int tab_id_; |
| 69 EngineRenderWidgetFeature* render_widget_feature_; |
| 70 BlimpMessageProcessor* navigation_message_sender_; |
| 71 |
| 72 // Tracks the page load status for a tab. |
| 73 PageLoadTracker page_load_tracker_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(Tab); |
| 76 }; |
| 77 |
| 78 } // namespace engine |
| 79 } // namespace blimp |
| 80 |
| 81 #endif // BLIMP_ENGINE_SESSION_TAB_H_ |
OLD | NEW |