Chromium Code Reviews| 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 bool PepperPluginInstanceImpl::Initialize( | 800 bool PepperPluginInstanceImpl::Initialize( |
| 801 const std::vector<std::string>& arg_names, | 801 const std::vector<std::string>& arg_names, |
| 802 const std::vector<std::string>& arg_values, | 802 const std::vector<std::string>& arg_values, |
| 803 bool full_frame, | 803 bool full_frame, |
| 804 scoped_ptr<PluginInstanceThrottlerImpl> throttler) { | 804 scoped_ptr<PluginInstanceThrottlerImpl> throttler) { |
| 805 DCHECK(!throttler_); | 805 DCHECK(!throttler_); |
| 806 | 806 |
| 807 if (!render_frame_) | 807 if (!render_frame_) |
| 808 return false; | 808 return false; |
| 809 | 809 |
| 810 // Get plugin dimensions directly. | |
| 811 blink::WebElement element = container()->element(); | |
| 812 blink::WebRect bounds = element.boundsInViewportSpace(); | |
| 813 gfx::Size size(bounds.width, bounds.height); | |
| 814 | |
| 815 // Plugins are sometimes only partially visible. This is to support content | |
| 816 // that may expand. Walk up the DOM tree here to find a parent container | |
| 817 // that is smaller, and use that as the plugin's effective visible size. | |
| 818 blink::WebNode node = element.parentNode(); | |
| 819 while (!node.isNull() && node.isElementNode()) { | |
| 820 blink::WebRect bounds = node.to<WebElement>().boundsInViewportSpace(); | |
| 821 size.SetToMin(gfx::Size(bounds.width, bounds.height)); | |
| 822 node = node.parentNode(); | |
| 823 } | |
|
piman
2015/03/18 01:58:57
This seems crazy. It's also most likely wrong beca
tommycli
2015/03/19 22:10:13
Hi piman,
The clip rect passed to ViewChanged was
| |
| 824 | |
| 810 if (is_flash_plugin_ && RenderThread::Get()) { | 825 if (is_flash_plugin_ && RenderThread::Get()) { |
| 811 RenderThread::Get()->RecordAction( | 826 RenderThread::Get()->RecordAction( |
| 812 base::UserMetricsAction("Flash.PluginInstanceCreated")); | 827 base::UserMetricsAction("Flash.PluginInstanceCreated")); |
| 813 blink::WebRect bounds = container()->element().boundsInViewportSpace(); | 828 RecordFlashSizeMetric(size.width(), size.height()); |
| 814 RecordFlashSizeMetric(bounds.width, bounds.height); | |
| 815 } | 829 } |
| 816 | 830 |
| 817 if (throttler) { | 831 if (throttler) { |
| 818 throttler_ = throttler.Pass(); | 832 throttler_ = throttler.Pass(); |
| 819 throttler_->AddObserver(this); | 833 throttler_->AddObserver(this); |
| 820 throttler_->Initialize(render_frame_, plugin_url_.GetOrigin(), | 834 throttler_->Initialize(render_frame_, plugin_url_.GetOrigin(), |
| 821 module()->name(), | 835 module()->name(), size); |
| 822 container()->element().boundsInViewportSpace()); | |
| 823 } | 836 } |
| 824 | 837 |
| 825 message_channel_ = MessageChannel::Create(this, &message_channel_object_); | 838 message_channel_ = MessageChannel::Create(this, &message_channel_object_); |
| 826 | 839 |
| 827 full_frame_ = full_frame; | 840 full_frame_ = full_frame; |
| 828 | 841 |
| 829 UpdateTouchEventRequest(); | 842 UpdateTouchEventRequest(); |
| 830 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); | 843 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); |
| 831 | 844 |
| 832 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build( | 845 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build( |
| (...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3316 | 3329 |
| 3317 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { | 3330 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { |
| 3318 if (initialized_ && !javascript_used_ && is_flash_plugin_) { | 3331 if (initialized_ && !javascript_used_ && is_flash_plugin_) { |
| 3319 javascript_used_ = true; | 3332 javascript_used_ = true; |
| 3320 RenderThread::Get()->RecordAction( | 3333 RenderThread::Get()->RecordAction( |
| 3321 base::UserMetricsAction("Flash.JavaScriptUsed")); | 3334 base::UserMetricsAction("Flash.JavaScriptUsed")); |
| 3322 } | 3335 } |
| 3323 } | 3336 } |
| 3324 | 3337 |
| 3325 } // namespace content | 3338 } // namespace content |
| OLD | NEW |