| 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/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
| 6 | 6 |
| 7 #include <string.h> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| 9 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 12 #include "extensions/common/constants.cc" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "url/gurl.h" |
| 15 #include "url/origin.h" |
| 16 #include "url/url_util.h" |
| 11 | 17 |
| 12 namespace { | 18 namespace { |
| 13 | 19 |
| 14 void CheckUserAgentStringOrdering(bool mobile_device) { | 20 void CheckUserAgentStringOrdering(bool mobile_device) { |
| 15 std::vector<std::string> pieces; | 21 std::vector<std::string> pieces; |
| 16 | 22 |
| 17 // Check if the pieces of the user agent string come in the correct order. | 23 // Check if the pieces of the user agent string come in the correct order. |
| 18 ChromeContentClient content_client; | 24 ChromeContentClient content_client; |
| 19 std::string buffer = content_client.GetUserAgent(); | 25 std::string buffer = content_client.GetUserAgent(); |
| 20 | 26 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ASSERT_FALSE(command_line->HasSwitch(switches::kUseMobileUserAgent)); | 80 ASSERT_FALSE(command_line->HasSwitch(switches::kUseMobileUserAgent)); |
| 75 CheckUserAgentStringOrdering(false); | 81 CheckUserAgentStringOrdering(false); |
| 76 | 82 |
| 77 // Do it for mobile devices. | 83 // Do it for mobile devices. |
| 78 command_line->AppendSwitch(switches::kUseMobileUserAgent); | 84 command_line->AppendSwitch(switches::kUseMobileUserAgent); |
| 79 ASSERT_TRUE(command_line->HasSwitch(switches::kUseMobileUserAgent)); | 85 ASSERT_TRUE(command_line->HasSwitch(switches::kUseMobileUserAgent)); |
| 80 CheckUserAgentStringOrdering(true); | 86 CheckUserAgentStringOrdering(true); |
| 81 #endif | 87 #endif |
| 82 } | 88 } |
| 83 | 89 |
| 90 TEST(ChromeContentClientTest, AdditionalSchemes) { |
| 91 EXPECT_TRUE(url::IsStandard( |
| 92 extensions::kExtensionScheme, |
| 93 url::Component(0, strlen(extensions::kExtensionScheme)))); |
| 94 |
| 95 GURL extension_url( |
| 96 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); |
| 97 url::Origin origin(extension_url); |
| 98 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", |
| 99 origin.Serialize()); |
| 100 } |
| 101 |
| 84 } // namespace chrome_common | 102 } // namespace chrome_common |
| OLD | NEW |