| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/content_settings_observer.h" | 5 #include "chrome/renderer/content_settings_observer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return permissions->second; | 413 return permissions->second; |
| 414 | 414 |
| 415 Send(new ChromeViewHostMsg_AllowDOMStorage( | 415 Send(new ChromeViewHostMsg_AllowDOMStorage( |
| 416 routing_id(), GURL(frame->securityOrigin().toString()), | 416 routing_id(), GURL(frame->securityOrigin().toString()), |
| 417 GURL(frame->top()->securityOrigin().toString()), local, &result)); | 417 GURL(frame->top()->securityOrigin().toString()), local, &result)); |
| 418 cached_storage_permissions_[key] = result; | 418 cached_storage_permissions_[key] = result; |
| 419 return result; | 419 return result; |
| 420 } | 420 } |
| 421 | 421 |
| 422 bool ContentSettingsObserver::allowReadFromClipboard(bool default_value) { | 422 bool ContentSettingsObserver::allowReadFromClipboard(bool default_value) { |
| 423 bool allowed = false; | 423 bool allowed = default_value; |
| 424 #if defined(ENABLE_EXTENSIONS) | 424 #if defined(ENABLE_EXTENSIONS) |
| 425 extensions::ScriptContext* calling_context = | 425 extensions::ScriptContext* calling_context = |
| 426 extension_dispatcher_->script_context_set().GetCalling(); | 426 extension_dispatcher_->script_context_set().GetCalling(); |
| 427 if (calling_context) { | 427 if (calling_context) { |
| 428 allowed = calling_context->HasAPIPermission( | 428 allowed |= calling_context->HasAPIPermission( |
| 429 extensions::APIPermission::kClipboardRead); | 429 extensions::APIPermission::kClipboardRead); |
| 430 } | 430 } |
| 431 #endif | 431 #endif |
| 432 return allowed; | 432 return allowed; |
| 433 } | 433 } |
| 434 | 434 |
| 435 bool ContentSettingsObserver::allowWriteToClipboard(bool default_value) { | 435 bool ContentSettingsObserver::allowWriteToClipboard(bool default_value) { |
| 436 bool allowed = false; | 436 bool allowed = default_value; |
| 437 #if defined(ENABLE_EXTENSIONS) | 437 #if defined(ENABLE_EXTENSIONS) |
| 438 // All blessed extension pages could historically write to the clipboard, so | 438 // All blessed extension pages could historically write to the clipboard, so |
| 439 // preserve that for compatibility. | 439 // preserve that for compatibility. |
| 440 extensions::ScriptContext* calling_context = | 440 extensions::ScriptContext* calling_context = |
| 441 extension_dispatcher_->script_context_set().GetCalling(); | 441 extension_dispatcher_->script_context_set().GetCalling(); |
| 442 if (calling_context) { | 442 if (calling_context) { |
| 443 if (calling_context->effective_context_type() == | 443 if (calling_context->effective_context_type() == |
| 444 extensions::Feature::BLESSED_EXTENSION_CONTEXT) { | 444 extensions::Feature::BLESSED_EXTENSION_CONTEXT) { |
| 445 allowed = true; | 445 allowed = true; |
| 446 } else { | 446 } else { |
| 447 allowed = calling_context->HasAPIPermission( | 447 allowed |= calling_context->HasAPIPermission( |
| 448 extensions::APIPermission::kClipboardWrite); | 448 extensions::APIPermission::kClipboardWrite); |
| 449 } | 449 } |
| 450 } | 450 } |
| 451 #endif | 451 #endif |
| 452 return allowed; | 452 return allowed; |
| 453 } | 453 } |
| 454 | 454 |
| 455 bool ContentSettingsObserver::allowMutationEvents(bool default_value) { | 455 bool ContentSettingsObserver::allowMutationEvents(bool default_value) { |
| 456 return IsPlatformApp() ? false : default_value; | 456 return IsPlatformApp() ? false : default_value; |
| 457 } | 457 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 | 717 |
| 718 // If the scheme is file:, an empty file name indicates a directory listing, | 718 // If the scheme is file:, an empty file name indicates a directory listing, |
| 719 // which requires JavaScript to function properly. | 719 // which requires JavaScript to function properly. |
| 720 if (EqualsASCII(origin.protocol(), url::kFileScheme)) { | 720 if (EqualsASCII(origin.protocol(), url::kFileScheme)) { |
| 721 return document_url.SchemeIs(url::kFileScheme) && | 721 return document_url.SchemeIs(url::kFileScheme) && |
| 722 document_url.ExtractFileName().empty(); | 722 document_url.ExtractFileName().empty(); |
| 723 } | 723 } |
| 724 | 724 |
| 725 return false; | 725 return false; |
| 726 } | 726 } |
| OLD | NEW |