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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc

Issue 2436903003: Extract ArcSupportMessageHost. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/chromeos/arc/extensions/arc_support_message_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/api/messaging/native_message_host.h" 5 #include "extensions/browser/api/messaging/native_message_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chromeos/arc/arc_support_host.h" 20 #include "chrome/browser/chromeos/arc/extensions/arc_support_message_host.h"
21 #include "components/policy/core/common/policy_service.h" 21 #include "components/policy/core/common/policy_service.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "extensions/common/constants.h" 23 #include "extensions/common/constants.h"
24 #include "extensions/common/url_pattern.h" 24 #include "extensions/common/url_pattern.h"
25 #include "net/url_request/url_request_context_getter.h" 25 #include "net/url_request/url_request_context_getter.h"
26 #include "remoting/host/chromoting_host_context.h" 26 #include "remoting/host/chromoting_host_context.h"
27 #include "remoting/host/it2me/it2me_native_messaging_host.h" 27 #include "remoting/host/it2me/it2me_native_messaging_host.h"
28 #include "ui/gfx/native_widget_types.h" 28 #include "ui/gfx/native_widget_types.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 "chrome-extension://gbchcmhmhahfdphkhkmpfmihenigjmpp/", 122 "chrome-extension://gbchcmhmhahfdphkhkmpfmihenigjmpp/",
123 "chrome-extension://kgngmbheleoaphbjbaiobfdepmghbfah/", 123 "chrome-extension://kgngmbheleoaphbjbaiobfdepmghbfah/",
124 "chrome-extension://odkaodonbgfohohmklejpjiejmcipmib/", 124 "chrome-extension://odkaodonbgfohohmklejpjiejmcipmib/",
125 "chrome-extension://dokpleeekgeeiehdhmdkeimnkmoifgdd/", 125 "chrome-extension://dokpleeekgeeiehdhmdkeimnkmoifgdd/",
126 "chrome-extension://ajoainacpilcemgiakehflpbkbfipojk/", 126 "chrome-extension://ajoainacpilcemgiakehflpbkbfipojk/",
127 "chrome-extension://hmboipgjngjoiaeicfdifdoeacilalgc/", 127 "chrome-extension://hmboipgjngjoiaeicfdifdoeacilalgc/",
128 "chrome-extension://inomeogfingihgjfjlpeplalcfajhgai/", 128 "chrome-extension://inomeogfingihgjfjlpeplalcfajhgai/",
129 "chrome-extension://hpodccmdligbeohchckkeajbfohibipg/"}; 129 "chrome-extension://hpodccmdligbeohchckkeajbfohibipg/"};
130 130
131 static const BuiltInHost kBuiltInHost[] = { 131 static const BuiltInHost kBuiltInHost[] = {
132 {"com.google.chrome.test.echo", // ScopedTestNativeMessagingHost::kHostName 132 {"com.google.chrome.test.echo", // ScopedTestNativeMessagingHost::kHostName
133 kEchoHostOrigins, 133 kEchoHostOrigins, arraysize(kEchoHostOrigins), &EchoHost::Create},
134 arraysize(kEchoHostOrigins), 134 {"com.google.chrome.remote_assistance", kRemotingIt2MeOrigins,
135 &EchoHost::Create}, 135 arraysize(kRemotingIt2MeOrigins), &CreateIt2MeHost},
136 {"com.google.chrome.remote_assistance", 136 {arc::ArcSupportMessageHost::kHostName,
137 kRemotingIt2MeOrigins, 137 arc::ArcSupportMessageHost::kHostOrigin, 1,
138 arraysize(kRemotingIt2MeOrigins), 138 &arc::ArcSupportMessageHost::Create},
139 &CreateIt2MeHost},
140 {ArcSupportHost::kHostName,
141 ArcSupportHost::kHostOrigin,
142 1,
143 &ArcSupportHost::Create},
144 }; 139 };
145 140
146 bool MatchesSecurityOrigin(const BuiltInHost& host, 141 bool MatchesSecurityOrigin(const BuiltInHost& host,
147 const std::string& extension_id) { 142 const std::string& extension_id) {
148 GURL origin(std::string(kExtensionScheme) + "://" + extension_id); 143 GURL origin(std::string(kExtensionScheme) + "://" + extension_id);
149 for (int i = 0; i < host.allowed_origins_count; i++) { 144 for (int i = 0; i < host.allowed_origins_count; i++) {
150 URLPattern allowed_origin(URLPattern::SCHEME_ALL, host.allowed_origins[i]); 145 URLPattern allowed_origin(URLPattern::SCHEME_ALL, host.allowed_origins[i]);
151 if (allowed_origin.MatchesSecurityOrigin(origin)) { 146 if (allowed_origin.MatchesSecurityOrigin(origin)) {
152 return true; 147 return true;
153 } 148 }
(...skipping 18 matching lines...) Expand all
172 } 167 }
173 *error = kForbiddenError; 168 *error = kForbiddenError;
174 return nullptr; 169 return nullptr;
175 } 170 }
176 } 171 }
177 *error = kNotFoundError; 172 *error = kNotFoundError;
178 return nullptr; 173 return nullptr;
179 } 174 }
180 175
181 } // namespace extensions 176 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/extensions/arc_support_message_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698