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

Unified Diff: chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc

Issue 10584042: Bring up a content settings icon for ungestured registerProtocolHandler call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make windows happy Created 8 years, 6 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: chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
index 9ca8d28fc5fe3c30b46e6a65f13b7c36df506232..d1fb1551b2a74eca43a10d48437f8cf77fdf44d1 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
@@ -4,13 +4,16 @@
#include "base/auto_reset.h"
#include "base/command_line.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tab_contents/test_tab_contents.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/content_settings.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_browser_thread.h"
@@ -220,3 +223,100 @@ TEST_F(ContentSettingBubbleModelTest, FileURL) {
content_setting_bubble_model->bubble_content().radio_group.radio_items[0];
ASSERT_NE(std::string::npos, title.find(file_url));
}
+
+TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) {
+ const GURL page_url("http://toplevel.example/");
+ NavigateAndCommit(page_url);
+ TabSpecificContentSettings* content_settings =
+ tab_contents()->content_settings();
+ content_settings->SetPendingProtocolHandler(
+ ProtocolHandler::CreateProtocolHandler(
+ "mailto", GURL("http://www.toplevel.example/"),
Peter Kasting 2012/06/25 23:55:30 Nit: If you're going to combine args on the same l
Greg Billock 2012/06/26 19:17:04 Done, but it doesn't always fit. :-(
+ ASCIIToUTF16("Handler")));
+
+ scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
+ ContentSettingBubbleModel::CreateContentSettingBubbleModel(
+ NULL, tab_contents(), profile(),
+ CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER));
+ const ContentSettingBubbleModel::BubbleContent& bubble_content =
+ content_setting_bubble_model->bubble_content();
+ EXPECT_FALSE(bubble_content.title.empty());
+ EXPECT_FALSE(bubble_content.radio_group.radio_items.empty());
+ EXPECT_TRUE(bubble_content.popup_items.empty());
+ EXPECT_EQ(0U, bubble_content.domain_lists.size());
Peter Kasting 2012/06/25 23:55:30 Nit: Why not _TRUE(...empty()) here too?
Bernhard Bauer 2012/06/26 09:08:34 An advantage of this version is that the error mes
Peter Kasting 2012/06/26 17:18:22 I know, but several other things here (radio_items
Greg Billock 2012/06/26 19:17:04 Done.
+ EXPECT_TRUE(bubble_content.custom_link.empty());
+ EXPECT_FALSE(bubble_content.custom_link_enabled);
+ EXPECT_FALSE(bubble_content.manage_link.empty());
+}
+
+TEST_F(ContentSettingBubbleModelTest, RPHAllow) {
+ profile()->CreateProtocolHandlerRegistry();
+
+ const GURL page_url("http://toplevel.example/");
+ NavigateAndCommit(page_url);
+ TabSpecificContentSettings* content_settings =
+ tab_contents()->content_settings();
+ ProtocolHandler test_handler = ProtocolHandler::CreateProtocolHandler(
+ "mailto", GURL("http://www.toplevel.example/"),
+ ASCIIToUTF16("Handler"));
+ content_settings->SetPendingProtocolHandler(test_handler);
+
+ scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
+ ContentSettingBubbleModel::CreateContentSettingBubbleModel(
+ NULL, tab_contents(), profile(),
+ CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER));
+
+ {
+ ProtocolHandler handler =
+ profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto");
+ EXPECT_TRUE(handler.IsEmpty());
+ EXPECT_EQ(CONTENT_SETTING_DEFAULT,
+ content_settings->GetPendingProtocolHandlerSetting());
+ }
+
+ // "0" is the "Allow" radio button.
+ content_setting_bubble_model->OnRadioClicked(0);
Bernhard Bauer 2012/06/25 16:52:20 You could move these into constants.
Greg Billock 2012/06/26 19:17:04 Yes. I'd have to promote them out of the CC file,
+ {
+ ProtocolHandler handler =
+ profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto");
+ ASSERT_FALSE(handler.IsEmpty());
+ EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title());
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ content_settings->GetPendingProtocolHandlerSetting());
+ }
+
+ // "1" is the "Deny" radio button.
+ content_setting_bubble_model->OnRadioClicked(1);
+ {
+ ProtocolHandler handler =
+ profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto");
+ EXPECT_TRUE(handler.IsEmpty());
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ content_settings->GetPendingProtocolHandlerSetting());
+ }
+
+ // "2" is the "Ignore button.
+ content_setting_bubble_model->OnRadioClicked(2);
+ {
+ ProtocolHandler handler =
+ profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto");
+ EXPECT_TRUE(handler.IsEmpty());
+ EXPECT_EQ(CONTENT_SETTING_DEFAULT,
+ content_settings->GetPendingProtocolHandlerSetting());
+ EXPECT_TRUE(profile()->GetProtocolHandlerRegistry()->IsIgnored(
+ test_handler));
+ }
+
+ // "0" is the "Allow" radio button.
+ content_setting_bubble_model->OnRadioClicked(0);
+ {
+ ProtocolHandler handler =
+ profile()->GetProtocolHandlerRegistry()->GetHandlerFor("mailto");
+ ASSERT_FALSE(handler.IsEmpty());
+ EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title());
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ content_settings->GetPendingProtocolHandlerSetting());
+ EXPECT_FALSE(profile()->GetProtocolHandlerRegistry()->IsIgnored(
+ test_handler));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698