blob: 08243029159fab23dfd0f41d7a8762c52bc57d58 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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
10namespace content {
11class BrowserContext;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000012class JavaScriptDialogManager;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000013class WebContents;
14}
15
16namespace android_webview {
17
18class 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.
28class 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)2a99a7e2013-03-28 15:31:22 +000040 virtual content::BrowserContext* GetBrowserContext() = 0;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000041
42 // Constructs and returns ownership of a WebContents instance.
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000043 virtual content::WebContents* CreateWebContents() = 0;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000044
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_