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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 406023002: Restructuring NavigationController functionalities from ContentViewCore to NavigationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unwanted headers Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 08051f5dfb6acc9fca324492f6ea911aef8f6b6f..8b28c97219da104c0aa04ff086fc2a38dea5b009 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -782,11 +782,6 @@ void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
root_layer_->SetIsDrawable(true);
}
-void ContentViewCoreImpl::LoadUrl(
- NavigationController::LoadURLParams& params) {
- GetWebContents()->GetController().LoadURLWithParams(params);
-}
-
ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() const {
return view_android_;
}
@@ -822,63 +817,6 @@ void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj,
rvhi->DidSelectPopupMenuItems(selected_indices);
}
-void ContentViewCoreImpl::LoadUrl(
- JNIEnv* env, jobject obj,
- jstring url,
- jint load_url_type,
- jint transition_type,
- jstring j_referrer_url,
- jint referrer_policy,
- jint ua_override_option,
- jstring extra_headers,
- jbyteArray post_data,
- jstring base_url_for_data_url,
- jstring virtual_url_for_data_url,
- jboolean can_load_local_resources,
- jboolean is_renderer_initiated) {
- DCHECK(url);
- NavigationController::LoadURLParams params(
- GURL(ConvertJavaStringToUTF8(env, url)));
-
- params.load_type = static_cast<NavigationController::LoadURLType>(
- load_url_type);
- params.transition_type = PageTransitionFromInt(transition_type);
- params.override_user_agent =
- static_cast<NavigationController::UserAgentOverrideOption>(
- ua_override_option);
-
- if (extra_headers)
- params.extra_headers = ConvertJavaStringToUTF8(env, extra_headers);
-
- if (post_data) {
- std::vector<uint8> http_body_vector;
- base::android::JavaByteArrayToByteVector(env, post_data, &http_body_vector);
- params.browser_initiated_post_data =
- base::RefCountedBytes::TakeVector(&http_body_vector);
- }
-
- if (base_url_for_data_url) {
- params.base_url_for_data_url =
- GURL(ConvertJavaStringToUTF8(env, base_url_for_data_url));
- }
-
- if (virtual_url_for_data_url) {
- params.virtual_url_for_data_url =
- GURL(ConvertJavaStringToUTF8(env, virtual_url_for_data_url));
- }
-
- params.can_load_local_resources = can_load_local_resources;
- if (j_referrer_url) {
- params.referrer = content::Referrer(
- GURL(ConvertJavaStringToUTF8(env, j_referrer_url)),
- static_cast<blink::WebReferrerPolicy>(referrer_policy));
- }
-
- params.is_renderer_initiated = is_renderer_initiated;
-
- LoadUrl(params);
-}
-
ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL(
JNIEnv* env, jobject) const {
return ConvertUTF8ToJavaString(env, GetWebContents()->GetURL().spec());
@@ -1165,12 +1103,6 @@ void ContentViewCoreImpl::SetMultiTouchZoomSupportEnabled(JNIEnv* env,
rwhv->SetMultiTouchZoomSupportEnabled(enabled);
}
-void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) {
- // TODO(creis): Do callers of this need to know if it fails?
- if (web_contents_->GetController().CanPruneAllButLastCommitted())
- web_contents_->GetController().PruneAllButLastCommitted();
-}
-
void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection(
JNIEnv* env,
jobject obj,
@@ -1212,79 +1144,6 @@ void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) {
}
}
-namespace {
-
-static void AddNavigationEntryToHistory(JNIEnv* env, jobject obj,
- jobject history,
- NavigationEntry* entry,
- int index) {
- // Get the details of the current entry
- ScopedJavaLocalRef<jstring> j_url(
- ConvertUTF8ToJavaString(env, entry->GetURL().spec()));
- ScopedJavaLocalRef<jstring> j_virtual_url(
- ConvertUTF8ToJavaString(env, entry->GetVirtualURL().spec()));
- ScopedJavaLocalRef<jstring> j_original_url(
- ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec()));
- ScopedJavaLocalRef<jstring> j_title(
- ConvertUTF16ToJavaString(env, entry->GetTitle()));
- ScopedJavaLocalRef<jobject> j_bitmap;
- const FaviconStatus& status = entry->GetFavicon();
- if (status.valid && status.image.ToSkBitmap()->getSize() > 0)
- j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap());
-
- // Add the item to the list
- Java_ContentViewCore_addToNavigationHistory(
- env, obj, history, index, j_url.obj(), j_virtual_url.obj(),
- j_original_url.obj(), j_title.obj(), j_bitmap.obj());
-}
-
-} // namespace
-
-int ContentViewCoreImpl::GetNavigationHistory(JNIEnv* env,
- jobject obj,
- jobject history) {
- // Iterate through navigation entries to populate the list
- const NavigationController& controller = web_contents_->GetController();
- int count = controller.GetEntryCount();
- for (int i = 0; i < count; ++i) {
- AddNavigationEntryToHistory(
- env, obj, history, controller.GetEntryAtIndex(i), i);
- }
-
- return controller.GetCurrentEntryIndex();
-}
-
-void ContentViewCoreImpl::GetDirectedNavigationHistory(JNIEnv* env,
- jobject obj,
- jobject history,
- jboolean is_forward,
- jint max_entries) {
- // Iterate through navigation entries to populate the list
- const NavigationController& controller = web_contents_->GetController();
- int count = controller.GetEntryCount();
- int num_added = 0;
- int increment_value = is_forward ? 1 : -1;
- for (int i = controller.GetCurrentEntryIndex() + increment_value;
- i >= 0 && i < count;
- i += increment_value) {
- if (num_added >= max_entries)
- break;
-
- AddNavigationEntryToHistory(
- env, obj, history, controller.GetEntryAtIndex(i), i);
- num_added++;
- }
-}
-
-ScopedJavaLocalRef<jstring>
-ContentViewCoreImpl::GetOriginalUrlForActiveNavigationEntry(JNIEnv* env,
- jobject obj) {
- NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
- if (entry == NULL)
- return ScopedJavaLocalRef<jstring>(env, NULL);
- return ConvertUTF8ToJavaString(env, entry->GetOriginalRequestURL().spec());
-}
-
long ContentViewCoreImpl::GetNativeImeAdapter(JNIEnv* env, jobject obj) {
RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
if (!rwhva)
@@ -1358,13 +1217,6 @@ void ContentViewCoreImpl::PostMessageToFrame(JNIEnv* env, jobject obj,
host->Send(new ViewMsg_PostMessageEvent(host->GetRoutingID(), params));
}
-
-bool ContentViewCoreImpl::GetUseDesktopUserAgent(
- JNIEnv* env, jobject obj) {
- NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
- return entry && entry->GetIsOverridingUserAgent();
-}
-
void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter,
int text_input_type,
const std::string& text,
@@ -1388,38 +1240,6 @@ void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter,
show_ime_if_needed, is_non_ime_change);
}
-void ContentViewCoreImpl::ClearSslPreferences(JNIEnv* env, jobject obj) {
- SSLHostState* state = SSLHostState::GetFor(
- web_contents_->GetController().GetBrowserContext());
- state->Clear();
-}
-
-void ContentViewCoreImpl::SetUseDesktopUserAgent(
- JNIEnv* env,
- jobject obj,
- jboolean enabled,
- jboolean reload_on_state_change) {
- if (GetUseDesktopUserAgent(env, obj) == enabled)
- return;
-
- // Make sure the navigation entry actually exists.
- NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry();
- if (!entry)
- return;
-
- // Set the flag in the NavigationEntry.
- entry->SetIsOverridingUserAgent(enabled);
-
- // Send the override to the renderer.
- if (reload_on_state_change) {
- // Reloading the page will send the override down as part of the
- // navigation IPC message.
- NavigationControllerImpl& controller =
- static_cast<NavigationControllerImpl&>(web_contents_->GetController());
- controller.ReloadOriginalRequestURL(false);
- }
-}
-
void ContentViewCoreImpl::SetAccessibilityEnabled(JNIEnv* env, jobject obj,
bool enabled) {
SetAccessibilityEnabledInternal(enabled);

Powered by Google App Engine
This is Rietveld 408576698