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

Side by Side Diff: extensions/shell/common/shell_content_client.cc

Issue 2574763003: Remove chrome-extension-resource:// scheme (Closed)
Patch Set: Silently strip chrome-extension-resource:// from CSP directives. Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/shell/common/shell_content_client.h" 5 #include "extensions/shell/common/shell_content_client.h"
6 6
7 #include "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/common/user_agent.h" 9 #include "content/public/common/user_agent.h"
10 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 nacl.internal_entry_points.get_interface = nacl_plugin::PPP_GetInterface; 67 nacl.internal_entry_points.get_interface = nacl_plugin::PPP_GetInterface;
68 nacl.internal_entry_points.initialize_module = 68 nacl.internal_entry_points.initialize_module =
69 nacl_plugin::PPP_InitializeModule; 69 nacl_plugin::PPP_InitializeModule;
70 nacl.internal_entry_points.shutdown_module = 70 nacl.internal_entry_points.shutdown_module =
71 nacl_plugin::PPP_ShutdownModule; 71 nacl_plugin::PPP_ShutdownModule;
72 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 72 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
73 plugins->push_back(nacl); 73 plugins->push_back(nacl);
74 #endif // !defined(DISABLE_NACL) 74 #endif // !defined(DISABLE_NACL)
75 } 75 }
76 76
77 static const int kNumShellStandardURLSchemes = 2; 77 static const url::SchemeWithType kShellStandardURLSchemes[] = {
James Cook 2016/12/14 20:41:49 nit: eliminate this and the iteration below, just
ncarter (slow) 2016/12/14 22:26:42 Done.
78 static const url::SchemeWithType kShellStandardURLSchemes[ 78 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
79 kNumShellStandardURLSchemes] = {
80 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
81 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT},
82 }; 79 };
83 80
84 void ShellContentClient::AddAdditionalSchemes( 81 void ShellContentClient::AddAdditionalSchemes(
85 std::vector<url::SchemeWithType>* standard_schemes, 82 std::vector<url::SchemeWithType>* standard_schemes,
86 std::vector<url::SchemeWithType>* referrer_schemes, 83 std::vector<url::SchemeWithType>* referrer_schemes,
87 std::vector<std::string>* savable_schemes) { 84 std::vector<std::string>* savable_schemes) {
88 for (int i = 0; i < kNumShellStandardURLSchemes; i++) 85 for (const url::SchemeWithType& standard_scheme : kShellStandardURLSchemes)
89 standard_schemes->push_back(kShellStandardURLSchemes[i]); 86 standard_schemes->push_back(standard_scheme);
90 87
91 savable_schemes->push_back(kExtensionScheme); 88 savable_schemes->push_back(kExtensionScheme);
92 savable_schemes->push_back(kExtensionResourceScheme);
93 } 89 }
94 90
95 std::string ShellContentClient::GetUserAgent() const { 91 std::string ShellContentClient::GetUserAgent() const {
96 // Must contain a user agent string for version sniffing. For example, 92 // Must contain a user agent string for version sniffing. For example,
97 // pluginless WebRTC Hangouts checks the Chrome version number. 93 // pluginless WebRTC Hangouts checks the Chrome version number.
98 return content::BuildUserAgentFromProduct("Chrome/" PRODUCT_VERSION); 94 return content::BuildUserAgentFromProduct("Chrome/" PRODUCT_VERSION);
99 } 95 }
100 96
101 base::string16 ShellContentClient::GetLocalizedString(int message_id) const { 97 base::string16 ShellContentClient::GetLocalizedString(int message_id) const {
102 return l10n_util::GetStringUTF16(message_id); 98 return l10n_util::GetStringUTF16(message_id);
103 } 99 }
104 100
105 base::StringPiece ShellContentClient::GetDataResource( 101 base::StringPiece ShellContentClient::GetDataResource(
106 int resource_id, 102 int resource_id,
107 ui::ScaleFactor scale_factor) const { 103 ui::ScaleFactor scale_factor) const {
108 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( 104 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
109 resource_id, scale_factor); 105 resource_id, scale_factor);
110 } 106 }
111 107
112 base::RefCountedMemory* ShellContentClient::GetDataResourceBytes( 108 base::RefCountedMemory* ShellContentClient::GetDataResourceBytes(
113 int resource_id) const { 109 int resource_id) const {
114 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); 110 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
115 } 111 }
116 112
117 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { 113 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const {
118 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); 114 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
119 } 115 }
120 116
121 } // namespace extensions 117 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698