Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 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 ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ |
| 6 | #define ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | |
| 10 | namespace content { |
| 11 | class BrowserContext; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 12 | class JavaScriptDialogManager; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 13 | class WebContents; |
| 14 | } |
| 15 | |
| 16 | namespace android_webview { |
| 17 | |
| 18 | class AwContentsContainer; |
| 19 | |
| 20 | // The concrete class implementing this interface is the responsible for |
| 21 | // creating he browser component objects that the Android WebView depends on. |
| 22 | // The motivation for this abstraction is to keep code under |
| 23 | // android_webview/native from holding direct chrome/ layer dependencies. |
| 24 | // Note this is a distinct role to the Webview embedder proper: this class is |
| 25 | // about 'static' environmental decoupling, allowing dependency injection by the |
| 26 | // top-level lib, whereas runtime behavior is controlled by propagated back to |
| 27 | // the embedding application code via WebContentsDelegate and the like. |
| 28 | class AwBrowserDependencyFactory { |
| 29 | public: |
| 30 | virtual ~AwBrowserDependencyFactory(); |
| 31 | |
| 32 | // Allows the lib executive to inject the delegate instance. Ownership of |
| 33 | // |delegate| is NOT transferred, but the object must be long-lived. |
| 34 | static void SetInstance(AwBrowserDependencyFactory* delegate); |
| 35 | |
| 36 | // Returns the singleton instance. |SetInstance| must have been called. |
| 37 | static AwBrowserDependencyFactory* GetInstance(); |
| 38 | |
| 39 | // Returns the current browser context based on the specified mode. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 40 | virtual content::BrowserContext* GetBrowserContext() = 0; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 41 | |
| 42 | // Constructs and returns ownership of a WebContents instance. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 43 | virtual content::WebContents* CreateWebContents() = 0; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 44 | |
| 45 | protected: |
| 46 | AwBrowserDependencyFactory(); |
| 47 | |
| 48 | private: |
| 49 | DISALLOW_COPY_AND_ASSIGN(AwBrowserDependencyFactory); |
| 50 | }; |
| 51 | |
| 52 | } // namespace android_webview |
| 53 | |
| 54 | #endif // ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ |