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

Side by Side Diff: athena/content/content_proxy.h

Issue 548633005: Adding overview / layer framework to Activities so that unloaded / sleeping activities can be shown… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ATHENA_CONTENT_CONTENT_PROXY_H_
6 #define ATHENA_CONTENT_CONTENT_PROXY_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/gfx/image/image_skia.h"
11
12 namespace aura {
13 class Window;
14 }
15
16 namespace views {
17 class View;
18 class WebView;
19 }
20
21 typedef unsigned int SkColor;
22
23 namespace athena {
24
25 class Activity;
26 class AppActivity;
27 class AppActivityProxy;
28 class WebActivity;
29
30 // This object creates and holds proxy content which gets shown instead of the
31 // actual web content, generated from the passed |web_view|.
32 // The created |proxy_content_| will be destroyed with the destruction of this
33 // object.
34 // Calling EvictContent() will release the rendered content and replaces it with
35 // a solid color to save memory.
36 // Calling Reparent() will transfer the |proxy_content_| to an ActivityProxy,
37 // allowing the destruction of the original activity / content.
38 class ContentProxy {
pkotwicz 2014/09/10 01:43:12 I wonder whether ContentProxy can inherit from vie
pkotwicz 2014/09/10 14:30:21 Clarification: Ideally, WebActivity::GetContentsVi
Mr4D (OOO till 08-26) 2014/09/10 15:55:45 I see what you mean - and yes, I experimented with
39 public:
40 // Creates the object by creating a sized down |web_view| layer and making it
41 // visible inside |activity|'s window.
42 ContentProxy(views::WebView* web_view, Activity* activity);
43 // TODO(skuhne): Add a function to create this object from a passed PNG, so
44 // that we can create it from a session restore.
45
46 // With the destruction of the object, the layer should get destroyed and the
47 // content should become visible again.
48 virtual ~ContentProxy();
49
50 // Called when the content will get unloaded.
51 void ContentWillUnload();
52
53 // Can be called to save resources by creating a layer with a solid color
54 // instead of creating a content image layer.
55 // Note: Currently the GPU does create a full size texture and fills it with
56 // the given color - so there isn't really memory savings yet.
57 void EvictContent();
58
59 // Get the image of the content. If there is no image known, an empty image
60 // will be returned.
61 gfx::ImageSkia GetContentImage();
62
63 protected:
Jun Mukai 2014/09/10 00:38:53 This protected section does not make sense to me.
Mr4D (OOO till 08-26) 2014/09/10 15:55:46 Removed. The reason being that these functions sho
64 friend AppActivity;
65 friend WebActivity;
66
67 // Transfer the owned |proxy_content_| to the |new_parent_window|.
68 // Once called, the |web_view_| will be made visible again and the connection
69 // to it will be removed since the old activity might go away.
70 void Reparent(aura::Window* new_parent_window);
71
72 private:
73 // Make the original (web)content visible. This call should only be paired
74 // with HideOriginalContent.
75 void ShowOriginalContent();
76
77 // Make the content invisible. This call should only be paired with
78 // MakeVisible.
79 void HideOriginalContent();
80
81 // Creates proxy content from |web_view_|. If there is no |web_view_|,
82 // a solid |proxy_content_| with |background_color_| will be created.
83 void CreateProxyContent();
84
85 // Creates a solid |proxy_content_| with |background_color_|.
86 void CreateSolidProxyContent();
87
88 // Show the |proxy_content_| in the current |window_|.
89 void ShowProxyContent();
90
91 // Removes the |proxy_content_| from the window again.
92 void HideProxyContent();
93
94 // The web view which is associated with this object. It will be NULL after
95 // the object got called with Reparent(), since the Activity which owns it
96 // will be destroyed shortly after.
97 views::WebView* web_view_;
98
99 // The window which shows our |proxy_content_|,
100 aura::Window* window_;
101
102 // The background color to use when evicted.
103 SkColor background_color_;
104
105 // If we have an image (e.g. from session restore) it is stored here.
106 gfx::ImageSkia image_;
107
108 // True if the content is loaded.
109 bool content_loaded_;
110
111 // The content representation which which will be presented to the user. It
112 // will either contain a shrunken down image of the |web_view| content or a
113 // solid |background_color_|.
114 scoped_ptr<views::View> proxy_content_;
115
116 DISALLOW_COPY_AND_ASSIGN(ContentProxy);
117 };
118
119 } // namespace athena
120
121 #endif // ATHENA_CONTENT_CONTENT_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698