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 #include "chrome/browser/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
| 6 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 7 #include "content/public/browser/android/content_view_core.h" |
| 8 #include "content/public/browser/web_contents.h" |
| 9 |
| 10 using content::ContentViewCore; |
| 11 using content::WebContents; |
| 12 |
| 13 TabContents* TabAndroid::GetOrCreateTabContents(WebContents* web_contents) { |
| 14 TabContents* tab_contents = TabContents::FromWebContents(web_contents); |
| 15 return tab_contents ? tab_contents : TabContents::Factory::CreateTabContents( |
| 16 web_contents); |
| 17 } |
| 18 |
| 19 TabContents* TabAndroid::InitTabContentsFromView(JNIEnv* env, |
| 20 jobject content_view) { |
| 21 ContentViewCore* content_view_core = |
| 22 ContentViewCore::GetNativeContentViewCore(env, content_view); |
| 23 DCHECK(content_view_core); |
| 24 DCHECK(content_view_core->GetWebContents()); |
| 25 return GetOrCreateTabContents(content_view_core->GetWebContents()); |
| 26 } |
6 | 27 |
7 TabAndroid::TabAndroid() : tab_id_(-1) { | 28 TabAndroid::TabAndroid() : tab_id_(-1) { |
8 } | 29 } |
9 | 30 |
10 TabAndroid::~TabAndroid() { | 31 TabAndroid::~TabAndroid() { |
11 } | 32 } |
OLD | NEW |