blob: 512e5e8c6738cc07fbff7a69020eb6663b60b286 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_
#define CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_
#include <jni.h>
#include <vector>
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_switches.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"
class GURL;
namespace content {
class BrowserContext;
class SiteInstance;
class WebContents;
} // namespace content
namespace chromecast {
namespace shell {
class CastWindowAndroid : public content::WebContentsDelegate,
public content::WebContentsObserver {
public:
// Creates a new window and immediately loads the given URL.
static CastWindowAndroid* CreateNewWindow(
content::BrowserContext* browser_context,
const GURL& url);
virtual ~CastWindowAndroid();
void LoadURL(const GURL& url);
void Close();
// Registers the JNI methods for CastWindowAndroid.
static bool RegisterJni(JNIEnv* env);
// content::WebContentsDelegate implementation:
virtual void AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture,
bool* was_blocked) OVERRIDE;
virtual void CloseContents(content::WebContents* source) OVERRIDE;
virtual bool CanOverscrollContent() const OVERRIDE;
virtual bool AddMessageToConsole(content::WebContents* source,
int32 level,
const base::string16& message,
int32 line_no,
const base::string16& source_id) OVERRIDE;
virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
virtual void DeactivateContents(content::WebContents* contents) OVERRIDE;
// content::WebContentsObserver implementation:
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
private:
explicit CastWindowAndroid(content::WebContents* web_contents);
// Helper to create a new CastWindowAndroid given a newly created WebContents.
static CastWindowAndroid* CreateCastWindowAndroid(
content::WebContents* web_contents,
const gfx::Size& initial_size);
base::android::ScopedJavaGlobalRef<jobject> java_object_;
scoped_ptr<content::WebContents> web_contents_;
DISALLOW_COPY_AND_ASSIGN(CastWindowAndroid);
};
} // namespace shell
} // namespace chromecast
#endif // CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_
|