| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 // TODO(jam): remove this file when all files have been converted. |
| 10 #include "chrome/common/notification_registrar.h" | 10 #include "content/browser/tab_contents/test_tab_contents.h" |
| 11 #include "webkit/glue/webpreferences.h" | |
| 12 | |
| 13 class Profile; | |
| 14 class TestRenderViewHost; | |
| 15 | |
| 16 // Subclass TabContents to ensure it creates TestRenderViewHosts and does | |
| 17 // not do anything involving views. | |
| 18 class TestTabContents : public TabContents { | |
| 19 public: | |
| 20 // The render view host factory will be passed on to the | |
| 21 TestTabContents(Profile* profile, SiteInstance* instance); | |
| 22 | |
| 23 TestRenderViewHost* pending_rvh() const; | |
| 24 | |
| 25 // State accessor. | |
| 26 bool cross_navigation_pending() { | |
| 27 return render_manager_.cross_navigation_pending_; | |
| 28 } | |
| 29 | |
| 30 // Overrides TabContents::ShouldTransitionCrossSite so that we can test both | |
| 31 // alternatives without using command-line switches. | |
| 32 bool ShouldTransitionCrossSite() { return transition_cross_site; } | |
| 33 | |
| 34 // Overrides TabContents::Observe. We are listening to infobar related | |
| 35 // notifications so we can call InfoBarClosed() on the infobar delegates to | |
| 36 // prevent them from leaking. | |
| 37 virtual void Observe(NotificationType type, | |
| 38 const NotificationSource& source, | |
| 39 const NotificationDetails& details); | |
| 40 | |
| 41 // Promote DidNavigate to public. | |
| 42 void TestDidNavigate(RenderViewHost* render_view_host, | |
| 43 const ViewHostMsg_FrameNavigate_Params& params) { | |
| 44 DidNavigate(render_view_host, params); | |
| 45 } | |
| 46 | |
| 47 // Promote GetWebkitPrefs to public. | |
| 48 WebPreferences TestGetWebkitPrefs() { | |
| 49 return GetWebkitPrefs(); | |
| 50 } | |
| 51 | |
| 52 // Prevent interaction with views. | |
| 53 virtual bool CreateRenderViewForRenderManager( | |
| 54 RenderViewHost* render_view_host); | |
| 55 virtual void UpdateRenderViewSizeForRenderManager() {} | |
| 56 | |
| 57 // Returns a clone of this TestTabContents. The returned object is also a | |
| 58 // TestTabContents. The caller owns the returned object. | |
| 59 virtual TabContents* Clone(); | |
| 60 | |
| 61 // Creates a pending navigation to the given URL with the default parameters | |
| 62 // and then commits the load with a page ID one larger than any seen. This | |
| 63 // emulates what happens on a new navigation. | |
| 64 void NavigateAndCommit(const GURL& url); | |
| 65 | |
| 66 // Simulates the appropriate RenderView (pending if any, current otherwise) | |
| 67 // sending a navigate notification for the NavigationController pending entry. | |
| 68 void CommitPendingNavigation(); | |
| 69 | |
| 70 // Simulates the current RVH notifying that it has unloaded so that the | |
| 71 // pending RVH navigation can proceed. | |
| 72 // Does nothing if no cross-navigation is pending. | |
| 73 void ProceedWithCrossSiteNavigation(); | |
| 74 | |
| 75 // Set by individual tests. | |
| 76 bool transition_cross_site; | |
| 77 | |
| 78 NotificationRegistrar registrar_; | |
| 79 }; | |
| 80 | 11 |
| 81 #endif // CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ | 12 #endif // CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ |
| OLD | NEW |