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

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

Issue 8771055: Fix null pointer exception in WebViewColorOverlay. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/webview_color_overlay.h" 5 #include "chrome/renderer/webview_color_overlay.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/public/renderer/render_view.h" 8 #include "content/public/renderer/render_view.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkPaint.h" 10 #include "third_party/skia/include/core/SkPaint.h"
11 #include "third_party/skia/include/core/SkRect.h" 11 #include "third_party/skia/include/core/SkRect.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
13 #include "ui/gfx/size.h" 13 #include "ui/gfx/size.h"
14 #include "ui/gfx/skia_util.h" 14 #include "ui/gfx/skia_util.h"
15 15
16 #if WEBKIT_USING_CG 16 #if WEBKIT_USING_CG
17 #include "skia/ext/skia_utils_mac.h" 17 #include "skia/ext/skia_utils_mac.h"
18 #endif 18 #endif
19 19
20 WebViewColorOverlay::WebViewColorOverlay(content::RenderView* render_view, 20 WebViewColorOverlay::WebViewColorOverlay(content::RenderView* render_view,
21 SkColor color) 21 SkColor color)
22 : render_view_(render_view), 22 : render_view_(render_view),
23 color_(color) { 23 color_(color) {
24 render_view_->GetWebView()->addPageOverlay(this, 0); 24 render_view_->GetWebView()->addPageOverlay(this, 0);
25 } 25 }
26 26
27 WebViewColorOverlay::~WebViewColorOverlay() { 27 WebViewColorOverlay::~WebViewColorOverlay() {
28 render_view_->GetWebView()->removePageOverlay(this); 28 if (render_view_->GetWebView())
29 render_view_->GetWebView()->removePageOverlay(this);
29 } 30 }
30 31
31 void WebViewColorOverlay::paintPageOverlay(WebKit::WebCanvas* canvas) { 32 void WebViewColorOverlay::paintPageOverlay(WebKit::WebCanvas* canvas) {
32 SkRect rect = gfx::RectToSkRect(gfx::Rect(render_view_->GetSize())); 33 SkRect rect = gfx::RectToSkRect(gfx::Rect(render_view_->GetSize()));
33 34
34 #if WEBKIT_USING_SKIA 35 #if WEBKIT_USING_SKIA
35 SkPaint paint; 36 SkPaint paint;
36 paint.setColor(color_); 37 paint.setColor(color_);
37 paint.setStyle(SkPaint::kFill_Style); 38 paint.setStyle(SkPaint::kFill_Style);
38 canvas->drawRect(rect, paint); 39 canvas->drawRect(rect, paint);
39 #elif WEBKIT_USING_CG 40 #elif WEBKIT_USING_CG
40 CGContextSaveGState(canvas); 41 CGContextSaveGState(canvas);
41 CGColorRef color = gfx::SkColorToCGColorRef(color_); 42 CGColorRef color = gfx::SkColorToCGColorRef(color_);
42 CGContextSetFillColorWithColor(canvas, color); 43 CGContextSetFillColorWithColor(canvas, color);
43 CGColorRelease(color); 44 CGColorRelease(color);
44 CGContextFillRect(canvas, gfx::SkRectToCGRect(rect)); 45 CGContextFillRect(canvas, gfx::SkRectToCGRect(rect));
45 CGContextRestoreGState(canvas); 46 CGContextRestoreGState(canvas);
46 #else 47 #else
47 NOTIMPLEMENTED(); 48 NOTIMPLEMENTED();
48 #endif 49 #endif
49 } 50 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698