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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 33 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
34 #include "chrome/browser/devtools/devtools_window.h" 34 #include "chrome/browser/devtools/devtools_window.h"
35 #include "chrome/browser/download/download_prefs.h" 35 #include "chrome/browser/download/download_prefs.h"
36 #include "chrome/browser/extensions/crx_installer.h" 36 #include "chrome/browser/extensions/crx_installer.h"
37 #include "chrome/browser/extensions/extension_host.h" 37 #include "chrome/browser/extensions/extension_host.h"
38 #include "chrome/browser/extensions/extension_process_manager.h" 38 #include "chrome/browser/extensions/extension_process_manager.h"
39 #include "chrome/browser/extensions/extension_service.h" 39 #include "chrome/browser/extensions/extension_service.h"
40 #include "chrome/browser/extensions/extension_system.h" 40 #include "chrome/browser/extensions/extension_system.h"
41 #include "chrome/browser/extensions/unpacked_installer.h" 41 #include "chrome/browser/extensions/unpacked_installer.h"
42 #include "chrome/browser/extensions/updater/extension_updater.h" 42 #include "chrome/browser/extensions/updater/extension_updater.h"
43 #include "chrome/browser/infobars/infobar.h"
43 #include "chrome/browser/infobars/infobar_service.h" 44 #include "chrome/browser/infobars/infobar_service.h"
44 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 45 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
45 #include "chrome/browser/media/media_stream_devices_controller.h" 46 #include "chrome/browser/media/media_stream_devices_controller.h"
46 #include "chrome/browser/metrics/variations/variations_service.h" 47 #include "chrome/browser/metrics/variations/variations_service.h"
47 #include "chrome/browser/net/url_request_mock_util.h" 48 #include "chrome/browser/net/url_request_mock_util.h"
48 #include "chrome/browser/plugins/plugin_prefs.h" 49 #include "chrome/browser/plugins/plugin_prefs.h"
49 #include "chrome/browser/policy/browser_policy_connector.h" 50 #include "chrome/browser/policy/browser_policy_connector.h"
50 #include "chrome/browser/policy/cloud/test_request_interceptor.h" 51 #include "chrome/browser/policy/cloud/test_request_interceptor.h"
51 #include "chrome/browser/policy/external_data_fetcher.h" 52 #include "chrome/browser/policy/external_data_fetcher.h"
52 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 53 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 ASSERT_TRUE(contents); 1286 ASSERT_TRUE(contents);
1286 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); 1287 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
1287 ASSERT_TRUE(infobar_service); 1288 ASSERT_TRUE(infobar_service);
1288 EXPECT_EQ(0u, infobar_service->infobar_count()); 1289 EXPECT_EQ(0u, infobar_service->infobar_count());
1289 1290
1290 base::FilePath path(FILE_PATH_LITERAL("plugin/quicktime.html")); 1291 base::FilePath path(FILE_PATH_LITERAL("plugin/quicktime.html"));
1291 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); 1292 GURL url(URLRequestMockHTTPJob::GetMockUrl(path));
1292 ui_test_utils::NavigateToURL(browser(), url); 1293 ui_test_utils::NavigateToURL(browser(), url);
1293 // This should have triggered the dangerous plugin infobar. 1294 // This should have triggered the dangerous plugin infobar.
1294 ASSERT_EQ(1u, infobar_service->infobar_count()); 1295 ASSERT_EQ(1u, infobar_service->infobar_count());
1295 EXPECT_TRUE(infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate()); 1296 EXPECT_TRUE(
1297 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate());
1296 // And the plugin isn't running. 1298 // And the plugin isn't running.
1297 EXPECT_EQ(0, CountPlugins()); 1299 EXPECT_EQ(0, CountPlugins());
1298 1300
1299 // Now set a policy to always authorize this. 1301 // Now set a policy to always authorize this.
1300 PolicyMap policies; 1302 PolicyMap policies;
1301 policies.Set(key::kAlwaysAuthorizePlugins, POLICY_LEVEL_MANDATORY, 1303 policies.Set(key::kAlwaysAuthorizePlugins, POLICY_LEVEL_MANDATORY,
1302 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1304 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL);
1303 UpdateProviderPolicy(policies); 1305 UpdateProviderPolicy(policies);
1304 // Reloading the page shouldn't trigger the infobar this time. 1306 // Reloading the page shouldn't trigger the infobar this time.
1305 ui_test_utils::NavigateToURL(browser(), url); 1307 ui_test_utils::NavigateToURL(browser(), url);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 ASSERT_TRUE(translate_tab_helper); 1831 ASSERT_TRUE(translate_tab_helper);
1830 LanguageState& language_state = translate_tab_helper->language_state(); 1832 LanguageState& language_state = translate_tab_helper->language_state();
1831 EXPECT_EQ("fr", language_state.original_language()); 1833 EXPECT_EQ("fr", language_state.original_language());
1832 EXPECT_TRUE(language_state.page_needs_translation()); 1834 EXPECT_TRUE(language_state.page_needs_translation());
1833 EXPECT_FALSE(language_state.translation_pending()); 1835 EXPECT_FALSE(language_state.translation_pending());
1834 EXPECT_FALSE(language_state.translation_declined()); 1836 EXPECT_FALSE(language_state.translation_declined());
1835 EXPECT_FALSE(language_state.IsPageTranslated()); 1837 EXPECT_FALSE(language_state.IsPageTranslated());
1836 1838
1837 // Verify that the translate infobar showed up. 1839 // Verify that the translate infobar showed up.
1838 ASSERT_EQ(1u, infobar_service->infobar_count()); 1840 ASSERT_EQ(1u, infobar_service->infobar_count());
1839 InfoBarDelegate* infobar = infobar_service->infobar_at(0); 1841 InfoBar* infobar = infobar_service->infobar_at(0);
1840 TranslateInfoBarDelegate* translate_infobar_delegate = 1842 TranslateInfoBarDelegate* translate_infobar_delegate =
1841 infobar->AsTranslateInfoBarDelegate(); 1843 infobar->delegate()->AsTranslateInfoBarDelegate();
1842 ASSERT_TRUE(translate_infobar_delegate); 1844 ASSERT_TRUE(translate_infobar_delegate);
1843 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, 1845 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE,
1844 translate_infobar_delegate->infobar_type()); 1846 translate_infobar_delegate->infobar_type());
1845 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); 1847 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code());
1846 1848
1847 // Now force disable translate. 1849 // Now force disable translate.
1848 infobar_service->RemoveInfoBar(infobar); 1850 infobar_service->RemoveInfoBar(infobar);
1849 EXPECT_EQ(0u, infobar_service->infobar_count()); 1851 EXPECT_EQ(0u, infobar_service->infobar_count());
1850 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, 1852 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY,
1851 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1853 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL);
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 chrome_variations::VariationsService::GetVariationsServerURL( 2729 chrome_variations::VariationsService::GetVariationsServerURL(
2728 g_browser_process->local_state()); 2730 g_browser_process->local_state());
2729 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); 2731 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true));
2730 std::string value; 2732 std::string value;
2731 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); 2733 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
2732 EXPECT_EQ("restricted", value); 2734 EXPECT_EQ("restricted", value);
2733 } 2735 }
2734 #endif 2736 #endif
2735 2737
2736 } // namespace policy 2738 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698