OLD | NEW |
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 "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
12 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
15 #include "content/browser/tab_contents/test_tab_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "content/test/test_browser_thread.h" | 16 #include "content/test/test_browser_thread.h" |
| 17 #include "content/test/web_contents_tester.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 using content::BrowserThread; | 20 using content::BrowserThread; |
| 21 using content::WebContentsTester; |
20 | 22 |
21 class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness { | 23 class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness { |
22 protected: | 24 protected: |
23 ContentSettingBubbleModelTest() | 25 ContentSettingBubbleModelTest() |
24 : ui_thread_(BrowserThread::UI, MessageLoop::current()) { | 26 : ui_thread_(BrowserThread::UI, MessageLoop::current()) { |
25 } | 27 } |
26 | 28 |
27 void CheckGeolocationBubble(size_t expected_domains, | 29 void CheckGeolocationBubble(size_t expected_domains, |
28 bool expect_clear_link, | 30 bool expect_clear_link, |
29 bool expect_reload_hint) { | 31 bool expect_reload_hint) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 109 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
108 AutoReset<CommandLine> auto_reset(cmd, *cmd); | 110 AutoReset<CommandLine> auto_reset(cmd, *cmd); |
109 cmd->AppendSwitch(switches::kEnableResourceContentSettings); | 111 cmd->AppendSwitch(switches::kEnableResourceContentSettings); |
110 | 112 |
111 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); | 113 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); |
112 std::string fooPlugin = "foo"; | 114 std::string fooPlugin = "foo"; |
113 std::string barPlugin = "bar"; | 115 std::string barPlugin = "bar"; |
114 | 116 |
115 // Navigating to some sample url prevents the GetURL method from returning an | 117 // Navigating to some sample url prevents the GetURL method from returning an |
116 // invalid empty URL. | 118 // invalid empty URL. |
117 contents()->NavigateAndCommit(GURL("http://www.example.com")); | 119 WebContentsTester::For( |
| 120 contents())->NavigateAndCommit(GURL("http://www.example.com")); |
118 GURL url = contents()->GetURL(); | 121 GURL url = contents()->GetURL(); |
119 map->AddExceptionForURL(url, | 122 map->AddExceptionForURL(url, |
120 url, | 123 url, |
121 CONTENT_SETTINGS_TYPE_PLUGINS, | 124 CONTENT_SETTINGS_TYPE_PLUGINS, |
122 fooPlugin, | 125 fooPlugin, |
123 CONTENT_SETTING_ALLOW); | 126 CONTENT_SETTING_ALLOW); |
124 map->AddExceptionForURL(url, | 127 map->AddExceptionForURL(url, |
125 url, | 128 url, |
126 CONTENT_SETTINGS_TYPE_PLUGINS, | 129 CONTENT_SETTINGS_TYPE_PLUGINS, |
127 barPlugin, | 130 barPlugin, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 std::string file_url("file:///tmp/test.html"); | 216 std::string file_url("file:///tmp/test.html"); |
214 NavigateAndCommit(GURL(file_url)); | 217 NavigateAndCommit(GURL(file_url)); |
215 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 218 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
216 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 219 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
217 NULL, contents_wrapper(), profile(), | 220 NULL, contents_wrapper(), profile(), |
218 CONTENT_SETTINGS_TYPE_IMAGES)); | 221 CONTENT_SETTINGS_TYPE_IMAGES)); |
219 std::string title = | 222 std::string title = |
220 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; | 223 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; |
221 ASSERT_NE(std::string::npos, title.find(file_url)); | 224 ASSERT_NE(std::string::npos, title.find(file_url)); |
222 } | 225 } |
OLD | NEW |