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

Side by Side Diff: extensions/browser/extension_function.h

Issue 444133003: Try run for https://codereview.chromium.org/426593007. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: app view fix 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/event_router.cc ('k') | extensions/browser/extension_function.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 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
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/process/process.h" 16 #include "base/process/process.h"
17 #include "base/sequenced_task_runner_helpers.h" 17 #include "base/sequenced_task_runner_helpers.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/common/console_message_level.h" 19 #include "content/public/common/console_message_level.h"
20 #include "extensions/browser/extension_function_histogram_value.h" 20 #include "extensions/browser/extension_function_histogram_value.h"
21 #include "extensions/browser/info_map.h" 21 #include "extensions/browser/info_map.h"
22 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
23 #include "extensions/common/features/feature.h"
23 #include "ipc/ipc_message.h" 24 #include "ipc/ipc_message.h"
24 25
25 class ExtensionFunction; 26 class ExtensionFunction;
26 class UIThreadExtensionFunction; 27 class UIThreadExtensionFunction;
27 class IOThreadExtensionFunction; 28 class IOThreadExtensionFunction;
28 29
29 namespace base { 30 namespace base {
30 class ListValue; 31 class ListValue;
31 class Value; 32 class Value;
32 } 33 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 extensions::functions::HistogramValue histogram_value() const { 240 extensions::functions::HistogramValue histogram_value() const {
240 return histogram_value_; } 241 return histogram_value_; }
241 242
242 void set_response_callback(const ResponseCallback& callback) { 243 void set_response_callback(const ResponseCallback& callback) {
243 response_callback_ = callback; 244 response_callback_ = callback;
244 } 245 }
245 246
246 void set_source_tab_id(int source_tab_id) { source_tab_id_ = source_tab_id; } 247 void set_source_tab_id(int source_tab_id) { source_tab_id_ = source_tab_id; }
247 int source_tab_id() const { return source_tab_id_; } 248 int source_tab_id() const { return source_tab_id_; }
248 249
250 void set_source_context_type(extensions::Feature::Context type) {
251 source_context_type_ = type;
252 }
253 extensions::Feature::Context source_context_type() const {
254 return source_context_type_;
255 }
256
249 protected: 257 protected:
250 friend struct ExtensionFunctionDeleteTraits; 258 friend struct ExtensionFunctionDeleteTraits;
251 259
252 // ResponseValues. 260 // ResponseValues.
253 // 261 //
254 // Success, no arguments to pass to caller 262 // Success, no arguments to pass to caller
255 ResponseValue NoArguments(); 263 ResponseValue NoArguments();
256 // Success, a single argument |arg| to pass to caller. TAKES OWNERSHIP -- a 264 // Success, a single argument |arg| to pass to caller. TAKES OWNERSHIP -- a
257 // raw pointer for convenience, since callers usually construct the argument 265 // raw pointer for convenience, since callers usually construct the argument
258 // to this by hand. 266 // to this by hand.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // The sample value to record with the histogram API when the function 373 // The sample value to record with the histogram API when the function
366 // is invoked. 374 // is invoked.
367 extensions::functions::HistogramValue histogram_value_; 375 extensions::functions::HistogramValue histogram_value_;
368 376
369 // The callback to run once the function has done execution. 377 // The callback to run once the function has done execution.
370 ResponseCallback response_callback_; 378 ResponseCallback response_callback_;
371 379
372 // The ID of the tab triggered this function call, or -1 if there is no tab. 380 // The ID of the tab triggered this function call, or -1 if there is no tab.
373 int source_tab_id_; 381 int source_tab_id_;
374 382
383 // The type of the JavaScript context where this call originated.
384 extensions::Feature::Context source_context_type_;
385
375 private: 386 private:
376 void OnRespondingLater(ResponseValue response); 387 void OnRespondingLater(ResponseValue response);
377 388
378 DISALLOW_COPY_AND_ASSIGN(ExtensionFunction); 389 DISALLOW_COPY_AND_ASSIGN(ExtensionFunction);
379 }; 390 };
380 391
381 // Extension functions that run on the UI thread. Most functions fall into 392 // Extension functions that run on the UI thread. Most functions fall into
382 // this category. 393 // this category.
383 class UIThreadExtensionFunction : public ExtensionFunction { 394 class UIThreadExtensionFunction : public ExtensionFunction {
384 public: 395 public:
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 virtual bool RunSync() = 0; 605 virtual bool RunSync() = 0;
595 606
596 // ValidationFailure override to match RunSync(). 607 // ValidationFailure override to match RunSync().
597 static bool ValidationFailure(SyncIOThreadExtensionFunction* function); 608 static bool ValidationFailure(SyncIOThreadExtensionFunction* function);
598 609
599 private: 610 private:
600 virtual ResponseAction Run() OVERRIDE; 611 virtual ResponseAction Run() OVERRIDE;
601 }; 612 };
602 613
603 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 614 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
OLDNEW
« no previous file with comments | « extensions/browser/event_router.cc ('k') | extensions/browser/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698