1 // Copyright 2014 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 CHROME_BROWSER_UI_TAB_HELPERS_H_ 6 #define CHROME_BROWSER_UI_TAB_HELPERS_H_ 7 8 namespace content { 9 class WebContents; 10 } 11 12 namespace chrome { 13 class BrowserTabStripModelDelegate; 14 15 namespace android { 16 class ChromeWebContentsDelegateAndroid; 17 } 18 } 19 20 namespace prerender { 21 class PrerenderContents; 22 } 23 24 // A "tab contents" is a WebContents that is used as a tab in a browser window 25 // (or the equivalent on Android). The TabHelpers class allows specific classes 26 // to attach the set of tab helpers that is used for tab contents. 27 // 28 // TODO(avi): This list is rather large, and for most callers it's due to the 29 // fact that they need tab helpers attached early to deal with arbitrary 30 // content loaded into a WebContents that will later be added to the tabstrip. 31 // Is there a better way to handle this? (Ideally, this list would contain 32 // only Browser and BrowserTabStripModelDelegate.) 33 class TabHelpers { 34 private: 35 // Browser and its TabStripModelDelegate have intimate control of tabs. 36 // TabAndroid is the equivalent on Android. 37 friend class Browser; 38 friend class chrome::BrowserTabStripModelDelegate; 39 40 // These are the Android equivalents of the two classes above. 41 friend class TabAndroid; 42 friend class chrome::android::ChromeWebContentsDelegateAndroid; 43 44 // chrome::Navigate creates WebContents that are destined for the tab strip, 45 // and that might have WebUI that immediately calls back into random tab 46 // helpers. 47 friend class BrowserNavigatorWebContentsAdoption; 48 49 // Prerendering loads pages that have arbitrary external content; it needs 50 // the full set of tab helpers to deal with it. 51 friend class prerender::PrerenderContents; 52 53 // Adopts the specified WebContents as a full-fledged browser tab, attaching 54 // all the associated tab helpers that are needed for the WebContents to 55 // serve in that role. It is safe to call this on a WebContents that was 56 // already adopted. 57 static void AttachTabHelpers(content::WebContents* web_contents); 58 }; 59 60 #endif // CHROME_BROWSER_UI_TAB_HELPERS_H_ 61