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/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/metrics/histogram_samples.h" | 13 #include "base/metrics/histogram_samples.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/test/histogram_tester.h" | 15 #include "base/test/histogram_tester.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "chrome/renderer/searchbox/search_bouncer.h" | 17 #include "chrome/renderer/searchbox/search_bouncer.h" |
18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" |
19 #include "content/public/common/webplugininfo.h" | 19 #include "content/public/common/webplugininfo.h" |
| 20 #include "extensions/features/features.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/WebKit/public/platform/WebString.h" | 22 #include "third_party/WebKit/public/platform/WebString.h" |
22 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 23 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 #if defined(ENABLE_EXTENSIONS) | 26 #if BUILDFLAG(ENABLE_EXTENSIONS) |
26 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
27 #include "extensions/common/extension_builder.h" | 28 #include "extensions/common/extension_builder.h" |
28 #include "extensions/common/manifest_constants.h" | 29 #include "extensions/common/manifest_constants.h" |
29 #endif | 30 #endif |
30 | 31 |
31 #if !defined(DISABLE_NACL) | 32 #if !defined(DISABLE_NACL) |
32 #include "third_party/WebKit/public/platform/WebString.h" | 33 #include "third_party/WebKit/public/platform/WebString.h" |
33 #include "third_party/WebKit/public/platform/WebVector.h" | 34 #include "third_party/WebKit/public/platform/WebVector.h" |
34 #include "third_party/WebKit/public/web/WebPluginParams.h" | 35 #include "third_party/WebKit/public/web/WebPluginParams.h" |
35 #endif | 36 #endif |
36 | 37 |
37 #if !defined(DISABLE_NACL) | 38 #if !defined(DISABLE_NACL) |
38 using blink::WebPluginParams; | 39 using blink::WebPluginParams; |
39 using blink::WebString; | 40 using blink::WebString; |
40 using blink::WebVector; | 41 using blink::WebVector; |
41 #endif | 42 #endif |
42 | 43 |
43 using content::WebPluginInfo; | 44 using content::WebPluginInfo; |
44 using content::WebPluginMimeType; | 45 using content::WebPluginMimeType; |
45 | 46 |
46 namespace { | 47 namespace { |
47 | 48 |
48 #if !defined(DISABLE_NACL) | 49 #if !defined(DISABLE_NACL) |
49 const bool kNaClRestricted = false; | 50 const bool kNaClRestricted = false; |
50 const bool kNaClUnrestricted = true; | 51 const bool kNaClUnrestricted = true; |
51 const bool kExtensionNotFromWebStore = false; | 52 const bool kExtensionNotFromWebStore = false; |
52 const bool kExtensionFromWebStore = true; | 53 const bool kExtensionFromWebStore = true; |
53 #endif | 54 #endif |
54 | 55 |
55 #if defined(ENABLE_EXTENSIONS) | 56 #if BUILDFLAG(ENABLE_EXTENSIONS) |
56 const bool kNotHostedApp = false; | 57 const bool kNotHostedApp = false; |
57 const bool kHostedApp = true; | 58 const bool kHostedApp = true; |
58 #endif | 59 #endif |
59 | 60 |
60 #if !defined(DISABLE_NACL) | 61 #if !defined(DISABLE_NACL) |
61 const char kExtensionUrl[] = "chrome-extension://extension_id/background.html"; | 62 const char kExtensionUrl[] = "chrome-extension://extension_id/background.html"; |
62 | 63 |
63 const char kPhotosAppURL[] = "https://foo.plus.google.com"; | 64 const char kPhotosAppURL[] = "https://foo.plus.google.com"; |
64 const char kPhotosManifestURL[] = "https://ssl.gstatic.com/photos/nacl/foo"; | 65 const char kPhotosManifestURL[] = "https://ssl.gstatic.com/photos/nacl/foo"; |
65 | 66 |
(...skipping 30 matching lines...) Expand all Loading... |
96 mime_type_info.additional_param_values.push_back( | 97 mime_type_info.additional_param_values.push_back( |
97 base::UTF8ToUTF16(manifest_url)); | 98 base::UTF8ToUTF16(manifest_url)); |
98 info->mime_types.push_back(mime_type_info); | 99 info->mime_types.push_back(mime_type_info); |
99 } | 100 } |
100 | 101 |
101 } // namespace | 102 } // namespace |
102 | 103 |
103 typedef testing::Test ChromeContentRendererClientTest; | 104 typedef testing::Test ChromeContentRendererClientTest; |
104 | 105 |
105 | 106 |
106 #if defined(ENABLE_EXTENSIONS) | 107 #if BUILDFLAG(ENABLE_EXTENSIONS) |
107 scoped_refptr<const extensions::Extension> CreateTestExtension( | 108 scoped_refptr<const extensions::Extension> CreateTestExtension( |
108 extensions::Manifest::Location location, bool is_from_webstore, | 109 extensions::Manifest::Location location, bool is_from_webstore, |
109 bool is_hosted_app, const std::string& app_url) { | 110 bool is_hosted_app, const std::string& app_url) { |
110 int flags = is_from_webstore ? | 111 int flags = is_from_webstore ? |
111 extensions::Extension::FROM_WEBSTORE: | 112 extensions::Extension::FROM_WEBSTORE: |
112 extensions::Extension::NO_FLAGS; | 113 extensions::Extension::NO_FLAGS; |
113 | 114 |
114 base::DictionaryValue manifest; | 115 base::DictionaryValue manifest; |
115 manifest.SetString("name", "NaCl Extension"); | 116 manifest.SetString("name", "NaCl Extension"); |
116 manifest.SetString("version", "1"); | 117 manifest.SetString("version", "1"); |
(...skipping 22 matching lines...) Expand all Loading... |
139 location, is_from_webstore, kNotHostedApp, std::string()); | 140 location, is_from_webstore, kNotHostedApp, std::string()); |
140 } | 141 } |
141 | 142 |
142 scoped_refptr<const extensions::Extension> CreateHostedApp( | 143 scoped_refptr<const extensions::Extension> CreateHostedApp( |
143 bool is_from_webstore, const std::string& app_url) { | 144 bool is_from_webstore, const std::string& app_url) { |
144 return CreateTestExtension(extensions::Manifest::INTERNAL, | 145 return CreateTestExtension(extensions::Manifest::INTERNAL, |
145 is_from_webstore, | 146 is_from_webstore, |
146 kHostedApp, | 147 kHostedApp, |
147 app_url); | 148 app_url); |
148 } | 149 } |
149 #endif // defined(ENABLE_EXTENSIONS) | 150 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
150 | 151 |
151 TEST_F(ChromeContentRendererClientTest, NaClRestriction) { | 152 TEST_F(ChromeContentRendererClientTest, NaClRestriction) { |
152 // Unknown content types have no NaCl module. | 153 // Unknown content types have no NaCl module. |
153 { | 154 { |
154 WebPluginInfo info; | 155 WebPluginInfo info; |
155 EXPECT_EQ(GURL(), | 156 EXPECT_EQ(GURL(), |
156 ChromeContentRendererClient::GetNaClContentHandlerURL( | 157 ChromeContentRendererClient::GetNaClContentHandlerURL( |
157 "application/x-foo", info)); | 158 "application/x-foo", info)); |
158 } | 159 } |
159 // Known content types have a NaCl module. | 160 // Known content types have a NaCl module. |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 for (const auto& data : test_data) { | 744 for (const auto& data : test_data) { |
744 ++total_count; | 745 ++total_count; |
745 GURL gurl = GURL(data); | 746 GURL gurl = GURL(data); |
746 OverrideFlashEmbed(gurl); | 747 OverrideFlashEmbed(gurl); |
747 samples = GetHistogramSamples(); | 748 samples = GetHistogramSamples(); |
748 EXPECT_EQ(total_count, samples->GetCount(internal::FAILURE_ENABLEJSAPI)); | 749 EXPECT_EQ(total_count, samples->GetCount(internal::FAILURE_ENABLEJSAPI)); |
749 EXPECT_EQ(total_count, samples->TotalCount()); | 750 EXPECT_EQ(total_count, samples->TotalCount()); |
750 } | 751 } |
751 } | 752 } |
752 #endif | 753 #endif |
OLD | NEW |