OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/content/content_proxy.h" | 5 #include "athena/content/content_proxy.h" |
6 | 6 |
7 #include "athena/activity/public/activity.h" | |
8 #include "athena/activity/public/activity_view_model.h" | |
9 #include "base/bind.h" | 7 #include "base/bind.h" |
10 #include "base/threading/worker_pool.h" | 8 #include "base/threading/worker_pool.h" |
11 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
13 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
14 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
15 #include "ui/gfx/codec/png_codec.h" | 13 #include "ui/gfx/codec/png_codec.h" |
16 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
18 #include "ui/gfx/image/image_png_rep.h" | 16 #include "ui/gfx/image/image_png_rep.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 std::vector<unsigned char> data; | 51 std::vector<unsigned char> data; |
54 if (gfx::PNGCodec::EncodeA8SkBitmap(bitmap, &data)) | 52 if (gfx::PNGCodec::EncodeA8SkBitmap(bitmap, &data)) |
55 data_ = new base::RefCountedBytes(data); | 53 data_ = new base::RefCountedBytes(data); |
56 } | 54 } |
57 | 55 |
58 scoped_refptr<base::RefCountedBytes> data_; | 56 scoped_refptr<base::RefCountedBytes> data_; |
59 | 57 |
60 DISALLOW_COPY_AND_ASSIGN(ProxyImageData); | 58 DISALLOW_COPY_AND_ASSIGN(ProxyImageData); |
61 }; | 59 }; |
62 | 60 |
63 ContentProxy::ContentProxy(views::WebView* web_view, Activity* activity) | 61 ContentProxy::ContentProxy(views::WebView* web_view) |
64 : web_view_(web_view), | 62 : web_view_(web_view), |
65 content_visible_(true), | 63 content_visible_(true), |
66 content_loaded_(true), | 64 content_loaded_(true), |
67 content_creation_called_(false), | 65 content_creation_called_(false), |
68 proxy_content_to_image_factory_(this) { | 66 proxy_content_to_image_factory_(this) { |
69 // Note: The content will be hidden once the image got created. | 67 // Note: The content will be hidden once the image got created. |
70 CreateProxyContent(); | 68 CreateProxyContent(); |
71 } | 69 } |
72 | 70 |
73 ContentProxy::~ContentProxy() { | 71 ContentProxy::~ContentProxy() { |
74 // If we still have a connection to the original Activity, we make it visible | 72 // If we still have a connection to the original web contents, we make it |
75 // again. | 73 // visible again. |
76 ShowOriginalContent(); | 74 ShowOriginalContent(); |
77 } | 75 } |
78 | 76 |
79 void ContentProxy::ContentWillUnload() { | 77 void ContentProxy::ContentWillUnload() { |
80 content_loaded_ = false; | 78 content_loaded_ = false; |
81 } | 79 } |
82 | 80 |
83 gfx::ImageSkia ContentProxy::GetContentImage() { | 81 gfx::ImageSkia ContentProxy::GetContentImage() { |
84 // While we compress to PNG, we use the original read back. | 82 // While we compress to PNG, we use the original read back. |
85 if (!png_data_.get()) | 83 if (!png_data_.get()) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 178 |
181 void ContentProxy::OnContentImageEncodeComplete( | 179 void ContentProxy::OnContentImageEncodeComplete( |
182 scoped_refptr<ProxyImageData> image) { | 180 scoped_refptr<ProxyImageData> image) { |
183 png_data_ = image->data(); | 181 png_data_ = image->data(); |
184 | 182 |
185 // From now on we decode the image as needed to save memory. | 183 // From now on we decode the image as needed to save memory. |
186 raw_image_ = gfx::ImageSkia(); | 184 raw_image_ = gfx::ImageSkia(); |
187 } | 185 } |
188 | 186 |
189 } // namespace athena | 187 } // namespace athena |
OLD | NEW |