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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 1181293003: Expand SecurityStyleChanged interfaces to include explanations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add CONTENT_EXPORT Created 5 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | content/browser/devtools/protocol/security_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "content/public/browser/host_zoom_map.h" 72 #include "content/public/browser/host_zoom_map.h"
73 #include "content/public/browser/interstitial_page.h" 73 #include "content/public/browser/interstitial_page.h"
74 #include "content/public/browser/interstitial_page_delegate.h" 74 #include "content/public/browser/interstitial_page_delegate.h"
75 #include "content/public/browser/navigation_entry.h" 75 #include "content/public/browser/navigation_entry.h"
76 #include "content/public/browser/notification_service.h" 76 #include "content/public/browser/notification_service.h"
77 #include "content/public/browser/render_frame_host.h" 77 #include "content/public/browser/render_frame_host.h"
78 #include "content/public/browser/render_process_host.h" 78 #include "content/public/browser/render_process_host.h"
79 #include "content/public/browser/render_view_host.h" 79 #include "content/public/browser/render_view_host.h"
80 #include "content/public/browser/render_widget_host_view.h" 80 #include "content/public/browser/render_widget_host_view.h"
81 #include "content/public/browser/resource_context.h" 81 #include "content/public/browser/resource_context.h"
82 #include "content/public/browser/security_style_explanation.h"
83 #include "content/public/browser/security_style_explanations.h"
82 #include "content/public/browser/web_contents.h" 84 #include "content/public/browser/web_contents.h"
83 #include "content/public/browser/web_contents_observer.h" 85 #include "content/public/browser/web_contents_observer.h"
84 #include "content/public/common/frame_navigate_params.h" 86 #include "content/public/common/frame_navigate_params.h"
85 #include "content/public/common/renderer_preferences.h" 87 #include "content/public/common/renderer_preferences.h"
86 #include "content/public/common/url_constants.h" 88 #include "content/public/common/url_constants.h"
87 #include "content/public/test/browser_test_utils.h" 89 #include "content/public/test/browser_test_utils.h"
88 #include "content/public/test/test_navigation_observer.h" 90 #include "content/public/test/test_navigation_observer.h"
89 #include "extensions/browser/extension_registry.h" 91 #include "extensions/browser/extension_registry.h"
90 #include "extensions/browser/extension_system.h" 92 #include "extensions/browser/extension_system.h"
91 #include "extensions/browser/uninstall_reason.h" 93 #include "extensions/browser/uninstall_reason.h"
92 #include "extensions/common/constants.h" 94 #include "extensions/common/constants.h"
93 #include "extensions/common/extension.h" 95 #include "extensions/common/extension.h"
94 #include "extensions/common/extension_set.h" 96 #include "extensions/common/extension_set.h"
97 #include "net/base/net_errors.h"
95 #include "net/dns/mock_host_resolver.h" 98 #include "net/dns/mock_host_resolver.h"
96 #include "net/test/spawned_test_server/spawned_test_server.h" 99 #include "net/test/spawned_test_server/spawned_test_server.h"
97 #include "ui/base/l10n/l10n_util.h" 100 #include "ui/base/l10n/l10n_util.h"
98 #include "ui/base/page_transition_types.h" 101 #include "ui/base/page_transition_types.h"
99 102
100 #if defined(OS_MACOSX) 103 #if defined(OS_MACOSX)
101 #include "base/mac/scoped_nsautorelease_pool.h" 104 #include "base/mac/scoped_nsautorelease_pool.h"
102 #include "chrome/browser/ui/cocoa/run_loop_testing.h" 105 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
103 #endif 106 #endif
104 107
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 const net::HostPortPair& host_port_pair, 337 const net::HostPortPair& host_port_pair,
335 std::string* replacement_path) { 338 std::string* replacement_path) {
336 std::vector<net::SpawnedTestServer::StringPair> replacement_text; 339 std::vector<net::SpawnedTestServer::StringPair> replacement_text;
337 replacement_text.push_back( 340 replacement_text.push_back(
338 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); 341 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString()));
339 return net::SpawnedTestServer::GetFilePathWithReplacements( 342 return net::SpawnedTestServer::GetFilePathWithReplacements(
340 original_file_path, replacement_text, replacement_path); 343 original_file_path, replacement_text, replacement_path);
341 } 344 }
342 345
343 // A WebContentsObserver useful for testing the SecurityStyleChanged() 346 // A WebContentsObserver useful for testing the SecurityStyleChanged()
344 // method: it keeps track of the latest security style that was fired. 347 // method: it keeps track of the latest security style and explanation
348 // that was fired.
345 class SecurityStyleTestObserver : public WebContentsObserver { 349 class SecurityStyleTestObserver : public WebContentsObserver {
346 public: 350 public:
347 explicit SecurityStyleTestObserver(content::WebContents* web_contents) 351 explicit SecurityStyleTestObserver(content::WebContents* web_contents)
348 : content::WebContentsObserver(web_contents), 352 : content::WebContentsObserver(web_contents),
349 latest_security_style_(content::SECURITY_STYLE_UNKNOWN) {} 353 latest_security_style_(content::SECURITY_STYLE_UNKNOWN) {}
350 ~SecurityStyleTestObserver() override {} 354 ~SecurityStyleTestObserver() override {}
351 355
352 void SecurityStyleChanged(content::SecurityStyle security_style) override { 356 void SecurityStyleChanged(content::SecurityStyle security_style,
357 const content::SecurityStyleExplanations&
358 security_style_explanations) override {
353 latest_security_style_ = security_style; 359 latest_security_style_ = security_style;
360 latest_explanations_ = security_style_explanations;
354 } 361 }
355 362
356 content::SecurityStyle latest_security_style() const { 363 content::SecurityStyle latest_security_style() const {
357 return latest_security_style_; 364 return latest_security_style_;
358 } 365 }
359 366
367 const content::SecurityStyleExplanations& latest_explanations() const {
368 return latest_explanations_;
369 }
370
360 private: 371 private:
361 content::SecurityStyle latest_security_style_; 372 content::SecurityStyle latest_security_style_;
373 content::SecurityStyleExplanations latest_explanations_;
362 374
363 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver); 375 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver);
364 }; 376 };
365 377
366 } // namespace 378 } // namespace
367 379
368 class BrowserTest : public ExtensionBrowserTest { 380 class BrowserTest : public ExtensionBrowserTest {
369 protected: 381 protected:
370 // In RTL locales wrap the page title with RTL embedding characters so that it 382 // In RTL locales wrap the page title with RTL embedding characters so that it
371 // matches the value returned by GetWindowTitle(). 383 // matches the value returned by GetWindowTitle().
(...skipping 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 // Visit an (otherwise valid) HTTPS page that displays mixed content. 2863 // Visit an (otherwise valid) HTTPS page that displays mixed content.
2852 std::string replacement_path; 2864 std::string replacement_path;
2853 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 2865 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
2854 "files/ssl/page_displays_insecure_content.html", 2866 "files/ssl/page_displays_insecure_content.html",
2855 test_server()->host_port_pair(), &replacement_path)); 2867 test_server()->host_port_pair(), &replacement_path));
2856 2868
2857 GURL mixed_content_url(https_test_server.GetURL(replacement_path)); 2869 GURL mixed_content_url(https_test_server.GetURL(replacement_path));
2858 ui_test_utils::NavigateToURL(browser(), mixed_content_url); 2870 ui_test_utils::NavigateToURL(browser(), mixed_content_url);
2859 EXPECT_EQ(content::SECURITY_STYLE_WARNING, observer.latest_security_style()); 2871 EXPECT_EQ(content::SECURITY_STYLE_WARNING, observer.latest_security_style());
2860 2872
2873 const content::SecurityStyleExplanations& mixed_content_explanation =
2874 observer.latest_explanations();
2875 ASSERT_EQ(1u, mixed_content_explanation.warning_explanations.size());
2876 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT),
2877 mixed_content_explanation.warning_explanations[0].summary);
2878 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_PASSIVE_MIXED_CONTENT_DESCRIPTION),
2879 mixed_content_explanation.warning_explanations[0].description);
2880 EXPECT_EQ(0u, mixed_content_explanation.broken_explanations.size());
2881
2861 // Visit a broken HTTPS url. Other conditions cannot be tested after 2882 // Visit a broken HTTPS url. Other conditions cannot be tested after
2862 // this one because once the interstitial is clicked through, all URLs 2883 // this one because once the interstitial is clicked through, all URLs
2863 // for this host will remain in a broken state. 2884 // for this host will remain in a broken state.
2864 GURL expired_url(https_test_server_expired.GetURL(std::string())); 2885 GURL expired_url(https_test_server_expired.GetURL(std::string()));
2865 ui_test_utils::NavigateToURL(browser(), expired_url); 2886 ui_test_utils::NavigateToURL(browser(), expired_url);
2866 2887
2867 ProceedThroughInterstitial(web_contents); 2888 ProceedThroughInterstitial(web_contents);
2868 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, 2889 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN,
2869 observer.latest_security_style()); 2890 observer.latest_security_style());
2891
2892 const content::SecurityStyleExplanations& expired_explanation =
2893 observer.latest_explanations();
2894 EXPECT_EQ(0u, expired_explanation.warning_explanations.size());
2895 ASSERT_EQ(1u, expired_explanation.broken_explanations.size());
2896 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_CERTIFICATE_CHAIN_ERROR),
2897 expired_explanation.broken_explanations[0].summary);
2898 base::string16 error_string =
2899 base::UTF8ToUTF16(net::ErrorToString(net::ERR_CERT_DATE_INVALID));
2900 EXPECT_EQ(l10n_util::GetStringFUTF8(
2901 IDS_CERTIFICATE_CHAIN_ERROR_DESCRIPTION_FORMAT, error_string),
2902 expired_explanation.broken_explanations[0].description);
2870 } 2903 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | content/browser/devtools/protocol/security_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698