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

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

Issue 481433005: Extensions: Move id_util functions to crx_file component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert last patchset. function returns Extension* and can't use an assert. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « extensions/browser/error_map_unittest.cc ('k') | extensions/browser/extension_prefs.cc » ('j') | 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/extension_message_filter.h" 5 #include "extensions/browser/extension_message_filter.h"
6 6
7 #include "components/crx_file/id_util.h"
7 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
8 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
9 #include "content/public/browser/resource_dispatcher_host.h" 10 #include "content/public/browser/resource_dispatcher_host.h"
10 #include "extensions/browser/blob_holder.h" 11 #include "extensions/browser/blob_holder.h"
11 #include "extensions/browser/event_router.h" 12 #include "extensions/browser/event_router.h"
12 #include "extensions/browser/extension_function_dispatcher.h" 13 #include "extensions/browser/extension_function_dispatcher.h"
13 #include "extensions/browser/extension_system.h" 14 #include "extensions/browser/extension_system.h"
14 #include "extensions/browser/info_map.h" 15 #include "extensions/browser/info_map.h"
15 #include "extensions/browser/process_manager.h" 16 #include "extensions/browser/process_manager.h"
16 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const std::string& extension_id, 99 const std::string& extension_id,
99 const GURL& listener_url, 100 const GURL& listener_url,
100 const std::string& event_name) { 101 const std::string& event_name) {
101 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_); 102 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_);
102 if (!process) 103 if (!process)
103 return; 104 return;
104 EventRouter* router = EventRouter::Get(browser_context_); 105 EventRouter* router = EventRouter::Get(browser_context_);
105 if (!router) 106 if (!router)
106 return; 107 return;
107 108
108 if (Extension::IdIsValid(extension_id)) { 109 if (crx_file::id_util::IdIsValid(extension_id)) {
109 router->AddEventListener(event_name, process, extension_id); 110 router->AddEventListener(event_name, process, extension_id);
110 } else if (listener_url.is_valid()) { 111 } else if (listener_url.is_valid()) {
111 router->AddEventListenerForURL(event_name, process, listener_url); 112 router->AddEventListenerForURL(event_name, process, listener_url);
112 } else { 113 } else {
113 NOTREACHED() << "Tried to add an event listener without a valid " 114 NOTREACHED() << "Tried to add an event listener without a valid "
114 << "extension ID nor listener URL"; 115 << "extension ID nor listener URL";
115 } 116 }
116 } 117 }
117 118
118 void ExtensionMessageFilter::OnExtensionRemoveListener( 119 void ExtensionMessageFilter::OnExtensionRemoveListener(
119 const std::string& extension_id, 120 const std::string& extension_id,
120 const GURL& listener_url, 121 const GURL& listener_url,
121 const std::string& event_name) { 122 const std::string& event_name) {
122 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_); 123 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_);
123 if (!process) 124 if (!process)
124 return; 125 return;
125 EventRouter* router = EventRouter::Get(browser_context_); 126 EventRouter* router = EventRouter::Get(browser_context_);
126 if (!router) 127 if (!router)
127 return; 128 return;
128 129
129 if (Extension::IdIsValid(extension_id)) { 130 if (crx_file::id_util::IdIsValid(extension_id)) {
130 router->RemoveEventListener(event_name, process, extension_id); 131 router->RemoveEventListener(event_name, process, extension_id);
131 } else if (listener_url.is_valid()) { 132 } else if (listener_url.is_valid()) {
132 router->RemoveEventListenerForURL(event_name, process, listener_url); 133 router->RemoveEventListenerForURL(event_name, process, listener_url);
133 } else { 134 } else {
134 NOTREACHED() << "Tried to remove an event listener without a valid " 135 NOTREACHED() << "Tried to remove an event listener without a valid "
135 << "extension ID nor listener URL"; 136 << "extension ID nor listener URL";
136 } 137 }
137 } 138 }
138 139
139 void ExtensionMessageFilter::OnExtensionAddLazyListener( 140 void ExtensionMessageFilter::OnExtensionAddLazyListener(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 ExtensionFunctionDispatcher::DispatchOnIOThread( 224 ExtensionFunctionDispatcher::DispatchOnIOThread(
224 extension_info_map_.get(), 225 extension_info_map_.get(),
225 browser_context_, 226 browser_context_,
226 render_process_id_, 227 render_process_id_,
227 weak_ptr_factory_.GetWeakPtr(), 228 weak_ptr_factory_.GetWeakPtr(),
228 routing_id, 229 routing_id,
229 params); 230 params);
230 } 231 }
231 232
232 } // namespace extensions 233 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/error_map_unittest.cc ('k') | extensions/browser/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698