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/chrome_render_view_observer.h" | 5 #include "chrome/renderer/chrome_render_view_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 using WebKit::WebIconURL; | 63 using WebKit::WebIconURL; |
64 using WebKit::WebRect; | 64 using WebKit::WebRect; |
65 using WebKit::WebSecurityOrigin; | 65 using WebKit::WebSecurityOrigin; |
66 using WebKit::WebSize; | 66 using WebKit::WebSize; |
67 using WebKit::WebString; | 67 using WebKit::WebString; |
68 using WebKit::WebTouchEvent; | 68 using WebKit::WebTouchEvent; |
69 using WebKit::WebURL; | 69 using WebKit::WebURL; |
70 using WebKit::WebURLRequest; | 70 using WebKit::WebURLRequest; |
71 using WebKit::WebView; | 71 using WebKit::WebView; |
72 using WebKit::WebVector; | 72 using WebKit::WebVector; |
73 using extensions::APIPermission; | |
73 using webkit_glue::ImageResourceFetcher; | 74 using webkit_glue::ImageResourceFetcher; |
74 | 75 |
75 // Delay in milliseconds that we'll wait before capturing the page contents | 76 // Delay in milliseconds that we'll wait before capturing the page contents |
76 // and thumbnail. | 77 // and thumbnail. |
77 static const int kDelayForCaptureMs = 500; | 78 static const int kDelayForCaptureMs = 500; |
78 | 79 |
79 // Typically, we capture the page data once the page is loaded. | 80 // Typically, we capture the page data once the page is loaded. |
80 // Sometimes, the page never finishes to load, preventing the page capture | 81 // Sometimes, the page never finishes to load, preventing the page capture |
81 // To workaround this problem, we always perform a capture after the following | 82 // To workaround this problem, we always perform a capture after the following |
82 // delay. | 83 // delay. |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 bool default_value) { | 478 bool default_value) { |
478 bool allowed = false; | 479 bool allowed = false; |
479 Send(new ChromeViewHostMsg_CanTriggerClipboardWrite( | 480 Send(new ChromeViewHostMsg_CanTriggerClipboardWrite( |
480 routing_id(), GURL(frame->document().securityOrigin().toString().utf8()), | 481 routing_id(), GURL(frame->document().securityOrigin().toString().utf8()), |
481 &allowed)); | 482 &allowed)); |
482 return allowed; | 483 return allowed; |
483 } | 484 } |
484 | 485 |
485 bool ChromeRenderViewObserver::IsExperimentalWebFeatureAllowed( | 486 bool ChromeRenderViewObserver::IsExperimentalWebFeatureAllowed( |
486 const WebDocument& document) { | 487 const WebDocument& document) { |
487 // Experimental Web API is enabled when | 488 // Experimental Web API is enabled when: |
488 // - The specific API is allowed from command line flag, or | 489 // The document is running Web UI. |
489 // - If the document is running extensions or apps which | |
490 // has the "experimental" permission, or | |
491 // - The document is running Web UI. | |
492 WebSecurityOrigin origin = document.securityOrigin(); | 490 WebSecurityOrigin origin = document.securityOrigin(); |
493 if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme)) | 491 if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme)) |
494 return true; | 492 return true; |
495 const extensions::Extension* extension = | 493 |
496 extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 494 // The document is running extensions or apps which has the "experimental" |
497 ExtensionURLInfo(origin, document.url())); | 495 // permission, or use the <browser> tag (which is implemented via Shadow DOM). |
498 if (!extension) | 496 if (EqualsASCII(origin.protocol(), chrome::kExtensionScheme)) { |
499 return false; | 497 const std::string extension_id = origin.host().utf8().data(); |
500 return (extension_dispatcher_->IsExtensionActive(extension->id()) && | 498 if (!extension_dispatcher_->IsExtensionActive(extension_id)) |
501 extension->HasAPIPermission( | 499 return false; |
502 extensions::APIPermission::kExperimental)); | 500 const extensions::Extension* extension = |
501 extension_dispatcher_->extensions()->GetByID(extension_id); | |
502 if (!extension) | |
503 return false; | |
504 return extension->HasAPIPermission(APIPermission::kExperimental) || | |
505 extension->HasAPIPermission(APIPermission::kBrowserTag); | |
Aaron Boodman
2012/07/02 20:52:35
Is it possible to just check for the browser permi
Mihai Parparita -not on Chrome
2012/07/02 22:05:14
I don't see an easy way to do this (enable it for
Aaron Boodman
2012/07/02 23:04:37
Oh, I see the issue. My earlier comment was mistak
Mihai Parparita -not on Chrome
2012/07/02 23:23:45
Did something along these lines.
| |
506 } | |
507 | |
508 return false; | |
503 } | 509 } |
504 | 510 |
505 bool ChromeRenderViewObserver::allowWebComponents(const WebDocument& document, | 511 bool ChromeRenderViewObserver::allowWebComponents(const WebDocument& document, |
506 bool defaultValue) { | 512 bool defaultValue) { |
507 if (defaultValue) | 513 if (defaultValue) |
508 return true; | 514 return true; |
509 return IsExperimentalWebFeatureAllowed(document); | 515 return IsExperimentalWebFeatureAllowed(document); |
510 } | 516 } |
511 | 517 |
512 static void SendInsecureContentSignal(int signal) { | 518 static void SendInsecureContentSignal(int signal) { |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 reinterpret_cast<const unsigned char*>(&data[0]); | 1079 reinterpret_cast<const unsigned char*>(&data[0]); |
1074 | 1080 |
1075 return decoder.Decode(src_data, data.size()); | 1081 return decoder.Decode(src_data, data.size()); |
1076 } | 1082 } |
1077 return SkBitmap(); | 1083 return SkBitmap(); |
1078 } | 1084 } |
1079 | 1085 |
1080 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { | 1086 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { |
1081 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); | 1087 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); |
1082 } | 1088 } |
OLD | NEW |