diff options
Diffstat (limited to 'content')
17 files changed, 192 insertions, 1 deletions
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index d9ac631..2236fa1 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -550,6 +550,12 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, OnFirstVisuallyNonEmptyPaint) + IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, + OnShowValidationMessage) + IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, + OnHideValidationMessage) + IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, + OnMoveValidationMessage) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() render_view_message_source_ = NULL; @@ -1601,6 +1607,26 @@ FrameTree* WebContentsImpl::GetFrameTree() { return &frame_tree_; } +void WebContentsImpl::OnShowValidationMessage( + const gfx::Rect& anchor_in_root_view, + const string16& main_text, + const string16& sub_text) { + if (delegate_) + delegate_->ShowValidationMessage( + this, anchor_in_root_view, main_text, sub_text); +} + +void WebContentsImpl::OnHideValidationMessage() { + if (delegate_) + delegate_->HideValidationMessage(this); +} + +void WebContentsImpl::OnMoveValidationMessage( + const gfx::Rect& anchor_in_root_view) { + if (delegate_) + delegate_->MoveValidationMessage(this, anchor_in_root_view); +} + void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) { if (browser_plugin_embedder_) browser_plugin_embedder_->DidSendScreenRects(); diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index e790f15..0db67f2 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -698,6 +698,12 @@ class CONTENT_EXPORT WebContentsImpl bool has_video, bool has_audio, bool is_playing); + void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view, + const string16& main_text, + const string16& sub_text); + void OnHideValidationMessage(); + void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view); + // Called by derived classes to indicate that we're no longer waiting for a // response. This won't actually update the throbber, but it will get picked diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 1c5a8a9..a3fdaae 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -2237,6 +2237,22 @@ IPC_MESSAGE_CONTROL0(ViewHostMsg_CancelVibration) IPC_MESSAGE_ROUTED1(ViewHostMsg_FocusedNodeTouched, bool /* editable */) +// Message sent from the renderer to the browser when an HTML form has failed +// validation constraints. +IPC_MESSAGE_ROUTED3(ViewHostMsg_ShowValidationMessage, + gfx::Rect /* anchor rectangle in root view coordinate */, + base::string16 /* validation message */, + base::string16 /* supplemental text */) + +// Message sent from the renderer to the browser when a HTML form validation +// message should be hidden from view. +IPC_MESSAGE_ROUTED0(ViewHostMsg_HideValidationMessage) + +// Message sent from the renderer to the browser when the suggested co-ordinates +// of the anchor for a HTML form validation message have changed. +IPC_MESSAGE_ROUTED1(ViewHostMsg_MoveValidationMessage, + gfx::Rect /* anchor rectangle in root view coordinate */) + #if defined(OS_ANDROID) // Response to ViewMsg_FindMatchRects. // diff --git a/content/public/android/java/res/drawable-hdpi/bubble.9.png b/content/public/android/java/res/drawable-hdpi/bubble.9.png Binary files differnew file mode 100644 index 0000000..905730f --- /dev/null +++ b/content/public/android/java/res/drawable-hdpi/bubble.9.png diff --git a/content/public/android/java/res/drawable-hdpi/bubble_arrow_up.png b/content/public/android/java/res/drawable-hdpi/bubble_arrow_up.png Binary files differnew file mode 100644 index 0000000..9f941a4 --- /dev/null +++ b/content/public/android/java/res/drawable-hdpi/bubble_arrow_up.png diff --git a/content/public/android/java/res/drawable-hdpi/pageinfo_warning_major.png b/content/public/android/java/res/drawable-hdpi/pageinfo_warning_major.png Binary files differnew file mode 100644 index 0000000..081668f --- /dev/null +++ b/content/public/android/java/res/drawable-hdpi/pageinfo_warning_major.png diff --git a/content/public/android/java/res/drawable-xhdpi/bubble.9.png b/content/public/android/java/res/drawable-xhdpi/bubble.9.png Binary files differnew file mode 100644 index 0000000..c5d2e8f --- /dev/null +++ b/content/public/android/java/res/drawable-xhdpi/bubble.9.png diff --git a/content/public/android/java/res/drawable-xhdpi/bubble_arrow_up.png b/content/public/android/java/res/drawable-xhdpi/bubble_arrow_up.png Binary files differnew file mode 100644 index 0000000..0ec744c --- /dev/null +++ b/content/public/android/java/res/drawable-xhdpi/bubble_arrow_up.png diff --git a/content/public/android/java/res/drawable-xhdpi/pageinfo_warning_major.png b/content/public/android/java/res/drawable-xhdpi/pageinfo_warning_major.png Binary files differnew file mode 100644 index 0000000..9b9e312 --- /dev/null +++ b/content/public/android/java/res/drawable-xhdpi/pageinfo_warning_major.png diff --git a/content/public/android/java/res/drawable/bubble.9.png b/content/public/android/java/res/drawable/bubble.9.png Binary files differnew file mode 100644 index 0000000..f3089cc --- /dev/null +++ b/content/public/android/java/res/drawable/bubble.9.png diff --git a/content/public/android/java/res/drawable/bubble_arrow_up.png b/content/public/android/java/res/drawable/bubble_arrow_up.png Binary files differnew file mode 100644 index 0000000..75d8e79 --- /dev/null +++ b/content/public/android/java/res/drawable/bubble_arrow_up.png diff --git a/content/public/android/java/res/drawable/pageinfo_warning_major.png b/content/public/android/java/res/drawable/pageinfo_warning_major.png Binary files differnew file mode 100644 index 0000000..82c9635 --- /dev/null +++ b/content/public/android/java/res/drawable/pageinfo_warning_major.png diff --git a/content/public/android/java/res/layout/validation_message_bubble.xml b/content/public/android/java/res/layout/validation_message_bubble.xml new file mode 100644 index 0000000..4e44be7 --- /dev/null +++ b/content/public/android/java/res/layout/validation_message_bubble.xml @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2013 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. +--> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="@drawable/bubble"> + + <LinearLayout + android:id="@+id/top_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignStart="@+id/icon_view" + android:layout_alignEnd="@+id/text_wrapper" + android:weightSum="1"> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="0.25" + android:visibility="invisible"/> + + <ImageView + android:id="@+id/arrow_image" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentStart="true" + android:layout_marginBottom="7dp" + android:src="@drawable/bubble_arrow_up" /> + + </LinearLayout> + + <ImageView + android:id="@id/icon_view" + android:layout_width="19dp" + android:layout_height="19dp" + android:layout_alignParentStart="true" + android:layout_below="@id/top_view" + android:layout_marginEnd="8dp" + android:src="@drawable/pageinfo_warning_major" /> + + <LinearLayout + android:id="@id/text_wrapper" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/top_view" + android:layout_toEndOf="@id/icon_view" + android:orientation="vertical"> + + <TextView + android:id="@+id/main_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxWidth="300dp" + android:textColor="@android:color/black" + android:textSize="16sp" /> + + <TextView + android:id="@+id/sub_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxWidth="300dp" + android:textColor="#444" + android:textSize="13sp" /> + + </LinearLayout> + +</RelativeLayout> diff --git a/content/public/android/java/resource_map/org/chromium/content/R.java b/content/public/android/java/resource_map/org/chromium/content/R.java index ac39779..fec2cea 100644 --- a/content/public/android/java/resource_map/org/chromium/content/R.java +++ b/content/public/android/java/resource_map/org/chromium/content/R.java @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2012 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. @@ -16,22 +16,28 @@ package org.chromium.content; * com.android.internal.R. */ public final class R { + /** Attributes */ public static final class attr { public static int select_dialog_multichoice; public static int select_dialog_singlechoice; } + /** Dimensions */ public static final class dimen { public static int link_preview_overlay_radius; } + /** Drawables */ public static final class drawable { public static int ondemand_overlay; } + /** id */ public static final class id { public static int ampm; + public static int arrow_image; public static int date_picker; public static int date_time_suggestion_value; public static int date_time_suggestion_label; public static int hour; + public static int main_text; public static int milli; public static int minute; public static int pickers; @@ -45,18 +51,23 @@ public final class R { public static int select_action_menu_paste; public static int select_action_menu_share; public static int select_action_menu_web_search; + public static int sub_text; public static int time_picker; public static int year; } + /** layouts */ public static final class layout { public static int date_time_picker_dialog; public static int date_time_suggestion; public static int two_field_date_picker; public static int multi_field_time_picker_dialog; + public static int validation_message_bubble; } + /** menus */ public static final class menu { public static int select_action_menu; } + /** strings */ public static final class string { public static int accessibility_content_view; public static int accessibility_date_picker_month; @@ -89,6 +100,7 @@ public final class R { public static int time_picker_dialog_title; public static int week_picker_dialog_title; } + /** styles */ public static final class style { public static int SelectPopupDialog; } diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 81faa6b..7f37194 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -451,6 +451,22 @@ class CONTENT_EXPORT WebContentsDelegate { virtual gfx::Size GetSizeForNewRenderView( const WebContents* web_contents) const; + // Notification that validation of a form displayed by the |web_contents| + // has failed. There can only be one message per |web_contents| at a time. + virtual void ShowValidationMessage(WebContents* web_contents, + const gfx::Rect& anchor_in_root_view, + const string16& main_text, + const string16& sub_text) {} + + // Notification that the delegate should hide any showing form validation + // message. + virtual void HideValidationMessage(WebContents* web_contents) {} + + // Notification that the form element that triggered the validation failure + // has moved. + virtual void MoveValidationMessage(WebContents* web_contents, + const gfx::Rect& anchor_in_root_view) {} + protected: virtual ~WebContentsDelegate(); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 82567ed..e8ba84a 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -15,6 +15,7 @@ #include "base/debug/alias.h" #include "base/debug/trace_event.h" #include "base/files/file_path.h" +#include "base/i18n/rtl.h" #include "base/json/json_writer.h" #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" @@ -2621,6 +2622,41 @@ bool RenderViewImpl::runModalBeforeUnloadDialog( return success; } +void RenderViewImpl::showValidationMessage( + const blink::WebRect& anchor_in_root_view, + const blink::WebString& main_text, + const blink::WebString& sub_text, + blink::WebTextDirection hint) { + base::string16 wrapped_main_text = main_text; + base::string16 wrapped_sub_text = sub_text; + if (hint == blink::WebTextDirectionLeftToRight) { + wrapped_main_text = + base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text); + if (!wrapped_sub_text.empty()) { + wrapped_sub_text = + base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text); + } + } else if (hint == blink::WebTextDirectionRightToLeft + && !base::i18n::IsRTL()) { + base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text); + if (!wrapped_sub_text.empty()) { + base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text); + } + } + Send(new ViewHostMsg_ShowValidationMessage( + routing_id(), anchor_in_root_view, wrapped_main_text, wrapped_sub_text)); +} + +void RenderViewImpl::hideValidationMessage() { + Send(new ViewHostMsg_HideValidationMessage(routing_id())); +} + +void RenderViewImpl::moveValidationMessage( + const blink::WebRect& anchor_in_root_view) { + Send(new ViewHostMsg_MoveValidationMessage(routing_id(), + anchor_in_root_view)); +} + void RenderViewImpl::showContextMenu( WebFrame* frame, const WebContextMenuData& data) { ContextMenuParams params = ContextMenuParamsBuilder::Build(data); diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index db72d1f..047e894 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -440,6 +440,14 @@ class CONTENT_EXPORT RenderViewImpl virtual bool runModalBeforeUnloadDialog(blink::WebFrame* frame, bool is_reload, const blink::WebString& message); + virtual void showValidationMessage(const blink::WebRect& anchor_in_root_view, + const blink::WebString& main_text, + const blink::WebString& sub_text, + blink::WebTextDirection hint) OVERRIDE; + virtual void hideValidationMessage() OVERRIDE; + virtual void moveValidationMessage( + const blink::WebRect& anchor_in_root_view) OVERRIDE; + // DEPRECATED virtual bool runModalBeforeUnloadDialog(blink::WebFrame* frame, const blink::WebString& message); |