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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc

Issue 11488009: Add content settings page action for Pepper broker authorization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years 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 | Annotate | Revision Log
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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 url, 191 url,
192 CONTENT_SETTINGS_TYPE_PLUGINS, 192 CONTENT_SETTINGS_TYPE_PLUGINS,
193 fooPlugin)); 193 fooPlugin));
194 EXPECT_EQ(CONTENT_SETTING_ALLOW, 194 EXPECT_EQ(CONTENT_SETTING_ALLOW,
195 map->GetContentSetting(url, 195 map->GetContentSetting(url,
196 url, 196 url,
197 CONTENT_SETTINGS_TYPE_PLUGINS, 197 CONTENT_SETTINGS_TYPE_PLUGINS,
198 barPlugin)); 198 barPlugin));
199 } 199 }
200 200
201 TEST_F(ContentSettingBubbleModelTest, PepperBroker) {
202 TabSpecificContentSettings* content_settings =
203 TabSpecificContentSettings::FromWebContents(web_contents());
204 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
205 std::string());
206
207 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
208 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
209 NULL, web_contents(), profile(),
210 CONTENT_SETTINGS_TYPE_PPAPI_BROKER));
211 const ContentSettingBubbleModel::BubbleContent& bubble_content =
212 content_setting_bubble_model->bubble_content();
213
214 std::string title = bubble_content.title;
215 EXPECT_FALSE(title.empty());
216 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size());
217 std::string radio1 = bubble_content.radio_group.radio_items[0];
218 std::string radio2 = bubble_content.radio_group.radio_items[1];
219 EXPECT_FALSE(bubble_content.custom_link_enabled);
220 EXPECT_FALSE(bubble_content.manage_link.empty());
221
222 content_settings->ClearBlockedContentSettingsExceptForCookies();
223 content_settings->OnContentAccessed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
224 content_setting_bubble_model.reset(
225 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
226 NULL, web_contents(), profile(),
227 CONTENT_SETTINGS_TYPE_PPAPI_BROKER));
228 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 =
229 content_setting_bubble_model->bubble_content();
230
231 EXPECT_FALSE(bubble_content_2.title.empty());
232 EXPECT_NE(title, bubble_content_2.title);
233 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size());
234 EXPECT_NE(radio1, bubble_content_2.radio_group.radio_items[0]);
235 EXPECT_NE(radio2, bubble_content_2.radio_group.radio_items[1]);
236 EXPECT_FALSE(bubble_content_2.custom_link_enabled);
237 EXPECT_FALSE(bubble_content_2.manage_link.empty());
238 }
239
201 TEST_F(ContentSettingBubbleModelTest, Geolocation) { 240 TEST_F(ContentSettingBubbleModelTest, Geolocation) {
202 const GURL page_url("http://toplevel.example/"); 241 const GURL page_url("http://toplevel.example/");
203 const GURL frame1_url("http://host1.example/"); 242 const GURL frame1_url("http://host1.example/");
204 const GURL frame2_url("http://host2.example:999/"); 243 const GURL frame2_url("http://host2.example:999/");
205 244
206 NavigateAndCommit(page_url); 245 NavigateAndCommit(page_url);
207 TabSpecificContentSettings* content_settings = 246 TabSpecificContentSettings* content_settings =
208 TabSpecificContentSettings::FromWebContents(web_contents()); 247 TabSpecificContentSettings::FromWebContents(web_contents());
209 248
210 // One permitted frame, but not in the content map: requires reload. 249 // One permitted frame, but not in the content map: requires reload.
(...skipping 22 matching lines...) Expand all
233 272
234 // Change the default to block: offer a clear link for the persisted frame 1. 273 // Change the default to block: offer a clear link for the persisted frame 1.
235 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 274 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
236 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK); 275 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK);
237 CheckGeolocationBubble(2, true, false); 276 CheckGeolocationBubble(2, true, false);
238 } 277 }
239 278
240 TEST_F(ContentSettingBubbleModelTest, FileURL) { 279 TEST_F(ContentSettingBubbleModelTest, FileURL) {
241 std::string file_url("file:///tmp/test.html"); 280 std::string file_url("file:///tmp/test.html");
242 NavigateAndCommit(GURL(file_url)); 281 NavigateAndCommit(GURL(file_url));
282 TabSpecificContentSettings::FromWebContents(web_contents())->OnContentBlocked(
283 CONTENT_SETTINGS_TYPE_IMAGES, std::string());
243 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( 284 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
244 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 285 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
245 NULL, web_contents(), profile(), 286 NULL, web_contents(), profile(),
246 CONTENT_SETTINGS_TYPE_IMAGES)); 287 CONTENT_SETTINGS_TYPE_IMAGES));
247 std::string title = 288 std::string title =
248 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; 289 content_setting_bubble_model->bubble_content().radio_group.radio_items[0];
249 ASSERT_NE(std::string::npos, title.find(file_url)); 290 ASSERT_NE(std::string::npos, title.find(file_url));
250 } 291 }
251 292
252 TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) { 293 TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 ProtocolHandler handler = registry.GetHandlerFor("mailto"); 402 ProtocolHandler handler = registry.GetHandlerFor("mailto");
362 ASSERT_FALSE(handler.IsEmpty()); 403 ASSERT_FALSE(handler.IsEmpty());
363 EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title()); 404 EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title());
364 EXPECT_EQ(CONTENT_SETTING_ALLOW, 405 EXPECT_EQ(CONTENT_SETTING_ALLOW,
365 content_settings->pending_protocol_handler_setting()); 406 content_settings->pending_protocol_handler_setting());
366 EXPECT_FALSE(registry.IsIgnored(test_handler)); 407 EXPECT_FALSE(registry.IsIgnored(test_handler));
367 } 408 }
368 409
369 registry.Shutdown(); 410 registry.Shutdown();
370 } 411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698