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 #include "extensions/browser/extension_function.h" | 5 #include "extensions/browser/extension_function.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
18 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
21 #include "extensions/browser/extension_function_dispatcher.h" | 21 #include "extensions/browser/extension_function_dispatcher.h" |
22 #include "extensions/browser/extension_message_filter.h" | 22 #include "extensions/browser/extension_message_filter.h" |
| 23 #include "extensions/browser/extension_util.h" |
23 #include "extensions/browser/extensions_browser_client.h" | 24 #include "extensions/browser/extensions_browser_client.h" |
24 #include "extensions/common/error_utils.h" | 25 #include "extensions/common/error_utils.h" |
25 #include "extensions/common/extension_api.h" | 26 #include "extensions/common/extension_api.h" |
26 #include "extensions/common/extension_messages.h" | 27 #include "extensions/common/extension_messages.h" |
27 | 28 |
28 using content::BrowserThread; | 29 using content::BrowserThread; |
29 using content::RenderViewHost; | 30 using content::RenderViewHost; |
30 using content::WebContents; | 31 using content::WebContents; |
31 using extensions::ErrorUtils; | 32 using extensions::ErrorUtils; |
32 using extensions::ExtensionAPI; | 33 using extensions::ExtensionAPI; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 return NULL; | 286 return NULL; |
286 } | 287 } |
287 | 288 |
288 IOThreadExtensionFunction* ExtensionFunction::AsIOThreadExtensionFunction() { | 289 IOThreadExtensionFunction* ExtensionFunction::AsIOThreadExtensionFunction() { |
289 return NULL; | 290 return NULL; |
290 } | 291 } |
291 | 292 |
292 bool ExtensionFunction::HasPermission() { | 293 bool ExtensionFunction::HasPermission() { |
293 Feature::Availability availability = | 294 Feature::Availability availability = |
294 ExtensionAPI::GetSharedInstance()->IsAvailable( | 295 ExtensionAPI::GetSharedInstance()->IsAvailable( |
295 name_, extension_.get(), source_context_type_, source_url()); | 296 name_, extension_.get(), source_context_type_, |
| 297 extensions::util::GetCurrentSessionType(), source_url()); |
296 return availability.is_available(); | 298 return availability.is_available(); |
297 } | 299 } |
298 | 300 |
299 void ExtensionFunction::OnQuotaExceeded(const std::string& violation_error) { | 301 void ExtensionFunction::OnQuotaExceeded(const std::string& violation_error) { |
300 error_ = violation_error; | 302 error_ = violation_error; |
301 SendResponse(false); | 303 SendResponse(false); |
302 } | 304 } |
303 | 305 |
304 void ExtensionFunction::SetArgs(const base::ListValue* args) { | 306 void ExtensionFunction::SetArgs(const base::ListValue* args) { |
305 DCHECK(!args_.get()); // Should only be called once. | 307 DCHECK(!args_.get()); // Should only be called once. |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 636 |
635 ExtensionFunction::ResponseAction SyncExtensionFunction::Run() { | 637 ExtensionFunction::ResponseAction SyncExtensionFunction::Run() { |
636 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) | 638 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) |
637 : Error(error_)); | 639 : Error(error_)); |
638 } | 640 } |
639 | 641 |
640 // static | 642 // static |
641 bool SyncExtensionFunction::ValidationFailure(SyncExtensionFunction* function) { | 643 bool SyncExtensionFunction::ValidationFailure(SyncExtensionFunction* function) { |
642 return false; | 644 return false; |
643 } | 645 } |
OLD | NEW |