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 "chrome/browser/browser_about_handler.h" | 5 #include "chrome/browser/browser_about_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/test/scoped_feature_list.h" | 15 #include "base/test/scoped_feature_list.h" |
16 #include "chrome/common/chrome_features.h" | 16 #include "chrome/common/chrome_features.h" |
17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/common/referrer.h" | 21 #include "content/public/common/referrer.h" |
| 22 #include "content/public/common/url_constants.h" |
22 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
23 #include "content/public/test/test_browser_thread_bundle.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 using content::BrowserThread; | 28 using content::BrowserThread; |
28 using content::NavigationController; | 29 using content::NavigationController; |
29 using content::NavigationEntry; | 30 using content::NavigationEntry; |
30 using content::Referrer; | 31 using content::Referrer; |
31 | 32 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 #if defined(OS_CHROMEOS) | 82 #if defined(OS_CHROMEOS) |
82 // Chrome OS defaults to showing Options in a window and including About in | 83 // Chrome OS defaults to showing Options in a window and including About in |
83 // Options. | 84 // Options. |
84 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForOptionsChromeOS) { | 85 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForOptionsChromeOS) { |
85 base::test::ScopedFeatureList scoped_feature_list; | 86 base::test::ScopedFeatureList scoped_feature_list; |
86 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings); | 87 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings); |
87 | 88 |
88 std::string chrome_prefix(content::kChromeUIScheme); | 89 std::string chrome_prefix(content::kChromeUIScheme); |
89 chrome_prefix.append(url::kStandardSchemeSeparator); | 90 chrome_prefix.append(url::kStandardSchemeSeparator); |
90 std::vector<AboutURLTestCase> test_cases( | 91 std::vector<AboutURLTestCase> test_cases( |
91 {{GURL(chrome_prefix + chrome::kChromeUISettingsHost), | 92 {{GURL(chrome_prefix + content::kChromeUISettingsHost), |
92 GURL(chrome_prefix + chrome::kChromeUISettingsFrameHost)}, | 93 GURL(chrome_prefix + chrome::kChromeUISettingsFrameHost)}, |
93 {GURL(chrome_prefix + chrome::kChromeUIHelpHost), | 94 {GURL(chrome_prefix + content::kChromeUIHelpHost), |
94 GURL(chrome_prefix + chrome::kChromeUISettingsFrameHost + "/" + | 95 GURL(chrome_prefix + chrome::kChromeUISettingsFrameHost + "/" + |
95 chrome::kChromeUIHelpHost)}}); | 96 content::kChromeUIHelpHost)}}); |
96 TestWillHandleBrowserAboutURL(test_cases); | 97 TestWillHandleBrowserAboutURL(test_cases); |
97 } | 98 } |
98 | 99 |
99 #else | 100 #else |
100 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForOptions) { | 101 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForOptions) { |
101 base::test::ScopedFeatureList scoped_feature_list; | 102 base::test::ScopedFeatureList scoped_feature_list; |
102 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings); | 103 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignSettings); |
103 | 104 |
104 std::string chrome_prefix(content::kChromeUIScheme); | 105 std::string chrome_prefix(content::kChromeUIScheme); |
105 chrome_prefix.append(url::kStandardSchemeSeparator); | 106 chrome_prefix.append(url::kStandardSchemeSeparator); |
106 std::vector<AboutURLTestCase> test_cases( | 107 std::vector<AboutURLTestCase> test_cases( |
107 {{ | 108 {{ |
108 GURL(chrome_prefix + chrome::kChromeUISettingsHost), | 109 GURL(chrome_prefix + content::kChromeUISettingsHost), |
109 GURL(chrome_prefix + chrome::kChromeUIUberHost + "/" + | 110 GURL(chrome_prefix + chrome::kChromeUIUberHost + "/" + |
110 chrome::kChromeUISettingsHost + "/"), | 111 content::kChromeUISettingsHost + "/"), |
111 }, | 112 }, |
112 { | 113 { |
113 GURL(chrome_prefix + chrome::kChromeUIHelpHost), | 114 GURL(chrome_prefix + content::kChromeUIHelpHost), |
114 GURL(chrome_prefix + chrome::kChromeUIUberHost + "/" + | 115 GURL(chrome_prefix + chrome::kChromeUIUberHost + "/" + |
115 chrome::kChromeUIHelpHost + "/"), | 116 content::kChromeUIHelpHost + "/"), |
116 }}); | 117 }}); |
117 TestWillHandleBrowserAboutURL(test_cases); | 118 TestWillHandleBrowserAboutURL(test_cases); |
118 } | 119 } |
119 #endif | 120 #endif |
120 | 121 |
121 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForMDSettings) { | 122 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURLForMDSettings) { |
122 base::test::ScopedFeatureList scoped_feature_list; | 123 base::test::ScopedFeatureList scoped_feature_list; |
123 scoped_feature_list.InitAndEnableFeature(features::kMaterialDesignSettings); | 124 scoped_feature_list.InitAndEnableFeature(features::kMaterialDesignSettings); |
124 | 125 |
125 std::string chrome_prefix(content::kChromeUIScheme); | 126 std::string chrome_prefix(content::kChromeUIScheme); |
126 chrome_prefix.append(url::kStandardSchemeSeparator); | 127 chrome_prefix.append(url::kStandardSchemeSeparator); |
127 std::vector<AboutURLTestCase> test_cases( | 128 std::vector<AboutURLTestCase> test_cases( |
128 {{GURL(chrome_prefix + chrome::kChromeUISettingsHost), | 129 {{GURL(chrome_prefix + content::kChromeUISettingsHost), |
129 GURL(chrome_prefix + chrome::kChromeUISettingsHost)}}); | 130 GURL(chrome_prefix + content::kChromeUISettingsHost)}}); |
130 TestWillHandleBrowserAboutURL(test_cases); | 131 TestWillHandleBrowserAboutURL(test_cases); |
131 } | 132 } |
132 | 133 |
133 // Ensure that minor BrowserAboutHandler fixup to a URL does not cause us to | 134 // Ensure that minor BrowserAboutHandler fixup to a URL does not cause us to |
134 // keep a separate virtual URL, which would not be updated on redirects. | 135 // keep a separate virtual URL, which would not be updated on redirects. |
135 // See https://crbug.com/449829. | 136 // See https://crbug.com/449829. |
136 TEST_F(BrowserAboutHandlerTest, NoVirtualURLForFixup) { | 137 TEST_F(BrowserAboutHandlerTest, NoVirtualURLForFixup) { |
137 GURL url("view-source:http://.foo"); | 138 GURL url("view-source:http://.foo"); |
138 | 139 |
139 // Fixup will remove the dot and add a slash. | 140 // Fixup will remove the dot and add a slash. |
140 GURL fixed_url("view-source:http://foo/"); | 141 GURL fixed_url("view-source:http://foo/"); |
141 | 142 |
142 // Rewriters will remove the view-source prefix and expect it to stay in the | 143 // Rewriters will remove the view-source prefix and expect it to stay in the |
143 // virtual URL. | 144 // virtual URL. |
144 GURL rewritten_url("http://foo/"); | 145 GURL rewritten_url("http://foo/"); |
145 | 146 |
146 TestingProfile profile; | 147 TestingProfile profile; |
147 std::unique_ptr<NavigationEntry> entry( | 148 std::unique_ptr<NavigationEntry> entry( |
148 NavigationController::CreateNavigationEntry( | 149 NavigationController::CreateNavigationEntry( |
149 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), | 150 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), |
150 &profile)); | 151 &profile)); |
151 EXPECT_EQ(fixed_url, entry->GetVirtualURL()); | 152 EXPECT_EQ(fixed_url, entry->GetVirtualURL()); |
152 EXPECT_EQ(rewritten_url, entry->GetURL()); | 153 EXPECT_EQ(rewritten_url, entry->GetURL()); |
153 } | 154 } |
OLD | NEW |