OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 void set_source_tab_id(int source_tab_id) { source_tab_id_ = source_tab_id; } | 271 void set_source_tab_id(int source_tab_id) { source_tab_id_ = source_tab_id; } |
272 int source_tab_id() const { return source_tab_id_; } | 272 int source_tab_id() const { return source_tab_id_; } |
273 | 273 |
274 void set_source_context_type(extensions::Feature::Context type) { | 274 void set_source_context_type(extensions::Feature::Context type) { |
275 source_context_type_ = type; | 275 source_context_type_ = type; |
276 } | 276 } |
277 extensions::Feature::Context source_context_type() const { | 277 extensions::Feature::Context source_context_type() const { |
278 return source_context_type_; | 278 return source_context_type_; |
279 } | 279 } |
280 | 280 |
| 281 void set_source_process_id(int source_process_id) { |
| 282 source_process_id_ = source_process_id; |
| 283 } |
| 284 int source_process_id() const { |
| 285 return source_process_id_; |
| 286 } |
| 287 |
281 protected: | 288 protected: |
282 friend struct ExtensionFunctionDeleteTraits; | 289 friend struct ExtensionFunctionDeleteTraits; |
283 | 290 |
284 // ResponseValues. | 291 // ResponseValues. |
285 // | 292 // |
286 // Success, no arguments to pass to caller. | 293 // Success, no arguments to pass to caller. |
287 ResponseValue NoArguments(); | 294 ResponseValue NoArguments(); |
288 // Success, a single argument |arg| to pass to caller. TAKES OWNERSHIP - a | 295 // Success, a single argument |arg| to pass to caller. TAKES OWNERSHIP - a |
289 // raw pointer for convenience, since callers usually construct the argument | 296 // raw pointer for convenience, since callers usually construct the argument |
290 // to this by hand. | 297 // to this by hand. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 424 |
418 // The callback to run once the function has done execution. | 425 // The callback to run once the function has done execution. |
419 ResponseCallback response_callback_; | 426 ResponseCallback response_callback_; |
420 | 427 |
421 // The ID of the tab triggered this function call, or -1 if there is no tab. | 428 // The ID of the tab triggered this function call, or -1 if there is no tab. |
422 int source_tab_id_; | 429 int source_tab_id_; |
423 | 430 |
424 // The type of the JavaScript context where this call originated. | 431 // The type of the JavaScript context where this call originated. |
425 extensions::Feature::Context source_context_type_; | 432 extensions::Feature::Context source_context_type_; |
426 | 433 |
| 434 // The process ID of the page that triggered this function call, or -1 |
| 435 // if unknown. |
| 436 int source_process_id_; |
| 437 |
427 private: | 438 private: |
428 void OnRespondingLater(ResponseValue response); | 439 void OnRespondingLater(ResponseValue response); |
429 | 440 |
430 DISALLOW_COPY_AND_ASSIGN(ExtensionFunction); | 441 DISALLOW_COPY_AND_ASSIGN(ExtensionFunction); |
431 }; | 442 }; |
432 | 443 |
433 // Extension functions that run on the UI thread. Most functions fall into | 444 // Extension functions that run on the UI thread. Most functions fall into |
434 // this category. | 445 // this category. |
435 class UIThreadExtensionFunction : public ExtensionFunction { | 446 class UIThreadExtensionFunction : public ExtensionFunction { |
436 public: | 447 public: |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); | 673 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); |
663 | 674 |
664 private: | 675 private: |
665 // If you're hitting a compile error here due to "final" - great! You're | 676 // If you're hitting a compile error here due to "final" - great! You're |
666 // doing the right thing, you just need to extend IOThreadExtensionFunction | 677 // doing the right thing, you just need to extend IOThreadExtensionFunction |
667 // instead of SyncIOExtensionFunction. | 678 // instead of SyncIOExtensionFunction. |
668 ResponseAction Run() final; | 679 ResponseAction Run() final; |
669 }; | 680 }; |
670 | 681 |
671 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 682 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
OLD | NEW |