Index: components/plugins/renderer/webview_plugin.cc |
diff --git a/chrome/renderer/plugins/webview_plugin.cc b/components/plugins/renderer/webview_plugin.cc |
similarity index 80% |
rename from chrome/renderer/plugins/webview_plugin.cc |
rename to components/plugins/renderer/webview_plugin.cc |
index 2853a3133eca5d6fe3f91798240c68a8a5e32cd2..20969d5d7a1b074a8aafdbcb4a97c68f55ef57e1 100644 |
--- a/chrome/renderer/plugins/webview_plugin.cc |
+++ b/components/plugins/renderer/webview_plugin.cc |
@@ -1,11 +1,12 @@ |
-// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/renderer/plugins/webview_plugin.h" |
+#include "components/plugins/renderer/webview_plugin.h" |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/histogram.h" |
+#include "base/safe_numerics.h" |
#include "content/public/renderer/web_preferences.h" |
#include "skia/ext/platform_canvas.h" |
#include "third_party/WebKit/public/platform/WebSize.h" |
@@ -42,9 +43,7 @@ using WebKit::WebVector; |
using WebKit::WebView; |
WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate) |
- : delegate_(delegate), |
- container_(NULL), |
- finished_loading_(false) { |
+ : delegate_(delegate), container_(NULL), finished_loading_(false) { |
web_view_ = WebView::create(this); |
web_view_->initializeMainFrame(this); |
} |
@@ -61,21 +60,24 @@ WebViewPlugin* WebViewPlugin::Create(WebViewPlugin::Delegate* delegate, |
return plugin; |
} |
-WebViewPlugin::~WebViewPlugin() { |
- web_view_->close(); |
-} |
+WebViewPlugin::~WebViewPlugin() { web_view_->close(); } |
void WebViewPlugin::ReplayReceivedData(WebPlugin* plugin) { |
if (!response_.isNull()) { |
plugin->didReceiveResponse(response_); |
size_t total_bytes = 0; |
- for (std::list<std::string>::iterator it = data_.begin(); |
- it != data_.end(); ++it) { |
- plugin->didReceiveData(it->c_str(), it->length()); |
+ for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); |
+ ++it) { |
+ plugin->didReceiveData( |
+ it->c_str(), base::checked_numeric_cast<int, size_t>(it->length())); |
total_bytes += it->length(); |
} |
- UMA_HISTOGRAM_MEMORY_KB("PluginDocument.Memory", (total_bytes / 1024)); |
- UMA_HISTOGRAM_COUNTS("PluginDocument.NumChunks", data_.size()); |
+ UMA_HISTOGRAM_MEMORY_KB( |
+ "PluginDocument.Memory", |
+ (base::checked_numeric_cast<int, size_t>(total_bytes / 1024))); |
+ UMA_HISTOGRAM_COUNTS( |
+ "PluginDocument.NumChunks", |
+ (base::checked_numeric_cast<int, size_t>(data_.size()))); |
} |
if (finished_loading_) { |
plugin->didFinishLoading(); |
@@ -90,9 +92,7 @@ void WebViewPlugin::RestoreTitleText() { |
container_->element().setAttribute("title", old_title_); |
} |
-WebPluginContainer* WebViewPlugin::container() const { |
- return container_; |
-} |
+WebPluginContainer* WebViewPlugin::container() const { return container_; } |
bool WebViewPlugin::initialize(WebPluginContainer* container) { |
container_ = container; |
@@ -110,17 +110,11 @@ void WebViewPlugin::destroy() { |
base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
} |
-NPObject* WebViewPlugin::scriptableObject() { |
- return NULL; |
-} |
+NPObject* WebViewPlugin::scriptableObject() { return NULL; } |
-struct _NPP* WebViewPlugin::pluginNPP() { |
- return NULL; |
-} |
+struct _NPP* WebViewPlugin::pluginNPP() { return NULL; } |
-bool WebViewPlugin::getFormValue(WebString& value) { |
- return false; |
-} |
+bool WebViewPlugin::getFormValue(WebString& value) { return false; } |
void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { |
gfx::Rect paint_rect = gfx::IntersectRects(rect_, rect); |
@@ -139,18 +133,17 @@ void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { |
} |
// Coordinates are relative to the containing window. |
-void WebViewPlugin::updateGeometry( |
- const WebRect& frame_rect, const WebRect& clip_rect, |
- const WebVector<WebRect>& cut_out_rects, bool is_visible) { |
+void WebViewPlugin::updateGeometry(const WebRect& frame_rect, |
+ const WebRect& clip_rect, |
+ const WebVector<WebRect>& cut_out_rects, |
+ bool is_visible) { |
if (static_cast<gfx::Rect>(frame_rect) != rect_) { |
rect_ = frame_rect; |
web_view_->resize(WebSize(frame_rect.width, frame_rect.height)); |
} |
} |
-bool WebViewPlugin::acceptsInputEvents() { |
- return true; |
-} |
+bool WebViewPlugin::acceptsInputEvents() { return true; } |
bool WebViewPlugin::handleInputEvent(const WebInputEvent& event, |
WebCursorInfo& cursor) { |
@@ -193,9 +186,7 @@ void WebViewPlugin::didFailLoading(const WebURLError& error) { |
error_.reset(new WebURLError(error)); |
} |
-bool WebViewPlugin::acceptsLoadDrops() { |
- return false; |
-} |
+bool WebViewPlugin::acceptsLoadDrops() { return false; } |
void WebViewPlugin::setToolTipText(const WebString& text, |
WebKit::WebTextDirection hint) { |