Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 10836155: Upstream ContentView.getNavigationHistory() (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address tedchoc's review comments. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "content/browser/android/content_view_client.h" 12 #include "content/browser/android/content_view_client.h"
13 #include "content/browser/android/touch_point.h" 13 #include "content/browser/android/touch_point.h"
14 #include "content/browser/renderer_host/java/java_bound_object.h" 14 #include "content/browser/renderer_host/java/java_bound_object.h"
15 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" 15 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h"
16 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
17 #include "content/browser/renderer_host/render_widget_host_impl.h" 17 #include "content/browser/renderer_host/render_widget_host_impl.h"
18 #include "content/browser/renderer_host/render_widget_host_view_android.h" 18 #include "content/browser/renderer_host/render_widget_host_view_android.h"
19 #include "content/browser/web_contents/navigation_controller_impl.h" 19 #include "content/browser/web_contents/navigation_controller_impl.h"
20 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
21 #include "content/public/browser/favicon_status.h"
21 #include "content/public/browser/interstitial_page.h" 22 #include "content/public/browser/interstitial_page.h"
23 #include "content/public/browser/navigation_entry.h"
22 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_source.h" 26 #include "content/public/browser/notification_source.h"
25 #include "content/public/browser/notification_types.h" 27 #include "content/public/browser/notification_types.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "jni/ContentViewCore_jni.h" 29 #include "jni/ContentViewCore_jni.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent Factory.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent Factory.h"
33 #include "ui/gfx/android/java_bitmap.h"
31 #include "webkit/glue/webmenuitem.h" 34 #include "webkit/glue/webmenuitem.h"
32 35
33 using base::android::AttachCurrentThread; 36 using base::android::AttachCurrentThread;
34 using base::android::ConvertJavaStringToUTF16; 37 using base::android::ConvertJavaStringToUTF16;
35 using base::android::ConvertUTF16ToJavaString; 38 using base::android::ConvertUTF16ToJavaString;
36 using base::android::ConvertUTF8ToJavaString; 39 using base::android::ConvertUTF8ToJavaString;
37 using base::android::GetClass; 40 using base::android::GetClass;
38 using base::android::HasField; 41 using base::android::HasField;
39 using base::android::ScopedJavaGlobalRef; 42 using base::android::ScopedJavaGlobalRef;
40 using base::android::ScopedJavaLocalRef; 43 using base::android::ScopedJavaLocalRef;
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 WebKit::WebBindings::releaseObject(bound_object); 392 WebKit::WebBindings::releaseObject(bound_object);
390 } 393 }
391 394
392 void ContentViewCoreImpl::RemoveJavascriptInterface(JNIEnv* env, 395 void ContentViewCoreImpl::RemoveJavascriptInterface(JNIEnv* env,
393 jobject /* obj */, 396 jobject /* obj */,
394 jstring name) { 397 jstring name) {
395 web_contents_->java_bridge_dispatcher_host_manager()->RemoveNamedObject( 398 web_contents_->java_bridge_dispatcher_host_manager()->RemoveNamedObject(
396 ConvertJavaStringToUTF16(env, name)); 399 ConvertJavaStringToUTF16(env, name));
397 } 400 }
398 401
402 int ContentViewCoreImpl::GetNavigationHistory(JNIEnv* env,
403 jobject obj,
404 jobject context) {
405 // Iterate through navigation entries to populate the list
406 const NavigationController& controller = web_contents_->GetController();
407 int count = controller.GetEntryCount();
408 for (int i = 0; i < count; ++i) {
409 NavigationEntry* entry = controller.GetEntryAtIndex(i);
410
411 // Get the details of the current entry
412 ScopedJavaLocalRef<jstring> j_url = ConvertUTF8ToJavaString(env,
413 entry->GetURL().spec());
414 ScopedJavaLocalRef<jstring> j_virtual_url = ConvertUTF8ToJavaString(env,
415 entry->GetVirtualURL().spec());
416 ScopedJavaLocalRef<jstring> j_original_url = ConvertUTF8ToJavaString(env,
417 entry->GetOriginalRequestURL().spec());
418 ScopedJavaLocalRef<jstring> j_title = ConvertUTF16ToJavaString(env,
419 entry->GetTitle());
420 ScopedJavaLocalRef<jobject> j_bitmap;
421 const FaviconStatus& status = entry->GetFavicon();
422 if (status.valid && status.image.ToSkBitmap()->getSize() > 0) {
423 j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap());
424 }
425
426 // Add the item to the list
427 Java_ContentViewCore_addToNavigationHistory(env, obj, context, j_url.obj(),
428 j_virtual_url.obj(), j_original_url.obj(), j_title.obj(),
429 j_bitmap.obj());
430 }
431
432 return controller.GetCurrentEntryIndex();
433 }
434
399 // -------------------------------------------------------------------------- 435 // --------------------------------------------------------------------------
400 // Methods called from native code 436 // Methods called from native code
401 // -------------------------------------------------------------------------- 437 // --------------------------------------------------------------------------
402 438
403 void ContentViewCoreImpl::LoadUrl(const GURL& url, int page_transition) { 439 void ContentViewCoreImpl::LoadUrl(const GURL& url, int page_transition) {
404 content::Referrer referer; 440 content::Referrer referer;
405 441
406 web_contents()->GetController().LoadURL( 442 web_contents()->GetController().LoadURL(
407 url, referer, content::PageTransitionFromInt(page_transition), 443 url, referer, content::PageTransitionFromInt(page_transition),
408 std::string()); 444 std::string());
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { 622 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) {
587 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; 623 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!";
588 return false; 624 return false;
589 } 625 }
590 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); 626 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I");
591 627
592 return RegisterNativesImpl(env) >= 0; 628 return RegisterNativesImpl(env) >= 0;
593 } 629 }
594 630
595 } // namespace content 631 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698