| 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_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 404 |
| 405 SkBitmap* ChromeContentRendererClient::GetSadWebViewBitmap() { | 405 SkBitmap* ChromeContentRendererClient::GetSadWebViewBitmap() { |
| 406 return const_cast<SkBitmap*>(ResourceBundle::GetSharedInstance(). | 406 return const_cast<SkBitmap*>(ResourceBundle::GetSharedInstance(). |
| 407 GetImageNamed(IDR_SAD_WEBVIEW).ToSkBitmap()); | 407 GetImageNamed(IDR_SAD_WEBVIEW).ToSkBitmap()); |
| 408 } | 408 } |
| 409 | 409 |
| 410 std::string ChromeContentRendererClient::GetDefaultEncoding() { | 410 std::string ChromeContentRendererClient::GetDefaultEncoding() { |
| 411 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); | 411 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); |
| 412 } | 412 } |
| 413 | 413 |
| 414 const Extension* ChromeContentRendererClient::GetExtension( | 414 const Extension* ChromeContentRendererClient::GetExtensionByOrigin( |
| 415 const WebSecurityOrigin& origin) const { | 415 const WebSecurityOrigin& origin) const { |
| 416 if (!EqualsASCII(origin.protocol(), extensions::kExtensionScheme)) | 416 if (!EqualsASCII(origin.protocol(), extensions::kExtensionScheme)) |
| 417 return NULL; | 417 return NULL; |
| 418 | 418 |
| 419 const std::string extension_id = origin.host().utf8().data(); | 419 const std::string extension_id = origin.host().utf8().data(); |
| 420 if (!extension_dispatcher_->IsExtensionActive(extension_id)) | |
| 421 return NULL; | |
| 422 | |
| 423 return extension_dispatcher_->extensions()->GetByID(extension_id); | 420 return extension_dispatcher_->extensions()->GetByID(extension_id); |
| 424 } | 421 } |
| 425 | 422 |
| 426 bool ChromeContentRendererClient::OverrideCreatePlugin( | 423 bool ChromeContentRendererClient::OverrideCreatePlugin( |
| 427 content::RenderView* render_view, | 424 content::RenderView* render_view, |
| 428 WebFrame* frame, | 425 WebFrame* frame, |
| 429 const WebPluginParams& params, | 426 const WebPluginParams& params, |
| 430 WebPlugin** plugin) { | 427 WebPlugin** plugin) { |
| 431 std::string orig_mime_type = params.mimeType.utf8(); | 428 std::string orig_mime_type = params.mimeType.utf8(); |
| 432 if (orig_mime_type == content::kBrowserPluginMimeType) { | 429 if (orig_mime_type == content::kBrowserPluginMimeType) { |
| 433 if (CommandLine::ForCurrentProcess()->HasSwitch( | 430 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 434 switches::kEnableBrowserPluginForAllViewTypes)) | 431 switches::kEnableBrowserPluginForAllViewTypes)) |
| 435 return false; | 432 return false; |
| 436 WebDocument document = frame->document(); | 433 WebDocument document = frame->document(); |
| 437 const Extension* extension = | 434 const Extension* extension = |
| 438 GetExtension(document.securityOrigin()); | 435 GetExtensionByOrigin(document.securityOrigin()); |
| 439 if (extension) { | 436 if (extension) { |
| 440 const extensions::APIPermission::ID perms[] = { | 437 const extensions::APIPermission::ID perms[] = { |
| 441 extensions::APIPermission::kWebView, | 438 extensions::APIPermission::kWebView, |
| 442 extensions::APIPermission::kAdView | 439 extensions::APIPermission::kAdView |
| 443 }; | 440 }; |
| 444 for (size_t i = 0; i < arraysize(perms); ++i) { | 441 for (size_t i = 0; i < arraysize(perms); ++i) { |
| 445 if (extension->HasAPIPermission(perms[i])) | 442 if (extension->HasAPIPermission(perms[i])) |
| 446 return false; | 443 return false; |
| 447 } | 444 } |
| 448 } | 445 } |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 // SiteIsolationPolicy is off by default. We would like to activate cross-site | 1322 // SiteIsolationPolicy is off by default. We would like to activate cross-site |
| 1326 // document blocking (for UMA data collection) for normal renderer processes | 1323 // document blocking (for UMA data collection) for normal renderer processes |
| 1327 // running a normal web page from the Internet. We only turn on | 1324 // running a normal web page from the Internet. We only turn on |
| 1328 // SiteIsolationPolicy for a renderer process that does not have the extension | 1325 // SiteIsolationPolicy for a renderer process that does not have the extension |
| 1329 // flag on. | 1326 // flag on. |
| 1330 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1327 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1331 return !command_line->HasSwitch(switches::kExtensionProcess); | 1328 return !command_line->HasSwitch(switches::kExtensionProcess); |
| 1332 } | 1329 } |
| 1333 | 1330 |
| 1334 } // namespace chrome | 1331 } // namespace chrome |
| OLD | NEW |