Commit 97894ce1 authored by sashab's avatar sashab Committed by Commit bot

Add Permissions to the PageInfo dialog on Android

Add permissions dropdowns to the PageInfo dialog on Android,
which alter the content setting for the website currently
being visited. Also add a 'Copy URL' button and a 'Done'
button.

BUG=365528

Review URL: https://codereview.chromium.org/620983002

Cr-Commit-Position: refs/heads/master@{#300658}
parent 7b73f83a
...@@ -529,6 +529,26 @@ group("strings") { ...@@ -529,6 +529,26 @@ group("strings") {
if (is_android) { if (is_android) {
# GYP: //chrome/chrome.gyp:content_setting_java
java_cpp_enum("content_setting_javagen") {
sources = [
"../components/content_settings/core/common/content_settings.h"
]
outputs = [
"org/chromium/chrome/browser/ContentSetting.java",
]
}
# GYP: //chrome/chrome.gyp:content_settings_type_java
java_cpp_enum("content_settings_type_javagen") {
sources = [
"../components/content_settings/core/common/content_settings_types.h"
]
outputs = [
"org/chromium/chrome/browser/ContentSettingsType.java",
]
}
# GYP: //chrome/chrome.gyp:page_info_connection_type_java # GYP: //chrome/chrome.gyp:page_info_connection_type_java
java_cpp_enum("page_info_connection_type_javagen") { java_cpp_enum("page_info_connection_type_javagen") {
sources = [ sources = [
......
...@@ -107,6 +107,8 @@ android_library("chrome_java") { ...@@ -107,6 +107,8 @@ android_library("chrome_java") {
":tab_load_status_javagen", ":tab_load_status_javagen",
":chrome_version_srcjar", ":chrome_version_srcjar",
"//chrome:page_info_connection_type_javagen", "//chrome:page_info_connection_type_javagen",
"//chrome:content_setting_javagen",
"//chrome:content_settings_type_javagen",
] ]
DEPRECATED_java_in_dir = "java/src" DEPRECATED_java_in_dir = "java/src"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 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.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textColor="@color/website_settings_popup_permission_spinner_text"
android:textSize="@dimen/website_settings_popup_permission_spinner_text_size"
android:ellipsize="marquee" />
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 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.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="32dp"
android:paddingRight="20dp"
android:background="@drawable/website_settings_permission_spinner_item_background"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:singleLine="true"
android:textColor="@color/website_settings_popup_permission_spinner_text"
android:textSize="@dimen/website_settings_popup_permission_spinner_text_size" />
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 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.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- To achieve a single border along the bottom, draw a rectangle offset by
1dp in all dimensions but the bottom. -->
<item android:top="-1dp" android:right="-1dp" android:left="-1dp">
<shape android:shape="rectangle" >
<stroke android:width="1dip" android:color="#e5e5e5"/>
</shape>
</item>
<item><bitmap android:gravity="right" android:src="@drawable/page_info_arrow_down" /></item>
</layer-list>
...@@ -8,26 +8,111 @@ ...@@ -8,26 +8,111 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/website_settings_popup_background" android:background="#ffffff"
android:orientation="vertical" android:orientation="vertical" >
android:paddingBottom="@dimen/website_settings_margin_bottom"
android:paddingEnd="@dimen/website_settings_margin_sides" <LinearLayout
android:paddingStart="@dimen/website_settings_margin_sides"
android:paddingTop="@dimen/website_settings_margin_top" >
<TextView
android:id="@+id/website_settings_url"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/website_settings_margin_below_url" android:orientation="vertical"
android:textColor="@color/website_settings_popup_url" android:paddingEnd="@dimen/website_settings_popup_padding_sides"
android:textSize="@dimen/website_settings_url_title_size" /> android:paddingStart="@dimen/website_settings_popup_padding_sides" >
<TextView
android:id="@+id/website_settings_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="4dp"
android:paddingTop="16dp"
android:textColor="@color/website_settings_popup_url"
android:textSize="16dp"/>
<TextView
android:id="@+id/website_settings_connection_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="3dp"
android:paddingTop="12dp"
android:textColor="#444444"
android:textSize="14dp" />
<Button
android:id="@+id/website_settings_copy_url_button"
style="?android:attr/borderlessButtonStyle"
android:layout_gravity="end"
android:layout_width="wrap_content"
android:layout_height="@dimen/website_settings_popup_button_height"
android:layout_marginEnd="@dimen/website_settings_popup_button_margin_sides"
android:layout_marginStart="@dimen/website_settings_popup_button_margin_sides"
android:layout_marginBottom="8dp"
android:layout_marginTop="24dp"
android:paddingEnd="@dimen/website_settings_popup_button_padding_sides"
android:paddingStart="@dimen/website_settings_popup_button_padding_sides"
android:text="@string/page_info_copy_url_button"
android:textAllCaps="true"
android:textColor="#4184f3"
android:textSize="@dimen/website_settings_popup_button_text_size"
android:textStyle="bold" />
</LinearLayout>
<!-- Horizontal separator -->
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="#e7e7e7" />
<TextView <LinearLayout
android:id="@+id/website_settings_permission_message"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/website_settings_popup_text" android:orientation="vertical"
android:textSize="@dimen/website_settings_url_description_size" /> android:paddingStart="@dimen/website_settings_popup_padding_sides"
android:paddingEnd="@dimen/website_settings_popup_padding_sides" >
<LinearLayout
android:id="@+id/website_settings_permissions_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal"
android:paddingTop="16dp"
android:paddingBottom="16dp" >
<Button
android:id="@+id/website_settings_site_settings_button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="@dimen/website_settings_popup_button_height"
android:layout_marginEnd="@dimen/website_settings_popup_button_margin_sides"
android:layout_marginStart="@dimen/website_settings_popup_button_margin_sides"
android:paddingEnd="@dimen/website_settings_popup_button_padding_sides"
android:paddingStart="@dimen/website_settings_popup_button_padding_sides"
android:text="@string/page_info_site_settings_button"
android:textAllCaps="true"
android:textColor="@color/website_settings_popup_button_text"
android:textSize="@dimen/website_settings_popup_button_text_size"
android:textStyle="bold" />
<Button
android:id="@+id/website_settings_done_button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="@dimen/website_settings_popup_button_height"
android:layout_marginEnd="@dimen/website_settings_popup_button_margin_sides"
android:layout_marginStart="@dimen/website_settings_popup_button_margin_sides"
android:paddingEnd="@dimen/website_settings_popup_button_padding_sides"
android:paddingStart="@dimen/website_settings_popup_button_padding_sides"
android:text="@string/page_info_done_button"
android:textAllCaps="true"
android:textColor="@color/website_settings_popup_button_text"
android:textSize="@dimen/website_settings_popup_button_text_size"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="18dp" >
<ImageView
android:id="@+id/website_settings_permission_icon"
android:layout_width="@dimen/website_settings_popup_permission_icon_size"
android:layout_height="@dimen/website_settings_popup_permission_icon_size" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp" >
<TextView
android:id="@+id/website_settings_permission_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#444444"
android:textSize="14dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/website_settings_permission_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
...@@ -34,14 +34,14 @@ ...@@ -34,14 +34,14 @@
<color name="website_settings_popup_reset_cert_decisions_button">#000000</color> <color name="website_settings_popup_reset_cert_decisions_button">#000000</color>
<!-- Website Settings Popup colors --> <!-- Website Settings Popup colors -->
<color name="website_settings_popup_background">#f2f2f2</color> <color name="website_settings_popup_button_text">#444444</color>
<color name="website_settings_popup_text">#333333</color> <color name="website_settings_popup_url">#848484</color>
<color name="website_settings_popup_url">#666666</color> <color name="website_settings_popup_url_domain">#444444</color>
<color name="website_settings_popup_url_domain">#333333</color>
<color name="website_settings_popup_url_scheme_http">#666666</color> <color name="website_settings_popup_url_scheme_http">#666666</color>
<color name="website_settings_popup_url_scheme_https">#1ac222</color> <color name="website_settings_popup_url_scheme_https">#1ac222</color>
<color name="website_settings_popup_url_scheme_mixed">#eba200</color> <color name="website_settings_popup_url_scheme_mixed">#f2a600</color>
<color name="website_settings_popup_url_scheme_broken">#db4437</color> <color name="website_settings_popup_url_scheme_broken">#db4437</color>
<color name="website_settings_popup_permission_spinner_text">#646464</color>
<!-- Distilled Page Prefs colors --> <!-- Distilled Page Prefs colors -->
<color name="distilled_page_prefs_selected">#999999</color> <color name="distilled_page_prefs_selected">#999999</color>
......
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
<dimen name="certificate_viewer_padding_thin">16dp</dimen> <dimen name="certificate_viewer_padding_thin">16dp</dimen>
<!-- Website Settings Popup Dimensions --> <!-- Website Settings Popup Dimensions -->
<dimen name="website_settings_margin_top">16dp</dimen> <dimen name="website_settings_popup_padding_sides">16dp</dimen>
<dimen name="website_settings_margin_sides">16dp</dimen> <dimen name="website_settings_popup_button_text_size">14dp</dimen>
<dimen name="website_settings_margin_bottom">18dp</dimen> <dimen name="website_settings_popup_button_height">36dp</dimen>
<dimen name="website_settings_margin_below_url">10dp</dimen> <dimen name="website_settings_popup_button_padding_sides">8dp</dimen>
<dimen name="website_settings_url_title_size">16dp</dimen> <dimen name="website_settings_popup_button_margin_sides">4dp</dimen>
<dimen name="website_settings_url_description_size">12dp</dimen> <dimen name="website_settings_popup_permission_icon_size">24dp</dimen>
<dimen name="website_settings_popup_permission_spinner_text_size">16dp</dimen>
<!-- Accessibility tab switcher --> <!-- Accessibility tab switcher -->
<dimen name="accessibility_tab_height">65dp</dimen> <dimen name="accessibility_tab_height">65dp</dimen>
......
...@@ -411,6 +411,41 @@ You are signing in with a managed account and giving its administrator control o ...@@ -411,6 +411,41 @@ You are signing in with a managed account and giving its administrator control o
Add to homescreen Add to homescreen
</message> </message>
<!-- WebsiteSettingsPopup (PageInfo dialog) -->
<message name="IDS_PAGE_INFO_COPY_URL_BUTTON" desc="Text in the button that copies the URL to the clipboard.">
Copy URL
</message>
<message name="IDS_PAGE_INFO_SITE_SETTINGS_BUTTON" desc="Text in the button that opens a website's Site Settings from the Page Info dialog.">
Site Settings
</message>
<message name="IDS_PAGE_INFO_DONE_BUTTON" desc="Text in the button that closes the Page Info dialog.">
Done
</message>
<message name="IDS_PAGE_INFO_PERMISSION_ALLOW" desc="The label used in the permissions dropdowns in the Page Info dialog on mobile for the option that grants a permission.">
Allow
</message>
<message name="IDS_PAGE_INFO_PERMISSION_BLOCK" desc="The label used in the permissions dropdowns in the Page Info dialog on mobile for the option that denies a permission.">
Block
</message>
<message name="IDS_PAGE_INFO_CONNECTION_HTTPS" desc="Message to display in the page info bubble when the connection is private (HTTPS).">
Your connection to this site is private.
</message>
<message name="IDS_PAGE_INFO_CONNECTION_HTTP" desc="Message to display in the page info bubble when the connection is not private (HTTP).">
Your connection to this site is not private.
</message>
<message name="IDS_PAGE_INFO_CONNECTION_MIXED" desc="Message to display in the page info bubble when the main connection is private, but there is content on the page that is not private.">
Your connection to this site is private, but someone on the network might be able to change the look of the page.
</message>
<message name="IDS_PAGE_INFO_CONNECTION_BROKEN_LEADING_TEXT" desc="Message to display highlighted red in the page info bubble when the connection is insecure because the HTTPS certificate is invalid.">
Your connection to this site is not private.
</message>
<message name="IDS_PAGE_INFO_CONNECTION_BROKEN_FOLLOWING_TEXT" desc="Message to display after a 'Your connection to this site is not private' message' in the page info bubble when the connection is insecure because the HTTPS certificate is invalid.">
Attackers might be trying to steal your information (for example, photos, passwords, messages and credit cards) from <ph name="DOMAIN_NAME">%1$s<ex>google.com</ex></ph>.
</message>
<message name="IDS_PAGE_INFO_CONNECTION_INTERNAL_PAGE" desc="Message to display in the page info bubble when the page is an internal Chrome page (e.g. the bookmarks page, or about:blank).">
You are viewing a secure Google Chrome page.
</message>
<!-- Network prediction internal values --> <!-- Network prediction internal values -->
<message name="IDS_NEVER_PREFETCH_BANDWIDTH_ENTRY" desc="Option to always disable the prefetching of web pages. [CHAR-LIMIT=16]"> <message name="IDS_NEVER_PREFETCH_BANDWIDTH_ENTRY" desc="Option to always disable the prefetching of web pages. [CHAR-LIMIT=16]">
Never Never
...@@ -421,6 +456,7 @@ You are signing in with a managed account and giving its administrator control o ...@@ -421,6 +456,7 @@ You are signing in with a managed account and giving its administrator control o
<message name="IDS_ALWAYS_PREFETCH_BANDWIDTH_ENTRY" desc="Option to always prefetch web pages regardless of connection. [CHAR-LIMIT=16]"> <message name="IDS_ALWAYS_PREFETCH_BANDWIDTH_ENTRY" desc="Option to always prefetch web pages regardless of connection. [CHAR-LIMIT=16]">
Always Always
</message> </message>
</messages> </messages>
</release> </release>
</grit> </grit>
...@@ -9431,17 +9431,6 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -9431,17 +9431,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
</message> </message>
</if> </if>
<!-- Page Info Bubble -->
<message name="IDS_PAGE_INFO_ENCRYPTED_CONNECTION_SUMMARY_TEXT" desc="Message to display in the page info bubble when the connection is private.">
Your connection to this site is private.
</message>
<message name="IDS_PAGE_INFO_UNENCRYPTED_CONNECTION_SUMMARY_TEXT" desc="Message to display in the page info bubble when the connection is not private.">
Your connection to this site is not private.
</message>
<message name="IDS_PAGE_INFO_MIXED_CONTENT_CONNECTION_SUMMARY_TEXT" desc="Message to display in the page info bubble when the connection is private, but someone on the network might be able to change the look of the page (there is content on the page that is not private).">
Your connection to this site is private (HTTPS), but someone on the network might be able to change the look of the page.
</message>
<!-- Critical Notification Bubble --> <!-- Critical Notification Bubble -->
<message name="IDS_CRITICAL_NOTIFICATION_HEADLINE" desc="The headline for the critical notification"> <message name="IDS_CRITICAL_NOTIFICATION_HEADLINE" desc="The headline for the critical notification">
<ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> will restart in <ph name="SECONDS">$2<ex>10</ex></ph> seconds. <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> will restart in <ph name="SECONDS">$2<ex>10</ex></ph> seconds.
......
...@@ -11,12 +11,14 @@ ...@@ -11,12 +11,14 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/website_settings/website_settings.h" #include "chrome/browser/ui/website_settings/website_settings.h"
#include "chrome/browser/ui/website_settings/website_settings_ui.h" #include "chrome/browser/ui/website_settings/website_settings_ui.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/content_settings_types.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/cert_store.h" #include "content/public/browser/cert_store.h"
#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "jni/WebsiteSettingsPopup_jni.h" #include "jni/WebsiteSettingsPopup_jni.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -65,51 +67,25 @@ void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) { ...@@ -65,51 +67,25 @@ void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, jobject obj) {
delete this; delete this;
} }
void WebsiteSettingsPopupAndroid::OnPermissionSettingChanged(JNIEnv* env,
jobject obj,
jint type,
jint setting) {
ContentSettingsType content_setting_type =
static_cast<ContentSettingsType>(type);
ContentSetting content_setting = static_cast<ContentSetting>(setting);
presenter_->OnSitePermissionChanged(content_setting_type, content_setting);
}
void WebsiteSettingsPopupAndroid::SetIdentityInfo( void WebsiteSettingsPopupAndroid::SetIdentityInfo(
const IdentityInfo& identity_info) { const IdentityInfo& identity_info) {
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
enum PageInfoConnectionType connection_type = CONNECTION_UNKNOWN; Java_WebsiteSettingsPopup_updatePageDetails(
switch (identity_info.connection_status) {
case WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN:
connection_type = CONNECTION_UNKNOWN;
break;
case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED:
connection_type = CONNECTION_ENCRYPTED;
break;
case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_CONTENT:
connection_type = CONNECTION_MIXED_CONTENT;
break;
case WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED:
connection_type = CONNECTION_UNENCRYPTED;
break;
case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR:
connection_type = CONNECTION_ENCRYPTED_ERROR;
break;
case WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE:
connection_type = CONNECTION_INTERNAL_PAGE;
break;
default:
NOTREACHED();
break;
}
Java_WebsiteSettingsPopup_setURLTitle(
env, env,
popup_jobject_.obj(), popup_jobject_.obj(),
ConvertUTF8ToJavaString(env, url_.scheme()).obj(), identity_info.connection_status ==
ConvertUTF8ToJavaString(env, url_.host()).obj(), WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE);
ConvertUTF8ToJavaString(env, url_.path()).obj(),
static_cast<jint>(connection_type));
Java_WebsiteSettingsPopup_setConnectionMessage(
env,
popup_jobject_.obj(),
ConvertUTF16ToJavaString(
env,
l10n_util::GetStringUTF16(
WebsiteSettingsUI::GetConnectionSummaryMessageID(
identity_info.connection_status))).obj());
Java_WebsiteSettingsPopup_showDialog(env, popup_jobject_.obj()); Java_WebsiteSettingsPopup_showDialog(env, popup_jobject_.obj());
} }
...@@ -121,7 +97,43 @@ void WebsiteSettingsPopupAndroid::SetCookieInfo( ...@@ -121,7 +97,43 @@ void WebsiteSettingsPopupAndroid::SetCookieInfo(
void WebsiteSettingsPopupAndroid::SetPermissionInfo( void WebsiteSettingsPopupAndroid::SetPermissionInfo(
const PermissionInfoList& permission_info_list) { const PermissionInfoList& permission_info_list) {
NOTIMPLEMENTED(); JNIEnv* env = base::android::AttachCurrentThread();
// On Android, we only want to display a subset of the available options in a
// particular order, but only if their value is different from the default.
std::vector<ContentSettingsType> permissions_to_display;
permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION);
permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM);
permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_IMAGES);
permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_JAVASCRIPT);
permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_POPUPS);
std::map<ContentSettingsType, ContentSetting>
user_specified_settings_to_display;
for (const auto& permission : permission_info_list) {
if (std::find(permissions_to_display.begin(),
permissions_to_display.end(),
permission.type) != permissions_to_display.end() &&
permission.setting != CONTENT_SETTING_DEFAULT) {
user_specified_settings_to_display[permission.type] = permission.setting;
}
}
for (const auto& permission : permissions_to_display) {
if (ContainsKey(user_specified_settings_to_display, permission)) {
base::string16 setting_title =
WebsiteSettingsUI::PermissionTypeToUIString(permission);
Java_WebsiteSettingsPopup_addPermissionSection(
env,
popup_jobject_.obj(),
ConvertUTF16ToJavaString(env, setting_title).obj(),
static_cast<jint>(permission),
static_cast<jint>(user_specified_settings_to_display[permission]));
}
}
} }
void WebsiteSettingsPopupAndroid::SetSelectedTab( void WebsiteSettingsPopupAndroid::SetSelectedTab(
......
...@@ -35,6 +35,10 @@ class WebsiteSettingsPopupAndroid : public WebsiteSettingsUI { ...@@ -35,6 +35,10 @@ class WebsiteSettingsPopupAndroid : public WebsiteSettingsUI {
content::WebContents* web_contents); content::WebContents* web_contents);
virtual ~WebsiteSettingsPopupAndroid(); virtual ~WebsiteSettingsPopupAndroid();
void Destroy(JNIEnv* env, jobject obj); void Destroy(JNIEnv* env, jobject obj);
void OnPermissionSettingChanged(JNIEnv* env,
jobject obj,
jint type,
jint setting);
// WebsiteSettingsUI implementations. // WebsiteSettingsUI implementations.
virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) override; virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) override;
......
...@@ -337,7 +337,13 @@ void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() { ...@@ -337,7 +337,13 @@ void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() {
void WebsiteSettings::Init(Profile* profile, void WebsiteSettings::Init(Profile* profile,
const GURL& url, const GURL& url,
const content::SSLStatus& ssl) { const content::SSLStatus& ssl) {
if (url.SchemeIs(content::kChromeUIScheme)) { bool isChromeUINativeScheme = false;
#if defined(OS_ANDROID)
isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
#endif
if (url.SchemeIs(content::kChromeUIScheme) ||
url.SchemeIs(url::kAboutScheme) || isChromeUINativeScheme) {
site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
site_identity_details_ = site_identity_details_ =
l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
......
...@@ -257,6 +257,7 @@ int WebsiteSettingsUI::GetIdentityIconID( ...@@ -257,6 +257,7 @@ int WebsiteSettingsUI::GetIdentityIconID(
int resource_id = IDR_PAGEINFO_INFO; int resource_id = IDR_PAGEINFO_INFO;
switch (status) { switch (status) {
case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN: case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN:
case WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE:
break; break;
case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: case WebsiteSettings::SITE_IDENTITY_STATUS_CERT:
case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT:
...@@ -297,6 +298,7 @@ int WebsiteSettingsUI::GetConnectionIconID( ...@@ -297,6 +298,7 @@ int WebsiteSettingsUI::GetConnectionIconID(
int resource_id = IDR_PAGEINFO_INFO; int resource_id = IDR_PAGEINFO_INFO;
switch (status) { switch (status) {
case WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN: case WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN:
case WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE:
break; break;
case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED: case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED:
resource_id = IDR_PAGEINFO_GOOD; resource_id = IDR_PAGEINFO_GOOD;
...@@ -337,25 +339,3 @@ const gfx::Image& WebsiteSettingsUI::GetFirstVisitIcon( ...@@ -337,25 +339,3 @@ const gfx::Image& WebsiteSettingsUI::GetFirstVisitIcon(
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ResourceBundle& rb = ResourceBundle::GetSharedInstance();
return rb.GetNativeImageNamed(GetFirstVisitIconID(first_visit)); return rb.GetNativeImageNamed(GetFirstVisitIconID(first_visit));
} }
// static
int WebsiteSettingsUI::GetConnectionSummaryMessageID(
WebsiteSettings::SiteConnectionStatus status) {
switch (status) {
case WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN:
return IDS_PAGE_INFO_UNENCRYPTED_CONNECTION_SUMMARY_TEXT;
case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED:
return IDS_PAGE_INFO_ENCRYPTED_CONNECTION_SUMMARY_TEXT;
case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_CONTENT:
return IDS_PAGE_INFO_MIXED_CONTENT_CONNECTION_SUMMARY_TEXT;
case WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED:
return IDS_PAGE_INFO_UNENCRYPTED_CONNECTION_SUMMARY_TEXT;
case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR:
return IDS_PAGE_INFO_UNENCRYPTED_CONNECTION_SUMMARY_TEXT;
case WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE:
return IDS_PAGE_INFO_INTERNAL_PAGE;
default:
NOTREACHED();
return 0;
}
}
...@@ -154,10 +154,6 @@ class WebsiteSettingsUI { ...@@ -154,10 +154,6 @@ class WebsiteSettingsUI {
// Returns the icon to show along with the first visit information. // Returns the icon to show along with the first visit information.
static const gfx::Image& GetFirstVisitIcon(const base::string16& first_visit); static const gfx::Image& GetFirstVisitIcon(const base::string16& first_visit);
// Returns the ID of a short message for the given connection |status|.
static int GetConnectionSummaryMessageID(
WebsiteSettings::SiteConnectionStatus status);
// Sets cookie information. // Sets cookie information.
virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0; virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0;
......
...@@ -118,6 +118,8 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness { ...@@ -118,6 +118,8 @@ class WebsiteSettingsTest : public ChromeRenderViewHostTestHarness {
EXPECT_CALL(*mock_ui, SetFirstVisit(base::string16())); EXPECT_CALL(*mock_ui, SetFirstVisit(base::string16()));
} }
void SetURL(std::string url) { url_ = GURL(url); }
const GURL& url() const { return url_; } const GURL& url() const { return url_; }
MockCertStore* cert_store() { return &cert_store_; } MockCertStore* cert_store() { return &cert_store_; }
int cert_id() { return cert_id_; } int cert_id() { return cert_id_; }
...@@ -391,3 +393,23 @@ TEST_F(WebsiteSettingsTest, ShowInfoBar) { ...@@ -391,3 +393,23 @@ TEST_F(WebsiteSettingsTest, ShowInfoBar) {
infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0)); infobar_service()->RemoveInfoBar(infobar_service()->infobar_at(0));
} }
TEST_F(WebsiteSettingsTest, AboutBlankPage) {
SetURL("about:blank");
SetDefaultUIExpectations(mock_ui());
EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE,
website_settings()->site_connection_status());
EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE,
website_settings()->site_identity_status());
EXPECT_EQ(base::string16(), website_settings()->organization_name());
}
TEST_F(WebsiteSettingsTest, InternalPage) {
SetURL("chrome://bookmarks");
SetDefaultUIExpectations(mock_ui());
EXPECT_EQ(WebsiteSettings::SITE_CONNECTION_STATUS_INTERNAL_PAGE,
website_settings()->site_connection_status());
EXPECT_EQ(WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE,
website_settings()->site_identity_status());
EXPECT_EQ(base::string16(), website_settings()->organization_name());
}
...@@ -587,6 +587,8 @@ ...@@ -587,6 +587,8 @@
'chrome_strings_grd', 'chrome_strings_grd',
'chrome_version_java', 'chrome_version_java',
'profile_account_management_metrics_java', 'profile_account_management_metrics_java',
'content_setting_java',
'content_settings_type_java',
'page_info_connection_type_java', 'page_info_connection_type_java',
'profile_sync_service_model_type_selection_java', 'profile_sync_service_model_type_selection_java',
'resource_id_java', 'resource_id_java',
...@@ -631,6 +633,24 @@ ...@@ -631,6 +633,24 @@
'../build/java_strings_grd.gypi', '../build/java_strings_grd.gypi',
], ],
}, },
{
# GN: //chrome:content_setting_javagen
'target_name': 'content_setting_java',
'type': 'none',
'variables': {
'source_file': '../components/content_settings/core/common/content_settings.h',
},
'includes': [ '../build/android/java_cpp_enum.gypi' ],
},
{
# GN: //chrome:content_settings_type_javagen
'target_name': 'content_settings_type_java',
'type': 'none',
'variables': {
'source_file': '../components/content_settings/core/common/content_settings_types.h',
},
'includes': [ '../build/android/java_cpp_enum.gypi' ],
},
{ {
# GN: //chrome:page_info_connection_type_javagen # GN: //chrome:page_info_connection_type_javagen
'target_name': 'page_info_connection_type_java', 'target_name': 'page_info_connection_type_java',
......
...@@ -96,6 +96,7 @@ const char kChromeUIVersionURL[] = "chrome://version/"; ...@@ -96,6 +96,7 @@ const char kChromeUIVersionURL[] = "chrome://version/";
const char kChromeUIVoiceSearchURL[] = "chrome://voicesearch/"; const char kChromeUIVoiceSearchURL[] = "chrome://voicesearch/";
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
const char kChromeUINativeScheme[] = "chrome-native";
const char kChromeUINativeNewTabURL[] = "chrome-native://newtab/"; const char kChromeUINativeNewTabURL[] = "chrome-native://newtab/";
const char kChromeUINativeBookmarksURL[] = "chrome-native://bookmarks/"; const char kChromeUINativeBookmarksURL[] = "chrome-native://bookmarks/";
const char kChromeUINativeRecentTabsURL[] = "chrome-native://recent-tabs/"; const char kChromeUINativeRecentTabsURL[] = "chrome-native://recent-tabs/";
......
...@@ -89,6 +89,7 @@ extern const char kChromeUIVersionURL[]; ...@@ -89,6 +89,7 @@ extern const char kChromeUIVersionURL[];
extern const char kChromeUIVoiceSearchURL[]; extern const char kChromeUIVoiceSearchURL[];
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
extern const char kChromeUINativeScheme[];
extern const char kChromeUINativeNewTabURL[]; extern const char kChromeUINativeNewTabURL[];
extern const char kChromeUINativeBookmarksURL[]; extern const char kChromeUINativeBookmarksURL[];
extern const char kChromeUINativeRecentTabsURL[]; extern const char kChromeUINativeRecentTabsURL[];
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
// Different settings that can be assigned for a particular content type. We // Different settings that can be assigned for a particular content type. We
// give the user the ability to set these on a global and per-origin basis. // give the user the ability to set these on a global and per-origin basis.
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser
enum ContentSetting { enum ContentSetting {
CONTENT_SETTING_DEFAULT = 0, CONTENT_SETTING_DEFAULT = 0,
CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW,
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
// A particular type of content to care about. We give the user various types // A particular type of content to care about. We give the user various types
// of controls over each of these. // of controls over each of these.
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser
enum ContentSettingsType { enum ContentSettingsType {
// "DEFAULT" is only used as an argument to the Content Settings Window // "DEFAULT" is only used as an argument to the Content Settings Window
// opener; there it means "whatever was last shown". // opener; there it means "whatever was last shown".
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment