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

Side by Side Diff: chrome/renderer/content_settings_observer.cc

Issue 789063002: Implement clipboardRead/Write content capabilities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
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/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 cached_storage_permissions_[key] = result; 408 cached_storage_permissions_[key] = result;
409 return result; 409 return result;
410 } 410 }
411 411
412 bool ContentSettingsObserver::allowReadFromClipboard(bool default_value) { 412 bool ContentSettingsObserver::allowReadFromClipboard(bool default_value) {
413 bool allowed = false; 413 bool allowed = false;
414 #if defined(ENABLE_EXTENSIONS) 414 #if defined(ENABLE_EXTENSIONS)
415 extensions::ScriptContext* calling_context = 415 extensions::ScriptContext* calling_context =
416 extension_dispatcher_->script_context_set().GetCalling(); 416 extension_dispatcher_->script_context_set().GetCalling();
417 if (calling_context) { 417 if (calling_context) {
418 const extensions::Extension* extension = 418 allowed = calling_context->HasEffectiveAPIPermission(
419 calling_context->effective_extension(); 419 extensions::APIPermission::kClipboardRead);
420 allowed = extension &&
421 extension->permissions_data()->HasAPIPermission(
422 extensions::APIPermission::kClipboardRead);
423 } 420 }
424 #endif 421 #endif
425 return allowed; 422 return allowed;
426 } 423 }
427 424
428 bool ContentSettingsObserver::allowWriteToClipboard(bool default_value) { 425 bool ContentSettingsObserver::allowWriteToClipboard(bool default_value) {
429 bool allowed = false; 426 bool allowed = false;
430 #if defined(ENABLE_EXTENSIONS) 427 #if defined(ENABLE_EXTENSIONS)
431 // All blessed extension pages could historically write to the clipboard, so 428 // All blessed extension pages could historically write to the clipboard, so
432 // preserve that for compatibility. 429 // preserve that for compatibility.
433 extensions::ScriptContext* calling_context = 430 extensions::ScriptContext* calling_context =
434 extension_dispatcher_->script_context_set().GetCalling(); 431 extension_dispatcher_->script_context_set().GetCalling();
435 if (calling_context) { 432 if (calling_context) {
436 if (calling_context->effective_context_type() == 433 if (calling_context->effective_context_type() ==
437 extensions::Feature::BLESSED_EXTENSION_CONTEXT) { 434 extensions::Feature::BLESSED_EXTENSION_CONTEXT) {
438 allowed = true; 435 allowed = true;
439 } else { 436 } else {
440 const extensions::Extension* extension = 437 allowed = calling_context->HasEffectiveAPIPermission(
441 calling_context->effective_extension(); 438 extensions::APIPermission::kClipboardWrite);
442 allowed = extension &&
443 extension->permissions_data()->HasAPIPermission(
444 extensions::APIPermission::kClipboardWrite);
445 } 439 }
446 } 440 }
447 #endif 441 #endif
448 return allowed; 442 return allowed;
449 } 443 }
450 444
451 bool ContentSettingsObserver::allowMutationEvents(bool default_value) { 445 bool ContentSettingsObserver::allowMutationEvents(bool default_value) {
452 return IsPlatformApp() ? false : default_value; 446 return IsPlatformApp() ? false : default_value;
453 } 447 }
454 448
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 709
716 // If the scheme is file:, an empty file name indicates a directory listing, 710 // If the scheme is file:, an empty file name indicates a directory listing,
717 // which requires JavaScript to function properly. 711 // which requires JavaScript to function properly.
718 if (EqualsASCII(origin.protocol(), url::kFileScheme)) { 712 if (EqualsASCII(origin.protocol(), url::kFileScheme)) {
719 return document_url.SchemeIs(url::kFileScheme) && 713 return document_url.SchemeIs(url::kFileScheme) &&
720 document_url.ExtractFileName().empty(); 714 document_url.ExtractFileName().empty();
721 } 715 }
722 716
723 return false; 717 return false;
724 } 718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698