Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
Kevin M
2016/06/07 22:43:43
Unit tests? :)
haibinlu
2016/06/08 17:57:22
per offline discussion, we should add some browser
maniscalco
2016/06/08 19:59:39
Not that I necessarily disagree, but could you ela
| |
| 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_BLIMP_H_ | |
| 6 #define BLIMP_ENGINE_SESSION_TAB_BLIMP_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "content/public/browser/invalidate_type.h" | |
| 10 #include "content/public/browser/web_contents_observer.h" | |
| 11 #include "blimp/engine/session/page_load_tracker.h" | |
| 12 | |
| 13 namespace content { | |
| 14 class RenderViewHost; | |
| 15 class WebContents; | |
| 16 } | |
| 17 | |
| 18 namespace blimp { | |
| 19 class BlimpMessageProcessor; | |
| 20 | |
| 21 namespace engine { | |
| 22 class EngineRenderWidgetFeature; | |
| 23 | |
| 24 // Owns WebContents, handles operations in the tab, and has one-to-one mapping | |
| 25 // to a client tab. | |
| 26 class Tab : public content::WebContentsObserver, public PageLoadTrackerClient { | |
| 27 public: | |
| 28 // Caller ensures |render_widget_feature| and |navigation_message_sender| | |
| 29 // outlives this object. | |
| 30 // |web_contents|: the WebContents this tab owns. | |
| 31 // |tab_id|: the ID of this tab. | |
| 32 // |render_widget_feature|: render widget feature. | |
| 33 // |navigation_message_sender|: for sending navigation messages to client. | |
| 34 Tab(std::unique_ptr<content::WebContents> web_contents, | |
| 35 const int tab_id, | |
| 36 EngineRenderWidgetFeature* render_widget_feature, | |
| 37 BlimpMessageProcessor* navigation_message_sender); | |
| 38 ~Tab() override; | |
| 39 | |
| 40 content::WebContents* web_contents() { return web_contents_.get(); } | |
| 41 int tab_id() const { return tab_id_; } | |
| 42 | |
| 43 void Resize(float device_pixel_ratio, const gfx::Size& size_in_dips); | |
| 44 void LoadUrl(const GURL& url); | |
| 45 void GoBack(); | |
| 46 void GoForward(); | |
| 47 void Reload(); | |
| 48 void NavigationStateChanged(content::InvalidateTypes changed_flags); | |
| 49 | |
| 50 // PageLoadTrackerClient implementation. | |
| 51 void SendPageLoadStatusUpdate(PageLoadStatus load_status) override; | |
| 52 | |
| 53 private: | |
| 54 // content::WebContentsObserver implementation. | |
| 55 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | |
| 56 void RenderViewHostChanged(content::RenderViewHost* old_host, | |
| 57 content::RenderViewHost* new_host) override; | |
| 58 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | |
| 59 | |
| 60 std::unique_ptr<content::WebContents> web_contents_; | |
| 61 const int tab_id_; | |
| 62 EngineRenderWidgetFeature* render_widget_feature_; | |
| 63 BlimpMessageProcessor* navigation_message_sender_; | |
| 64 | |
| 65 // Tracks the page load status for a tab. | |
| 66 std::unique_ptr<PageLoadTracker> page_load_tracker_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(Tab); | |
| 69 }; | |
| 70 | |
| 71 } // namespace engine | |
| 72 } // namespace blimp | |
| 73 | |
| 74 #endif // BLIMP_ENGINE_SESSION_TAB_BLIMP_H_ | |
| OLD | NEW |