OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/string_tokenizer.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chrome/common/child_process_logging.h" | 16 #include "chrome/common/child_process_logging.h" |
16 #include "chrome/common/chrome_content_client.h" | 17 #include "chrome/common/chrome_content_client.h" |
17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/content_settings_pattern.h" | 20 #include "chrome/common/content_settings_pattern.h" |
20 #include "chrome/common/external_ipc_fuzzer.h" | 21 #include "chrome/common/external_ipc_fuzzer.h" |
21 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 using WebKit::WebURLError; | 97 using WebKit::WebURLError; |
97 using WebKit::WebURLRequest; | 98 using WebKit::WebURLRequest; |
98 using WebKit::WebURLResponse; | 99 using WebKit::WebURLResponse; |
99 using WebKit::WebVector; | 100 using WebKit::WebVector; |
100 using autofill::AutofillAgent; | 101 using autofill::AutofillAgent; |
101 using autofill::PasswordAutofillManager; | 102 using autofill::PasswordAutofillManager; |
102 using content::RenderThread; | 103 using content::RenderThread; |
103 | 104 |
104 namespace { | 105 namespace { |
105 | 106 |
| 107 const char* kPredefinedAllowedSocketOrigins[] = { |
| 108 "okddffdblfhhnmhodogpojmfkjmhinfp" // SSH Client |
| 109 }; |
| 110 |
106 static void AppendParams(const std::vector<string16>& additional_names, | 111 static void AppendParams(const std::vector<string16>& additional_names, |
107 const std::vector<string16>& additional_values, | 112 const std::vector<string16>& additional_values, |
108 WebVector<WebString>* existing_names, | 113 WebVector<WebString>* existing_names, |
109 WebVector<WebString>* existing_values) { | 114 WebVector<WebString>* existing_values) { |
110 DCHECK(additional_names.size() == additional_values.size()); | 115 DCHECK(additional_names.size() == additional_values.size()); |
111 DCHECK(existing_names->size() == existing_values->size()); | 116 DCHECK(existing_names->size() == existing_values->size()); |
112 | 117 |
113 size_t existing_size = existing_names->size(); | 118 size_t existing_size = existing_names->size(); |
114 size_t total_size = existing_size + additional_names.size(); | 119 size_t total_size = existing_size + additional_names.size(); |
115 | 120 |
(...skipping 13 matching lines...) Expand all Loading... |
129 existing_names->swap(names); | 134 existing_names->swap(names); |
130 existing_values->swap(values); | 135 existing_values->swap(values); |
131 } | 136 } |
132 | 137 |
133 } // namespace | 138 } // namespace |
134 | 139 |
135 namespace chrome { | 140 namespace chrome { |
136 | 141 |
137 ChromeContentRendererClient::ChromeContentRendererClient() | 142 ChromeContentRendererClient::ChromeContentRendererClient() |
138 : spellcheck_provider_(NULL) { | 143 : spellcheck_provider_(NULL) { |
| 144 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| 145 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| 146 |
| 147 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 148 std::string allowed_list = |
| 149 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); |
| 150 if (!allowed_list.empty()) { |
| 151 StringTokenizer t(allowed_list, ","); |
| 152 while (t.GetNext()) { |
| 153 allowed_socket_origins_.insert(t.token()); |
| 154 } |
| 155 } |
139 } | 156 } |
140 | 157 |
141 ChromeContentRendererClient::~ChromeContentRendererClient() { | 158 ChromeContentRendererClient::~ChromeContentRendererClient() { |
142 } | 159 } |
143 | 160 |
144 void ChromeContentRendererClient::RenderThreadStarted() { | 161 void ChromeContentRendererClient::RenderThreadStarted() { |
145 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); | 162 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); |
146 extension_dispatcher_.reset(new ExtensionDispatcher()); | 163 extension_dispatcher_.reset(new ExtensionDispatcher()); |
147 histogram_snapshots_.reset(new RendererHistogramSnapshots()); | 164 histogram_snapshots_.reset(new RendererHistogramSnapshots()); |
148 net_predictor_.reset(new RendererNetPredictor()); | 165 net_predictor_.reset(new RendererNetPredictor()); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 805 |
789 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { | 806 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { |
790 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); | 807 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); |
791 } | 808 } |
792 | 809 |
793 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( | 810 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( |
794 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { | 811 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { |
795 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); | 812 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); |
796 } | 813 } |
797 | 814 |
| 815 bool ChromeContentRendererClient::AllowSocketAPI(const GURL& url) { |
| 816 return allowed_socket_origins_.find(url.host()) != |
| 817 allowed_socket_origins_.end(); |
| 818 } |
| 819 |
798 } // namespace chrome | 820 } // namespace chrome |
OLD | NEW |