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

Side by Side Diff: chrome/browser/ui/android/page_info/page_info_popup_android.cc

Issue 2754383004: Rename WebsiteSettings code to PageInfo. (Closed)
Patch Set: Upload missing comment fix for WebSettingsUI -> PageInfoUI. Created 3 years, 9 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/ui/android/page_info/website_settings_popup_android.h" 5 #include "chrome/browser/ui/android/page_info/page_info_popup_android.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/stl_util.h" 10 #include "base/stl_util.h"
11 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h " 11 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h "
12 #include "chrome/browser/infobars/infobar_service.h" 12 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ssl/security_state_tab_helper.h" 14 #include "chrome/browser/ssl/security_state_tab_helper.h"
15 #include "chrome/browser/ui/page_info/website_settings.h" 15 #include "chrome/browser/ui/page_info/page_info.h"
16 #include "chrome/browser/ui/page_info/website_settings_ui.h" 16 #include "chrome/browser/ui/page_info/page_info_ui.h"
17 #include "components/content_settings/core/common/content_settings.h" 17 #include "components/content_settings/core/common/content_settings.h"
18 #include "components/content_settings/core/common/content_settings_types.h" 18 #include "components/content_settings/core/common/content_settings_types.h"
19 #include "components/security_state/core/security_state.h" 19 #include "components/security_state/core/security_state.h"
20 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
21 #include "content/public/browser/navigation_controller.h" 21 #include "content/public/browser/navigation_controller.h"
22 #include "content/public/browser/navigation_entry.h" 22 #include "content/public/browser/navigation_entry.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "jni/WebsiteSettingsPopup_jni.h" 24 #include "jni/PageInfoPopup_jni.h"
25 #include "url/origin.h" 25 #include "url/origin.h"
26 26
27 using base::android::ConvertUTF16ToJavaString; 27 using base::android::ConvertUTF16ToJavaString;
28 using base::android::ConvertUTF8ToJavaString; 28 using base::android::ConvertUTF8ToJavaString;
29 using base::android::JavaParamRef; 29 using base::android::JavaParamRef;
30 30
31 // static 31 // static
32 static jlong Init(JNIEnv* env, 32 static jlong Init(JNIEnv* env,
33 const JavaParamRef<jclass>& clazz, 33 const JavaParamRef<jclass>& clazz,
34 const JavaParamRef<jobject>& obj, 34 const JavaParamRef<jobject>& obj,
35 const JavaParamRef<jobject>& java_web_contents) { 35 const JavaParamRef<jobject>& java_web_contents) {
36 content::WebContents* web_contents = 36 content::WebContents* web_contents =
37 content::WebContents::FromJavaWebContents(java_web_contents); 37 content::WebContents::FromJavaWebContents(java_web_contents);
38 38
39 return reinterpret_cast<intptr_t>( 39 return reinterpret_cast<intptr_t>(
40 new WebsiteSettingsPopupAndroid(env, obj, web_contents)); 40 new PageInfoPopupAndroid(env, obj, web_contents));
41 } 41 }
42 42
43 WebsiteSettingsPopupAndroid::WebsiteSettingsPopupAndroid( 43 PageInfoPopupAndroid::PageInfoPopupAndroid(JNIEnv* env,
44 JNIEnv* env, 44 jobject java_page_info_pop,
45 jobject java_website_settings_pop, 45 content::WebContents* web_contents)
46 content::WebContents* web_contents)
47 : search_geolocation_service_(nullptr) { 46 : search_geolocation_service_(nullptr) {
48 // Important to use GetVisibleEntry to match what's showing in the omnibox. 47 // Important to use GetVisibleEntry to match what's showing in the omnibox.
49 content::NavigationEntry* nav_entry = 48 content::NavigationEntry* nav_entry =
50 web_contents->GetController().GetVisibleEntry(); 49 web_contents->GetController().GetVisibleEntry();
51 if (nav_entry == NULL) 50 if (nav_entry == NULL)
52 return; 51 return;
53 52
54 url_ = nav_entry->GetURL(); 53 url_ = nav_entry->GetURL();
55 54
56 popup_jobject_.Reset(env, java_website_settings_pop); 55 popup_jobject_.Reset(env, java_page_info_pop);
57 56
58 SecurityStateTabHelper* helper = 57 SecurityStateTabHelper* helper =
59 SecurityStateTabHelper::FromWebContents(web_contents); 58 SecurityStateTabHelper::FromWebContents(web_contents);
60 DCHECK(helper); 59 DCHECK(helper);
61 security_state::SecurityInfo security_info; 60 security_state::SecurityInfo security_info;
62 helper->GetSecurityInfo(&security_info); 61 helper->GetSecurityInfo(&security_info);
63 62
64 search_geolocation_service_ = 63 search_geolocation_service_ =
65 SearchGeolocationService::Factory::GetForBrowserContext( 64 SearchGeolocationService::Factory::GetForBrowserContext(
66 web_contents->GetBrowserContext()); 65 web_contents->GetBrowserContext());
67 66
68 presenter_.reset(new WebsiteSettings( 67 presenter_.reset(new PageInfo(
69 this, Profile::FromBrowserContext(web_contents->GetBrowserContext()), 68 this, Profile::FromBrowserContext(web_contents->GetBrowserContext()),
70 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, 69 TabSpecificContentSettings::FromWebContents(web_contents), web_contents,
71 nav_entry->GetURL(), security_info)); 70 nav_entry->GetURL(), security_info));
72 } 71 }
73 72
74 WebsiteSettingsPopupAndroid::~WebsiteSettingsPopupAndroid() {} 73 PageInfoPopupAndroid::~PageInfoPopupAndroid() {}
75 74
76 void WebsiteSettingsPopupAndroid::Destroy(JNIEnv* env, 75 void PageInfoPopupAndroid::Destroy(JNIEnv* env,
77 const JavaParamRef<jobject>& obj) { 76 const JavaParamRef<jobject>& obj) {
78 delete this; 77 delete this;
79 } 78 }
80 79
81 void WebsiteSettingsPopupAndroid::RecordWebsiteSettingsAction( 80 void PageInfoPopupAndroid::RecordPageInfoAction(
82 JNIEnv* env, 81 JNIEnv* env,
83 const JavaParamRef<jobject>& obj, 82 const JavaParamRef<jobject>& obj,
84 jint action) { 83 jint action) {
85 presenter_->RecordWebsiteSettingsAction( 84 presenter_->RecordPageInfoAction(
86 static_cast<WebsiteSettings::WebsiteSettingsAction>(action)); 85 static_cast<PageInfo::PageInfoAction>(action));
87 } 86 }
88 87
89 void WebsiteSettingsPopupAndroid::SetIdentityInfo( 88 void PageInfoPopupAndroid::SetIdentityInfo(const IdentityInfo& identity_info) {
90 const IdentityInfo& identity_info) {
91 JNIEnv* env = base::android::AttachCurrentThread(); 89 JNIEnv* env = base::android::AttachCurrentThread();
92 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = 90 std::unique_ptr<PageInfoUI::SecurityDescription> security_description =
93 identity_info.GetSecurityDescription(); 91 identity_info.GetSecurityDescription();
94 92
95 Java_WebsiteSettingsPopup_setSecurityDescription( 93 Java_PageInfoPopup_setSecurityDescription(
96 env, popup_jobject_, 94 env, popup_jobject_,
97 ConvertUTF16ToJavaString(env, security_description->summary), 95 ConvertUTF16ToJavaString(env, security_description->summary),
98 ConvertUTF16ToJavaString(env, security_description->details)); 96 ConvertUTF16ToJavaString(env, security_description->details));
99 } 97 }
100 98
101 void WebsiteSettingsPopupAndroid::SetCookieInfo( 99 void PageInfoPopupAndroid::SetCookieInfo(
102 const CookieInfoList& cookie_info_list) { 100 const CookieInfoList& cookie_info_list) {
103 NOTIMPLEMENTED(); 101 NOTIMPLEMENTED();
104 } 102 }
105 103
106 void WebsiteSettingsPopupAndroid::SetPermissionInfo( 104 void PageInfoPopupAndroid::SetPermissionInfo(
107 const PermissionInfoList& permission_info_list, 105 const PermissionInfoList& permission_info_list,
108 ChosenObjectInfoList chosen_object_info_list) { 106 ChosenObjectInfoList chosen_object_info_list) {
109 JNIEnv* env = base::android::AttachCurrentThread(); 107 JNIEnv* env = base::android::AttachCurrentThread();
110 108
111 // On Android, we only want to display a subset of the available options in a 109 // On Android, we only want to display a subset of the available options in a
112 // particular order, but only if their value is different from the default. 110 // particular order, but only if their value is different from the default.
113 std::vector<ContentSettingsType> permissions_to_display; 111 std::vector<ContentSettingsType> permissions_to_display;
114 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION); 112 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION);
115 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 113 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
116 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 114 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
(...skipping 20 matching lines...) Expand all
137 ? CONTENT_SETTING_ALLOW 135 ? CONTENT_SETTING_ALLOW
138 : CONTENT_SETTING_BLOCK; 136 : CONTENT_SETTING_BLOCK;
139 } 137 }
140 } 138 }
141 } 139 }
142 } 140 }
143 141
144 for (const auto& permission : permissions_to_display) { 142 for (const auto& permission : permissions_to_display) {
145 if (base::ContainsKey(user_specified_settings_to_display, permission)) { 143 if (base::ContainsKey(user_specified_settings_to_display, permission)) {
146 base::string16 setting_title = 144 base::string16 setting_title =
147 WebsiteSettingsUI::PermissionTypeToUIString(permission); 145 PageInfoUI::PermissionTypeToUIString(permission);
148 146
149 Java_WebsiteSettingsPopup_addPermissionSection( 147 Java_PageInfoPopup_addPermissionSection(
150 env, popup_jobject_, ConvertUTF16ToJavaString(env, setting_title), 148 env, popup_jobject_, ConvertUTF16ToJavaString(env, setting_title),
151 static_cast<jint>(permission), 149 static_cast<jint>(permission),
152 static_cast<jint>(user_specified_settings_to_display[permission])); 150 static_cast<jint>(user_specified_settings_to_display[permission]));
153 } 151 }
154 } 152 }
155 153
156 for (const auto& chosen_object : chosen_object_info_list) { 154 for (const auto& chosen_object : chosen_object_info_list) {
157 base::string16 object_title = 155 base::string16 object_title =
158 WebsiteSettingsUI::ChosenObjectToUIString(*chosen_object); 156 PageInfoUI::ChosenObjectToUIString(*chosen_object);
159 157
160 Java_WebsiteSettingsPopup_addPermissionSection( 158 Java_PageInfoPopup_addPermissionSection(
161 env, popup_jobject_, ConvertUTF16ToJavaString(env, object_title), 159 env, popup_jobject_, ConvertUTF16ToJavaString(env, object_title),
162 static_cast<jint>(chosen_object->ui_info.content_settings_type), 160 static_cast<jint>(chosen_object->ui_info.content_settings_type),
163 static_cast<jint>(CONTENT_SETTING_ALLOW)); 161 static_cast<jint>(CONTENT_SETTING_ALLOW));
164 } 162 }
165 163
166 Java_WebsiteSettingsPopup_updatePermissionDisplay(env, popup_jobject_); 164 Java_PageInfoPopup_updatePermissionDisplay(env, popup_jobject_);
167 } 165 }
168 166
169 // static 167 // static
170 bool WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid( 168 bool PageInfoPopupAndroid::RegisterPageInfoPopupAndroid(JNIEnv* env) {
171 JNIEnv* env) {
172 return RegisterNativesImpl(env); 169 return RegisterNativesImpl(env);
173 } 170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698