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

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

Issue 10824198: Move small c/b/extensions classes into extensions namespace no.1 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest-er master for cq Created 8 years, 4 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 (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/browser/extensions/extension_function_dispatcher.h" 5 #include "chrome/browser/extensions/extension_function_dispatcher.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/process_util.h" 12 #include "base/process_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/extensions/extension_activity_log.h" 15 #include "chrome/browser/extensions/activity_log.h"
16 #include "chrome/browser/extensions/extension_function.h" 16 #include "chrome/browser/extensions/extension_function.h"
17 #include "chrome/browser/extensions/extension_function_registry.h" 17 #include "chrome/browser/extensions/extension_function_registry.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/extension_web_ui.h" 19 #include "chrome/browser/extensions/extension_web_ui.h"
20 #include "chrome/browser/extensions/extensions_quota_service.h" 20 #include "chrome/browser/extensions/extensions_quota_service.h"
21 #include "chrome/browser/extensions/process_map.h" 21 #include "chrome/browser/extensions/process_map.h"
22 #include "chrome/browser/external_protocol/external_protocol_handler.h" 22 #include "chrome/browser/external_protocol/external_protocol_handler.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 24 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
25 #include "chrome/common/extensions/api/extension_api.h" 25 #include "chrome/common/extensions/api/extension_api.h"
(...skipping 12 matching lines...) Expand all
38 using content::RenderViewHost; 38 using content::RenderViewHost;
39 using WebKit::WebSecurityOrigin; 39 using WebKit::WebSecurityOrigin;
40 40
41 namespace { 41 namespace {
42 42
43 const char kAccessDenied[] = "access denied"; 43 const char kAccessDenied[] = "access denied";
44 const char kQuotaExceeded[] = "quota exceeded"; 44 const char kQuotaExceeded[] = "quota exceeded";
45 45
46 void LogSuccess(const Extension* extension, 46 void LogSuccess(const Extension* extension,
47 const ExtensionHostMsg_Request_Params& params) { 47 const ExtensionHostMsg_Request_Params& params) {
48 ExtensionActivityLog* extension_activity_log = 48 extensions::ActivityLog* activity_log =
49 ExtensionActivityLog::GetInstance(); 49 extensions::ActivityLog::GetInstance();
50 if (extension_activity_log->HasObservers(extension)) { 50 if (activity_log->HasObservers(extension)) {
51 std::string call_signature = params.name + "("; 51 std::string call_signature = params.name + "(";
52 ListValue::const_iterator it = params.arguments.begin(); 52 ListValue::const_iterator it = params.arguments.begin();
53 for (; it != params.arguments.end(); ++it) { 53 for (; it != params.arguments.end(); ++it) {
54 std::string arg; 54 std::string arg;
55 JSONStringValueSerializer serializer(&arg); 55 JSONStringValueSerializer serializer(&arg);
56 if (serializer.SerializeAndOmitBinaryValues(**it)) { 56 if (serializer.SerializeAndOmitBinaryValues(**it)) {
57 if (it != params.arguments.begin()) 57 if (it != params.arguments.begin())
58 call_signature += ", "; 58 call_signature += ", ";
59 call_signature += arg; 59 call_signature += arg;
60 } 60 }
61 } 61 }
62 call_signature += ")"; 62 call_signature += ")";
63 63
64 extension_activity_log->Log( 64 activity_log->Log(extension,
65 extension, 65 extensions::ActivityLog::ACTIVITY_EXTENSION_API_CALL,
66 ExtensionActivityLog::ACTIVITY_EXTENSION_API_CALL, 66 call_signature);
67 call_signature);
68 } 67 }
69 } 68 }
70 69
71 void LogFailure(const Extension* extension, 70 void LogFailure(const Extension* extension,
72 const std::string& func_name, 71 const std::string& func_name,
73 const char* reason) { 72 const char* reason) {
74 ExtensionActivityLog* extension_activity_log = 73 extensions::ActivityLog* activity_log =
75 ExtensionActivityLog::GetInstance(); 74 extensions::ActivityLog::GetInstance();
76 if (extension_activity_log->HasObservers(extension)) { 75 if (activity_log->HasObservers(extension)) {
77 extension_activity_log->Log( 76 activity_log->Log(extension,
78 extension, 77 extensions::ActivityLog::ACTIVITY_EXTENSION_API_BLOCK,
79 ExtensionActivityLog::ACTIVITY_EXTENSION_API_BLOCK, 78 func_name + ": " + reason);
80 func_name + ": " + reason);
81 } 79 }
82 } 80 }
83 81
84 // Separate copy of ExtensionAPI used for IO thread extension functions. We need 82 // Separate copy of ExtensionAPI used for IO thread extension functions. We need
85 // this because ExtensionAPI has mutable data. It should be possible to remove 83 // this because ExtensionAPI has mutable data. It should be possible to remove
86 // this once all the extension APIs are updated to the feature system. 84 // this once all the extension APIs are updated to the feature system.
87 struct Static { 85 struct Static {
88 Static() 86 Static()
89 : api(extensions::ExtensionAPI::CreateWithDefaultConfiguration()) { 87 : api(extensions::ExtensionAPI::CreateWithDefaultConfiguration()) {
90 } 88 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 292 }
295 293
296 // static 294 // static
297 void ExtensionFunctionDispatcher::SendAccessDenied( 295 void ExtensionFunctionDispatcher::SendAccessDenied(
298 IPC::Sender* ipc_sender, int routing_id, int request_id) { 296 IPC::Sender* ipc_sender, int routing_id, int request_id) {
299 ListValue empty_list; 297 ListValue empty_list;
300 ipc_sender->Send(new ExtensionMsg_Response( 298 ipc_sender->Send(new ExtensionMsg_Response(
301 routing_id, request_id, false, empty_list, 299 routing_id, request_id, false, empty_list,
302 "Access to extension API denied.")); 300 "Access to extension API denied."));
303 } 301 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698