[email protected] | 60aad9c | 2012-01-13 19:55:32 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 703e807a | 2009-03-28 19:56:51 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/extensions/extension_function.h" |
| 6 | |
[email protected] | 93d49d7 | 2009-10-23 20:00:20 | [diff] [blame] | 7 | #include "base/json/json_writer.h" |
[email protected] | 73404a37 | 2009-04-17 23:09:10 | [diff] [blame] | 8 | #include "base/logging.h" |
[email protected] | 07ad962 | 2013-01-18 23:00:33 | [diff] [blame] | 9 | #include "base/metrics/histogram.h" |
[email protected] | 703e807a | 2009-03-28 19:56:51 | [diff] [blame] | 10 | #include "chrome/browser/extensions/extension_function_dispatcher.h" |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 11 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 12 | #include "chrome/browser/extensions/window_controller.h" |
| 13 | #include "chrome/browser/extensions/window_controller_list.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 14 | #include "chrome/browser/profiles/profile.h" |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 15 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | f34efa2 | 2013-03-05 19:14:23 | [diff] [blame] | 16 | #include "chrome/browser/ui/browser.h" |
[email protected] | d874814 | 2012-05-16 21:13:43 | [diff] [blame] | 17 | #include "chrome/browser/ui/browser_finder.h" |
[email protected] | 91e51d61 | 2012-10-21 23:03:05 | [diff] [blame] | 18 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 19 | #include "chrome/common/extensions/extension_messages.h" |
[email protected] | 86ab86b | 2011-10-19 03:07:55 | [diff] [blame] | 20 | #include "content/public/browser/notification_source.h" |
[email protected] | 0d6e9bd | 2011-10-18 04:29:16 | [diff] [blame] | 21 | #include "content/public/browser/notification_types.h" |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 22 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 23 | #include "content/public/browser/render_view_host.h" |
[email protected] | 7f6f44c | 2011-12-14 13:23:38 | [diff] [blame] | 24 | #include "content/public/browser/user_metrics.h" |
[email protected] | b39ef1cb | 2011-10-25 04:46:55 | [diff] [blame] | 25 | #include "content/public/common/result_codes.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 26 | |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 27 | using content::BrowserThread; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 28 | using content::RenderViewHost; |
[email protected] | 7f6f44c | 2011-12-14 13:23:38 | [diff] [blame] | 29 | using content::UserMetricsAction; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 30 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 31 | // static |
| 32 | void ExtensionFunctionDeleteTraits::Destruct(const ExtensionFunction* x) { |
| 33 | x->Destruct(); |
| 34 | } |
| 35 | |
| 36 | UIThreadExtensionFunction::RenderViewHostTracker::RenderViewHostTracker( |
[email protected] | ce0e260 | 2013-03-15 20:53:27 | [diff] [blame] | 37 | UIThreadExtensionFunction* function) |
| 38 | : content::RenderViewHostObserver(function->render_view_host()), |
[email protected] | 0f7daaa | 2011-11-22 18:34:56 | [diff] [blame] | 39 | function_(function) { |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 40 | } |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 41 | |
[email protected] | 0f7daaa | 2011-11-22 18:34:56 | [diff] [blame] | 42 | void UIThreadExtensionFunction::RenderViewHostTracker::RenderViewHostDestroyed( |
| 43 | RenderViewHost* render_view_host) { |
| 44 | // Overidding the default behavior of RenderViewHostObserver which is to |
| 45 | // delete this. In our case, we'll be deleted when the |
| 46 | // UIThreadExtensionFunction that contains us goes away. |
[email protected] | ce0e260 | 2013-03-15 20:53:27 | [diff] [blame] | 47 | |
| 48 | function_->SetRenderViewHost(NULL); |
[email protected] | 0f7daaa | 2011-11-22 18:34:56 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | bool UIThreadExtensionFunction::RenderViewHostTracker::OnMessageReceived( |
| 52 | const IPC::Message& message) { |
| 53 | return function_->OnMessageReceivedFromRenderView(message); |
| 54 | } |
| 55 | |
[email protected] | 3a3d4747 | 2010-07-15 21:03:54 | [diff] [blame] | 56 | ExtensionFunction::ExtensionFunction() |
[email protected] | 9931fbfc | 2010-07-23 09:15:51 | [diff] [blame] | 57 | : request_id_(-1), |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 58 | profile_id_(NULL), |
[email protected] | 9931fbfc | 2010-07-23 09:15:51 | [diff] [blame] | 59 | has_callback_(false), |
[email protected] | 6451e33 | 2010-10-05 00:14:53 | [diff] [blame] | 60 | include_incognito_(false), |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 61 | user_gesture_(false), |
| 62 | args_(NULL), |
[email protected] | 07ad962 | 2013-01-18 23:00:33 | [diff] [blame] | 63 | bad_message_(false), |
| 64 | histogram_value_(extensions::functions::UNKNOWN) { |
[email protected] | 3a3d4747 | 2010-07-15 21:03:54 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | ExtensionFunction::~ExtensionFunction() { |
| 68 | } |
| 69 | |
[email protected] | 2ad65b3 | 2011-05-26 23:39:20 | [diff] [blame] | 70 | UIThreadExtensionFunction* ExtensionFunction::AsUIThreadExtensionFunction() { |
| 71 | return NULL; |
| 72 | } |
| 73 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 74 | IOThreadExtensionFunction* ExtensionFunction::AsIOThreadExtensionFunction() { |
| 75 | return NULL; |
| 76 | } |
| 77 | |
[email protected] | 3d0e226 | 2012-08-02 15:32:16 | [diff] [blame] | 78 | bool ExtensionFunction::HasPermission() { |
| 79 | return extension_->HasAPIPermission(name_); |
| 80 | } |
| 81 | |
[email protected] | 85231d7 | 2012-08-31 09:45:29 | [diff] [blame] | 82 | void ExtensionFunction::OnQuotaExceeded(const std::string& violation_error) { |
| 83 | error_ = violation_error; |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 84 | SendResponse(false); |
| 85 | } |
| 86 | |
[email protected] | 602542d | 2012-04-20 02:48:01 | [diff] [blame] | 87 | void ExtensionFunction::SetArgs(const base::ListValue* args) { |
[email protected] | 30294edf | 2009-11-10 00:24:38 | [diff] [blame] | 88 | DCHECK(!args_.get()); // Should only be called once. |
[email protected] | 16f47e08 | 2011-01-18 02:16:59 | [diff] [blame] | 89 | args_.reset(args->DeepCopy()); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 90 | } |
| 91 | |
[email protected] | 07ff5fd | 2012-07-12 22:39:09 | [diff] [blame] | 92 | void ExtensionFunction::SetResult(base::Value* result) { |
| 93 | results_.reset(new base::ListValue()); |
| 94 | results_->Append(result); |
| 95 | } |
| 96 | |
| 97 | const ListValue* ExtensionFunction::GetResultList() { |
| 98 | return results_.get(); |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 99 | } |
| 100 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 101 | const std::string ExtensionFunction::GetError() { |
[email protected] | 3a3d4747 | 2010-07-15 21:03:54 | [diff] [blame] | 102 | return error_; |
| 103 | } |
| 104 | |
[email protected] | 60aad9c | 2012-01-13 19:55:32 | [diff] [blame] | 105 | void ExtensionFunction::SetError(const std::string& error) { |
| 106 | error_ = error; |
| 107 | } |
| 108 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 109 | void ExtensionFunction::Run() { |
[email protected] | 07ad962 | 2013-01-18 23:00:33 | [diff] [blame] | 110 | UMA_HISTOGRAM_ENUMERATION("Extensions.FunctionCalls", histogram_value(), |
| 111 | extensions::functions::ENUM_BOUNDARY); |
| 112 | |
[email protected] | 3a3d4747 | 2010-07-15 21:03:54 | [diff] [blame] | 113 | if (!RunImpl()) |
| 114 | SendResponse(false); |
| 115 | } |
| 116 | |
[email protected] | 712627bf | 2012-04-30 03:21:04 | [diff] [blame] | 117 | bool ExtensionFunction::ShouldSkipQuotaLimiting() const { |
| 118 | return false; |
| 119 | } |
| 120 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 121 | bool ExtensionFunction::HasOptionalArgument(size_t index) { |
| 122 | Value* value; |
| 123 | return args_->Get(index, &value) && !value->IsType(Value::TYPE_NULL); |
| 124 | } |
| 125 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 126 | void ExtensionFunction::SendResponseImpl(base::ProcessHandle process, |
[email protected] | b44f8ad | 2012-06-15 20:52:58 | [diff] [blame] | 127 | IPC::Sender* ipc_sender, |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 128 | int routing_id, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 129 | bool success) { |
| 130 | DCHECK(ipc_sender); |
| 131 | if (bad_message_) { |
| 132 | HandleBadMessage(process); |
| 133 | return; |
| 134 | } |
| 135 | |
[email protected] | 07ff5fd | 2012-07-12 22:39:09 | [diff] [blame] | 136 | // If results were never set, we send an empty argument list. |
[email protected] | 3eeddd89 | 2013-04-17 17:00:11 | [diff] [blame] | 137 | if (!results_) |
[email protected] | 07ff5fd | 2012-07-12 22:39:09 | [diff] [blame] | 138 | results_.reset(new ListValue()); |
[email protected] | 602542d | 2012-04-20 02:48:01 | [diff] [blame] | 139 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 140 | ipc_sender->Send(new ExtensionMsg_Response( |
[email protected] | 6add194 | 2012-07-13 09:21:23 | [diff] [blame] | 141 | routing_id, request_id_, success, *results_, GetError())); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | void ExtensionFunction::HandleBadMessage(base::ProcessHandle process) { |
| 145 | LOG(ERROR) << "bad extension message " << name_ << " : terminating renderer."; |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 146 | if (content::RenderProcessHost::run_renderer_in_process()) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 147 | // In single process mode it is better if we don't suicide but just crash. |
| 148 | CHECK(false); |
| 149 | } else { |
[email protected] | 7cb19b4 | 2012-05-07 21:46:36 | [diff] [blame] | 150 | NOTREACHED(); |
[email protected] | 7f6f44c | 2011-12-14 13:23:38 | [diff] [blame] | 151 | content::RecordAction(UserMetricsAction("BadMessageTerminate_EFD")); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 152 | if (process) |
[email protected] | 1fcfb20 | 2011-07-19 19:53:14 | [diff] [blame] | 153 | base::KillProcess(process, content::RESULT_CODE_KILLED_BAD_MESSAGE, |
| 154 | false); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 155 | } |
| 156 | } |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 157 | UIThreadExtensionFunction::UIThreadExtensionFunction() |
[email protected] | bdfc03e | 2011-11-22 00:20:33 | [diff] [blame] | 158 | : render_view_host_(NULL), profile_(NULL), delegate_(NULL) { |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | UIThreadExtensionFunction::~UIThreadExtensionFunction() { |
[email protected] | 7042b68 | 2012-04-19 22:57:51 | [diff] [blame] | 162 | if (dispatcher() && render_view_host()) |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 163 | dispatcher()->OnExtensionFunctionCompleted(GetExtension()); |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 164 | } |
| 165 | |
[email protected] | 2ad65b3 | 2011-05-26 23:39:20 | [diff] [blame] | 166 | UIThreadExtensionFunction* |
| 167 | UIThreadExtensionFunction::AsUIThreadExtensionFunction() { |
| 168 | return this; |
| 169 | } |
| 170 | |
[email protected] | 0f7daaa | 2011-11-22 18:34:56 | [diff] [blame] | 171 | bool UIThreadExtensionFunction::OnMessageReceivedFromRenderView( |
| 172 | const IPC::Message& message) { |
| 173 | return false; |
| 174 | } |
| 175 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 176 | void UIThreadExtensionFunction::Destruct() const { |
| 177 | BrowserThread::DeleteOnUIThread::Destruct(this); |
| 178 | } |
| 179 | |
| 180 | void UIThreadExtensionFunction::SetRenderViewHost( |
| 181 | RenderViewHost* render_view_host) { |
| 182 | render_view_host_ = render_view_host; |
[email protected] | ce0e260 | 2013-03-15 20:53:27 | [diff] [blame] | 183 | tracker_.reset(render_view_host ? new RenderViewHostTracker(this) : NULL); |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 184 | } |
| 185 | |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 186 | // TODO(stevenjb): Replace this with GetExtensionWindowController(). |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 187 | Browser* UIThreadExtensionFunction::GetCurrentBrowser() { |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 188 | // If the delegate has an associated browser, return it. |
[email protected] | 3d6ac9e | 2012-07-20 23:12:31 | [diff] [blame] | 189 | if (dispatcher()) { |
| 190 | extensions::WindowController* window_controller = |
| 191 | dispatcher()->delegate()->GetExtensionWindowController(); |
| 192 | if (window_controller) { |
| 193 | Browser* browser = window_controller->GetBrowser(); |
| 194 | if (browser) |
| 195 | return browser; |
| 196 | } |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | // Otherwise, try to default to a reasonable browser. If |include_incognito_| |
| 200 | // is true, we will also search browsers in the incognito version of this |
| 201 | // profile. Note that the profile may already be incognito, in which case |
| 202 | // we will search the incognito version only, regardless of the value of |
[email protected] | 7f4a1d24 | 2012-12-05 05:55:57 | [diff] [blame] | 203 | // |include_incognito|. Look only for browsers on the active desktop as it is |
| 204 | // preferable to pretend no browser is open then to return a browser on |
| 205 | // another desktop. |
[email protected] | 7a689f0 | 2012-10-31 21:26:18 | [diff] [blame] | 206 | if (render_view_host_) { |
| 207 | Profile* profile = Profile::FromBrowserContext( |
| 208 | render_view_host_->GetProcess()->GetBrowserContext()); |
[email protected] | 3c6a095 | 2012-12-17 11:56:09 | [diff] [blame] | 209 | Browser* browser = chrome::FindAnyBrowser(profile, include_incognito_, |
| 210 | chrome::GetActiveDesktop()); |
[email protected] | 7a689f0 | 2012-10-31 21:26:18 | [diff] [blame] | 211 | if (browser) |
| 212 | return browser; |
| 213 | } |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 214 | |
| 215 | // NOTE(rafaelw): This can return NULL in some circumstances. In particular, |
| 216 | // a background_page onload chrome.tabs api call can make it into here |
[email protected] | 7a689f0 | 2012-10-31 21:26:18 | [diff] [blame] | 217 | // before the browser is sufficiently initialized to return here, or |
| 218 | // all of this profile's browser windows may have been closed. |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 219 | // A similar situation may arise during shutdown. |
| 220 | // TODO(rafaelw): Delay creation of background_page until the browser |
| 221 | // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
[email protected] | 7a689f0 | 2012-10-31 21:26:18 | [diff] [blame] | 222 | return NULL; |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 223 | } |
| 224 | |
[email protected] | 91e51d61 | 2012-10-21 23:03:05 | [diff] [blame] | 225 | content::WebContents* UIThreadExtensionFunction::GetAssociatedWebContents() { |
| 226 | if (dispatcher()) { |
| 227 | content::WebContents* web_contents = |
| 228 | dispatcher()->delegate()->GetAssociatedWebContents(); |
| 229 | if (web_contents) |
| 230 | return web_contents; |
| 231 | } |
| 232 | |
| 233 | Browser* browser = GetCurrentBrowser(); |
| 234 | if (!browser) |
| 235 | return NULL; |
| 236 | return browser->tab_strip_model()->GetActiveWebContents(); |
| 237 | } |
| 238 | |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 239 | extensions::WindowController* |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 240 | UIThreadExtensionFunction::GetExtensionWindowController() { |
| 241 | // If the delegate has an associated window controller, return it. |
[email protected] | 3d6ac9e | 2012-07-20 23:12:31 | [diff] [blame] | 242 | if (dispatcher()) { |
| 243 | extensions::WindowController* window_controller = |
| 244 | dispatcher()->delegate()->GetExtensionWindowController(); |
| 245 | if (window_controller) |
| 246 | return window_controller; |
| 247 | } |
[email protected] | b51f3562 | 2012-05-05 22:01:43 | [diff] [blame] | 248 | |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 249 | return extensions::WindowControllerList::GetInstance()-> |
| 250 | CurrentWindowForFunction(this); |
[email protected] | 31bdbfef | 2012-05-22 19:59:15 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | bool UIThreadExtensionFunction::CanOperateOnWindow( |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 254 | const extensions::WindowController* window_controller) const { |
[email protected] | 31bdbfef | 2012-05-22 19:59:15 | [diff] [blame] | 255 | const extensions::Extension* extension = GetExtension(); |
| 256 | // |extension| is NULL for unit tests only. |
| 257 | if (extension != NULL && !window_controller->IsVisibleToExtension(extension)) |
| 258 | return false; |
| 259 | |
| 260 | if (profile() == window_controller->profile()) |
| 261 | return true; |
| 262 | |
| 263 | if (!include_incognito()) |
| 264 | return false; |
| 265 | |
| 266 | return profile()->HasOffTheRecordProfile() && |
| 267 | profile()->GetOffTheRecordProfile() == window_controller->profile(); |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | void UIThreadExtensionFunction::SendResponse(bool success) { |
[email protected] | bdfc03e | 2011-11-22 00:20:33 | [diff] [blame] | 271 | if (delegate_) { |
[email protected] | ca6df68 | 2012-04-10 23:00:20 | [diff] [blame] | 272 | delegate_->OnSendResponse(this, success, bad_message_); |
[email protected] | bdfc03e | 2011-11-22 00:20:33 | [diff] [blame] | 273 | } else { |
| 274 | if (!render_view_host_ || !dispatcher()) |
| 275 | return; |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 276 | |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 277 | SendResponseImpl(render_view_host_->GetProcess()->GetHandle(), |
[email protected] | bdfc03e | 2011-11-22 00:20:33 | [diff] [blame] | 278 | render_view_host_, |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 279 | render_view_host_->GetRoutingID(), |
[email protected] | bdfc03e | 2011-11-22 00:20:33 | [diff] [blame] | 280 | success); |
| 281 | } |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 282 | } |
| 283 | |
[email protected] | c697007 | 2013-01-10 02:59:43 | [diff] [blame] | 284 | void UIThreadExtensionFunction::WriteToConsole( |
| 285 | content::ConsoleMessageLevel level, |
| 286 | const std::string& message) { |
| 287 | render_view_host_->Send(new ExtensionMsg_AddMessageToConsole( |
| 288 | render_view_host_->GetRoutingID(), level, message)); |
| 289 | } |
| 290 | |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 291 | IOThreadExtensionFunction::IOThreadExtensionFunction() |
| 292 | : routing_id_(-1) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | IOThreadExtensionFunction::~IOThreadExtensionFunction() { |
| 296 | } |
| 297 | |
| 298 | IOThreadExtensionFunction* |
| 299 | IOThreadExtensionFunction::AsIOThreadExtensionFunction() { |
| 300 | return this; |
| 301 | } |
| 302 | |
| 303 | void IOThreadExtensionFunction::Destruct() const { |
| 304 | BrowserThread::DeleteOnIOThread::Destruct(this); |
| 305 | } |
| 306 | |
| 307 | void IOThreadExtensionFunction::SendResponse(bool success) { |
| 308 | if (!ipc_sender()) |
| 309 | return; |
| 310 | |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 311 | SendResponseImpl(ipc_sender()->peer_handle(), |
| 312 | ipc_sender(), routing_id_, success); |
[email protected] | 703e807a | 2009-03-28 19:56:51 | [diff] [blame] | 313 | } |
[email protected] | 73404a37 | 2009-04-17 23:09:10 | [diff] [blame] | 314 | |
[email protected] | bdfc03e | 2011-11-22 00:20:33 | [diff] [blame] | 315 | AsyncExtensionFunction::AsyncExtensionFunction() { |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | AsyncExtensionFunction::~AsyncExtensionFunction() { |
[email protected] | 35213ce9 | 2010-04-08 19:06:15 | [diff] [blame] | 319 | } |
[email protected] | 3a3d4747 | 2010-07-15 21:03:54 | [diff] [blame] | 320 | |
| 321 | SyncExtensionFunction::SyncExtensionFunction() { |
| 322 | } |
| 323 | |
| 324 | SyncExtensionFunction::~SyncExtensionFunction() { |
| 325 | } |
| 326 | |
| 327 | void SyncExtensionFunction::Run() { |
| 328 | SendResponse(RunImpl()); |
| 329 | } |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 330 | |
| 331 | SyncIOThreadExtensionFunction::SyncIOThreadExtensionFunction() { |
| 332 | } |
| 333 | |
| 334 | SyncIOThreadExtensionFunction::~SyncIOThreadExtensionFunction() { |
| 335 | } |
| 336 | |
| 337 | void SyncIOThreadExtensionFunction::Run() { |
| 338 | SendResponse(RunImpl()); |
| 339 | } |