Make Ctrl + T from apps focus the new tab's omnibox on Linux and ChromeOS.
[chromium-blink-merge.git] / chromecast / browser / android / cast_window_android.h
blob7c5cd7415f1034921fd239d7e366d43a637a55e4
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.
5 #ifndef CHROMECAST_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_
6 #define CHROMECAST_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_
8 #include <jni.h>
9 #include <vector>
11 #include "base/android/jni_string.h"
12 #include "base/android/scoped_java_ref.h"
13 #include "base/basictypes.h"
14 #include "base/callback_forward.h"
15 #include "base/command_line.h"
16 #include "base/macros.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h"
19 #include "build/build_config.h"
20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_delegate.h"
22 #include "content/public/browser/web_contents_observer.h"
23 #include "content/public/common/content_switches.h"
24 #include "ui/gfx/geometry/size.h"
25 #include "ui/gfx/native_widget_types.h"
27 class GURL;
29 namespace content {
30 class BrowserContext;
31 class SiteInstance;
32 class WebContents;
33 } // namespace content
35 namespace chromecast {
36 class CastContentWindow;
37 namespace shell {
39 class CastWindowAndroid : public content::WebContentsDelegate,
40 public content::WebContentsObserver {
41 public:
42 // Creates a new window and immediately loads the given URL.
43 static CastWindowAndroid* CreateNewWindow(
44 content::BrowserContext* browser_context,
45 const GURL& url);
47 ~CastWindowAndroid() override;
49 void LoadURL(const GURL& url);
50 // Calls RVH::ClosePage() and waits for acknowledgement before closing/
51 // deleting the window.
52 void Close();
53 // Destroys this window immediately.
54 void Destroy();
56 // Registers the JNI methods for CastWindowAndroid.
57 static bool RegisterJni(JNIEnv* env);
59 // content::WebContentsDelegate implementation:
60 void AddNewContents(content::WebContents* source,
61 content::WebContents* new_contents,
62 WindowOpenDisposition disposition,
63 const gfx::Rect& initial_rect,
64 bool user_gesture,
65 bool* was_blocked) override;
66 void CloseContents(content::WebContents* source) override;
67 bool CanOverscrollContent() const override;
68 bool AddMessageToConsole(content::WebContents* source,
69 int32 level,
70 const base::string16& message,
71 int32 line_no,
72 const base::string16& source_id) override;
73 void ActivateContents(content::WebContents* contents) override;
74 void DeactivateContents(content::WebContents* contents) override;
76 // content::WebContentsObserver implementation:
77 void RenderProcessGone(base::TerminationStatus status) override;
79 private:
80 explicit CastWindowAndroid(content::BrowserContext* browser_context);
81 void Initialize();
83 content::BrowserContext* browser_context_;
84 base::android::ScopedJavaGlobalRef<jobject> window_java_;
85 scoped_ptr<content::WebContents> web_contents_;
86 scoped_ptr<CastContentWindow> content_window_;
88 base::WeakPtrFactory<CastWindowAndroid> weak_factory_;
90 DISALLOW_COPY_AND_ASSIGN(CastWindowAndroid);
93 } // namespace shell
94 } // namespace chromecast
96 #endif // CHROMECAST_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_