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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_image_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: Fix merge Created 8 years, 5 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 | 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/utf_string_conversions.h"
5 #include "chrome/browser/content_settings/host_content_settings_map.h" 6 #include "chrome/browser/content_settings/host_content_settings_map.h"
6 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
7 #include "chrome/browser/prerender/prerender_manager.h" 8 #include "chrome/browser/prerender/prerender_manager.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
11 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" 12 #include "chrome/browser/ui/tab_contents/test_tab_contents.h"
12 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
13 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
14 #include "content/public/test/test_renderer_host.h" 15 #include "content/public/test/test_renderer_host.h"
(...skipping 25 matching lines...) Expand all
40 41
41 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, 42 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES,
42 std::string()); 43 std::string());
43 content_setting_image_model->UpdateFromWebContents(contents()); 44 content_setting_image_model->UpdateFromWebContents(contents());
44 45
45 EXPECT_TRUE(content_setting_image_model->is_visible()); 46 EXPECT_TRUE(content_setting_image_model->is_visible());
46 EXPECT_NE(0, content_setting_image_model->get_icon()); 47 EXPECT_NE(0, content_setting_image_model->get_icon());
47 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); 48 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty());
48 } 49 }
49 50
51 TEST_F(ContentSettingImageModelTest, RPHUpdateFromWebContents) {
52 scoped_ptr<ContentSettingImageModel> content_setting_image_model(
53 ContentSettingImageModel::CreateContentSettingImageModel(
54 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS));
55 content_setting_image_model->UpdateFromWebContents(contents());
56 EXPECT_FALSE(content_setting_image_model->is_visible());
57
58 TabSpecificContentSettings* content_settings =
59 tab_contents()->content_settings();
60 content_settings->set_pending_protocol_handler(
61 ProtocolHandler::CreateProtocolHandler(
62 "mailto", GURL("http://www.google.com/"), ASCIIToUTF16("Handler")));
63 content_setting_image_model->UpdateFromWebContents(contents());
64 EXPECT_TRUE(content_setting_image_model->is_visible());
65 }
66
50 TEST_F(ContentSettingImageModelTest, CookieAccessed) { 67 TEST_F(ContentSettingImageModelTest, CookieAccessed) {
51 TabSpecificContentSettings* content_settings = 68 TabSpecificContentSettings* content_settings =
52 tab_contents()->content_settings(); 69 tab_contents()->content_settings();
53 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( 70 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
54 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); 71 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK);
55 scoped_ptr<ContentSettingImageModel> content_setting_image_model( 72 scoped_ptr<ContentSettingImageModel> content_setting_image_model(
56 ContentSettingImageModel::CreateContentSettingImageModel( 73 ContentSettingImageModel::CreateContentSettingImageModel(
57 CONTENT_SETTINGS_TYPE_COOKIES)); 74 CONTENT_SETTINGS_TYPE_COOKIES));
58 EXPECT_FALSE(content_setting_image_model->is_visible()); 75 EXPECT_FALSE(content_setting_image_model->is_visible());
59 EXPECT_EQ(0, content_setting_image_model->get_icon()); 76 EXPECT_EQ(0, content_setting_image_model->get_icon());
60 EXPECT_TRUE(content_setting_image_model->get_tooltip().empty()); 77 EXPECT_TRUE(content_setting_image_model->get_tooltip().empty());
61 78
62 net::CookieOptions options; 79 net::CookieOptions options;
63 content_settings->OnCookieChanged(GURL("http://google.com"), 80 content_settings->OnCookieChanged(GURL("http://google.com"),
64 GURL("http://google.com"), 81 GURL("http://google.com"),
65 "A=B", 82 "A=B",
66 options, 83 options,
67 false); 84 false);
68 content_setting_image_model->UpdateFromWebContents(contents()); 85 content_setting_image_model->UpdateFromWebContents(contents());
69 EXPECT_TRUE(content_setting_image_model->is_visible()); 86 EXPECT_TRUE(content_setting_image_model->is_visible());
70 EXPECT_NE(0, content_setting_image_model->get_icon()); 87 EXPECT_NE(0, content_setting_image_model->get_icon());
71 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); 88 EXPECT_FALSE(content_setting_image_model->get_tooltip().empty());
72 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698