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