| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ | 5 #ifndef ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ |
| 6 #define ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ | 6 #define ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 class BrowserContext; |
| 11 class JavaScriptDialogCreator; | 12 class JavaScriptDialogCreator; |
| 12 class WebContents; | 13 class WebContents; |
| 13 } | 14 } |
| 14 | 15 |
| 15 namespace android_webview { | 16 namespace android_webview { |
| 16 | 17 |
| 17 class AwContentsContainer; | 18 class AwContentsContainer; |
| 18 | 19 |
| 19 // The concrete class implementing this interface is the responsible for | 20 // The concrete class implementing this interface is the responsible for |
| 20 // creating he browser component objects that the Android WebView depends on. | 21 // creating he browser component objects that the Android WebView depends on. |
| 21 // The motivation for this abstraction is to keep code under | 22 // The motivation for this abstraction is to keep code under |
| 22 // android_webview/native from holding direct chrome/ layer dependencies. | 23 // android_webview/native from holding direct chrome/ layer dependencies. |
| 23 // Note this is a distinct role to the Webview embedder proper: this class is | 24 // Note this is a distinct role to the Webview embedder proper: this class is |
| 24 // about 'static' environmental decoupling, allowing dependency injection by the | 25 // about 'static' environmental decoupling, allowing dependency injection by the |
| 25 // top-level lib, whereas runtime behavior is controlled by propagated back to | 26 // top-level lib, whereas runtime behavior is controlled by propagated back to |
| 26 // the embedding application code via WebContentsDelegate and the like. | 27 // the embedding application code via WebContentsDelegate and the like. |
| 27 class AwBrowserDependencyFactory { | 28 class AwBrowserDependencyFactory { |
| 28 public: | 29 public: |
| 29 virtual ~AwBrowserDependencyFactory(); | 30 virtual ~AwBrowserDependencyFactory(); |
| 30 | 31 |
| 31 // Allows the lib executive to inject the delegate instance. Ownership of | 32 // Allows the lib executive to inject the delegate instance. Ownership of |
| 32 // |delegate| is NOT transferred, but the object must be long-lived. | 33 // |delegate| is NOT transferred, but the object must be long-lived. |
| 33 static void SetInstance(AwBrowserDependencyFactory* delegate); | 34 static void SetInstance(AwBrowserDependencyFactory* delegate); |
| 34 | 35 |
| 35 // Returns the singleton instance. |SetInstance| must have been called. | 36 // Returns the singleton instance. |SetInstance| must have been called. |
| 36 static AwBrowserDependencyFactory* GetInstance(); | 37 static AwBrowserDependencyFactory* GetInstance(); |
| 37 | 38 |
| 39 // Returns the current browser context based on the specified mode. |
| 40 virtual content::BrowserContext* GetBrowserContext(bool incognito) = 0; |
| 41 |
| 38 // Constructs and returns ownership of a WebContents instance. | 42 // Constructs and returns ownership of a WebContents instance. |
| 39 virtual content::WebContents* CreateWebContents(bool incognito) = 0; | 43 virtual content::WebContents* CreateWebContents(bool incognito) = 0; |
| 40 | 44 |
| 41 // Creates and returns ownership of a new content container instance. That | 45 // Creates and returns ownership of a new content container instance. That |
| 42 // instance will take ownership of the passed |contents|. | 46 // instance will take ownership of the passed |contents|. |
| 43 virtual AwContentsContainer* CreateContentsContainer( | 47 virtual AwContentsContainer* CreateContentsContainer( |
| 44 content::WebContents* contents) = 0; | 48 content::WebContents* contents) = 0; |
| 45 | 49 |
| 46 // As per the WebContentsDelegate method of the same name. Ownership is NOT | 50 // As per the WebContentsDelegate method of the same name. Ownership is NOT |
| 47 // returned; the instance must be long-lived. | 51 // returned; the instance must be long-lived. |
| 48 virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator() = 0; | 52 virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator() = 0; |
| 49 | 53 |
| 50 protected: | 54 protected: |
| 51 AwBrowserDependencyFactory(); | 55 AwBrowserDependencyFactory(); |
| 52 | 56 |
| 53 private: | 57 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(AwBrowserDependencyFactory); | 58 DISALLOW_COPY_AND_ASSIGN(AwBrowserDependencyFactory); |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 } // namespace android_webview | 61 } // namespace android_webview |
| 58 | 62 |
| 59 #endif // ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ | 63 #endif // ANDROID_WEBVIEW_AW_BROWSER_DELEGATE_H_ |
| 60 | 64 |
| OLD | NEW |