| 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 <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" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 using WebKit::WebURLError; | 99 using WebKit::WebURLError; |
| 100 using WebKit::WebURLRequest; | 100 using WebKit::WebURLRequest; |
| 101 using WebKit::WebURLResponse; | 101 using WebKit::WebURLResponse; |
| 102 using WebKit::WebVector; | 102 using WebKit::WebVector; |
| 103 using autofill::AutofillAgent; | 103 using autofill::AutofillAgent; |
| 104 using autofill::PasswordAutofillManager; | 104 using autofill::PasswordAutofillManager; |
| 105 using content::RenderThread; | 105 using content::RenderThread; |
| 106 | 106 |
| 107 namespace { | 107 namespace { |
| 108 | 108 |
| 109 const char* kPredefinedAllowedSocketOrigins[] = { | |
| 110 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client | |
| 111 "pnhechapfaindjhompbnflcldabbghjo" // HTerm App (SSH Client) | |
| 112 }; | |
| 113 | |
| 114 static void AppendParams(const std::vector<string16>& additional_names, | 109 static void AppendParams(const std::vector<string16>& additional_names, |
| 115 const std::vector<string16>& additional_values, | 110 const std::vector<string16>& additional_values, |
| 116 WebVector<WebString>* existing_names, | 111 WebVector<WebString>* existing_names, |
| 117 WebVector<WebString>* existing_values) { | 112 WebVector<WebString>* existing_values) { |
| 118 DCHECK(additional_names.size() == additional_values.size()); | 113 DCHECK(additional_names.size() == additional_values.size()); |
| 119 DCHECK(existing_names->size() == existing_values->size()); | 114 DCHECK(existing_names->size() == existing_values->size()); |
| 120 | 115 |
| 121 size_t existing_size = existing_names->size(); | 116 size_t existing_size = existing_names->size(); |
| 122 size_t total_size = existing_size + additional_names.size(); | 117 size_t total_size = existing_size + additional_names.size(); |
| 123 | 118 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 136 | 131 |
| 137 existing_names->swap(names); | 132 existing_names->swap(names); |
| 138 existing_values->swap(values); | 133 existing_values->swap(values); |
| 139 } | 134 } |
| 140 | 135 |
| 141 } // namespace | 136 } // namespace |
| 142 | 137 |
| 143 namespace chrome { | 138 namespace chrome { |
| 144 | 139 |
| 145 ChromeContentRendererClient::ChromeContentRendererClient() { | 140 ChromeContentRendererClient::ChromeContentRendererClient() { |
| 146 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) | |
| 147 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); | |
| 148 | |
| 149 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 150 std::string allowed_list = | |
| 151 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); | |
| 152 if (!allowed_list.empty()) { | |
| 153 StringTokenizer t(allowed_list, ","); | |
| 154 while (t.GetNext()) { | |
| 155 allowed_socket_origins_.insert(t.token()); | |
| 156 } | |
| 157 } | |
| 158 } | 141 } |
| 159 | 142 |
| 160 ChromeContentRendererClient::~ChromeContentRendererClient() { | 143 ChromeContentRendererClient::~ChromeContentRendererClient() { |
| 161 } | 144 } |
| 162 | 145 |
| 163 void ChromeContentRendererClient::RenderThreadStarted() { | 146 void ChromeContentRendererClient::RenderThreadStarted() { |
| 164 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); | 147 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); |
| 165 extension_dispatcher_.reset(new ExtensionDispatcher()); | 148 extension_dispatcher_.reset(new ExtensionDispatcher()); |
| 166 histogram_snapshots_.reset(new RendererHistogramSnapshots()); | 149 histogram_snapshots_.reset(new RendererHistogramSnapshots()); |
| 167 net_predictor_.reset(new RendererNetPredictor()); | 150 net_predictor_.reset(new RendererNetPredictor()); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 | 837 |
| 855 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { | 838 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { |
| 856 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); | 839 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); |
| 857 } | 840 } |
| 858 | 841 |
| 859 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( | 842 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( |
| 860 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { | 843 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { |
| 861 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); | 844 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); |
| 862 } | 845 } |
| 863 | 846 |
| 864 bool ChromeContentRendererClient::AllowSocketAPI(const GURL& url) { | |
| 865 return allowed_socket_origins_.find(url.host()) != | |
| 866 allowed_socket_origins_.end(); | |
| 867 } | |
| 868 | |
| 869 } // namespace chrome | 847 } // namespace chrome |
| OLD | NEW |