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

Side by Side Diff: extensions/browser/extension_function_dispatcher.cc

Issue 646983008: Implement signin using webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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/browser/extension_function_dispatcher.h" 5 #include "extensions/browser/extension_function_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/metrics/sparse_histogram.h" 12 #include "base/metrics/sparse_histogram.h"
13 #include "base/process/process.h" 13 #include "base/process/process.h"
14 #include "base/strings/string_util.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/render_frame_host.h" 18 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_view_host.h" 20 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/user_metrics.h" 21 #include "content/public/browser/user_metrics.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_contents_observer.h" 23 #include "content/public/browser/web_contents_observer.h"
23 #include "content/public/common/result_codes.h" 24 #include "content/public/common/result_codes.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // static 225 // static
225 void ExtensionFunctionDispatcher::DispatchOnIOThread( 226 void ExtensionFunctionDispatcher::DispatchOnIOThread(
226 InfoMap* extension_info_map, 227 InfoMap* extension_info_map,
227 void* profile_id, 228 void* profile_id,
228 int render_process_id, 229 int render_process_id,
229 base::WeakPtr<ExtensionMessageFilter> ipc_sender, 230 base::WeakPtr<ExtensionMessageFilter> ipc_sender,
230 int routing_id, 231 int routing_id,
231 const ExtensionHostMsg_Request_Params& params) { 232 const ExtensionHostMsg_Request_Params& params) {
232 const Extension* extension = 233 const Extension* extension =
233 extension_info_map->extensions().GetByID(params.extension_id); 234 extension_info_map->extensions().GetByID(params.extension_id);
234 if (!extension) 235 const std::string& extension_id = extension ?
Fady Samuel 2014/10/21 21:32:57 I'd prefer if these changes were in a separate CL.
guohui 2014/10/22 15:35:33 Done.
235 return; 236 extension->id() : base::EmptyString();
236 237
237 ExtensionFunction::ResponseCallback callback( 238 ExtensionFunction::ResponseCallback callback(
238 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id, 239 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id,
239 params.request_id)); 240 params.request_id));
240 241
241 scoped_refptr<ExtensionFunction> function( 242 scoped_refptr<ExtensionFunction> function(
242 CreateExtensionFunction(params, 243 CreateExtensionFunction(params,
243 extension, 244 extension,
244 render_process_id, 245 render_process_id,
245 extension_info_map->process_map(), 246 extension_info_map->process_map(),
246 g_global_io_data.Get().api.get(), 247 g_global_io_data.Get().api.get(),
247 profile_id, 248 profile_id,
248 callback)); 249 callback));
249 if (!function.get()) 250 if (!function.get())
250 return; 251 return;
251 252
252 IOThreadExtensionFunction* function_io = 253 IOThreadExtensionFunction* function_io =
253 function->AsIOThreadExtensionFunction(); 254 function->AsIOThreadExtensionFunction();
254 if (!function_io) { 255 if (!function_io) {
255 NOTREACHED(); 256 NOTREACHED();
256 return; 257 return;
257 } 258 }
258 function_io->set_ipc_sender(ipc_sender, routing_id); 259 function_io->set_ipc_sender(ipc_sender, routing_id);
259 function_io->set_extension_info_map(extension_info_map); 260 function_io->set_extension_info_map(extension_info_map);
260 function->set_include_incognito( 261 function->set_include_incognito(
261 extension_info_map->IsIncognitoEnabled(extension->id())); 262 extension_info_map->IsIncognitoEnabled(extension_id));
262 263
263 if (!CheckPermissions(function.get(), params, callback)) 264 if (!CheckPermissions(function.get(), params, callback))
264 return; 265 return;
265 266
266 QuotaService* quota = extension_info_map->GetQuotaService(); 267 QuotaService* quota = extension_info_map->GetQuotaService();
267 std::string violation_error = quota->Assess(extension->id(), 268 std::string violation_error = quota->Assess(
268 function.get(), 269 extension_id, function.get(), &params.arguments, base::TimeTicks::Now());
269 &params.arguments,
270 base::TimeTicks::Now());
271 if (violation_error.empty()) { 270 if (violation_error.empty()) {
272 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); 271 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy());
273 NotifyApiFunctionCalled(extension->id(), 272 NotifyApiFunctionCalled(extension_id,
274 params.name, 273 params.name,
275 args.Pass(), 274 args.Pass(),
276 static_cast<content::BrowserContext*>(profile_id)); 275 static_cast<content::BrowserContext*>(profile_id));
277 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls", 276 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls",
278 function->histogram_value()); 277 function->histogram_value());
279 function->Run()->Execute(); 278 function->Run()->Execute();
280 } else { 279 } else {
281 function->OnQuotaExceeded(violation_error); 280 function->OnQuotaExceeded(violation_error);
282 } 281 }
283 } 282 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 463
465 // static 464 // static
466 void ExtensionFunctionDispatcher::SendAccessDenied( 465 void ExtensionFunctionDispatcher::SendAccessDenied(
467 const ExtensionFunction::ResponseCallback& callback) { 466 const ExtensionFunction::ResponseCallback& callback) {
468 base::ListValue empty_list; 467 base::ListValue empty_list;
469 callback.Run(ExtensionFunction::FAILED, empty_list, 468 callback.Run(ExtensionFunction::FAILED, empty_list,
470 "Access to extension API denied."); 469 "Access to extension API denied.");
471 } 470 }
472 471
473 } // namespace extensions 472 } // namespace extensions
OLDNEW
« extensions/browser/extension_function.h ('K') | « extensions/browser/extension_function.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698