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

Side by Side Diff: athena/content/web_activity.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: Rebased, fixed resulting problems and addressed comments 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
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 #ifndef ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ 5 #ifndef ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_
6 #define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ 6 #define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "athena/activity/public/activity.h" 10 #include "athena/activity/public/activity.h"
11 #include "athena/activity/public/activity_view_model.h" 11 #include "athena/activity/public/activity_view_model.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
15 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
16 17
17 class SkBitmap; 18 class SkBitmap;
18 19
19 namespace content { 20 namespace content {
20 class BrowserContext; 21 class BrowserContext;
21 class WebContents; 22 class WebContents;
22 } 23 }
23 24
24 namespace gfx { 25 namespace gfx {
25 class Size; 26 class Size;
26 } 27 }
27 28
28 namespace views { 29 namespace views {
29 class WebView; 30 class WebView;
30 class WidgetDelegate; 31 class WidgetDelegate;
31 } 32 }
32 33
33 namespace athena { 34 namespace athena {
34 35
35 class AthenaWebView; 36 class AthenaWebView;
37 class ContentProxy;
36 38
37 class WebActivity : public Activity, 39 class WebActivity : public Activity,
38 public ActivityViewModel, 40 public ActivityViewModel,
39 public content::WebContentsObserver { 41 public content::WebContentsObserver {
40 public: 42 public:
41 WebActivity(content::BrowserContext* context, 43 WebActivity(content::BrowserContext* context,
42 const base::string16& title, 44 const base::string16& title,
43 const GURL& gurl); 45 const GURL& gurl);
44 WebActivity(AthenaWebView* web_view); 46 WebActivity(AthenaWebView* web_view);
45 47
46 protected: 48 protected:
47 virtual ~WebActivity(); 49 virtual ~WebActivity();
48 50
49 // Activity: 51 // Activity:
50 virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE; 52 virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE;
51 virtual void SetCurrentState(ActivityState state) OVERRIDE; 53 virtual void SetCurrentState(ActivityState state) OVERRIDE;
52 virtual ActivityState GetCurrentState() OVERRIDE; 54 virtual ActivityState GetCurrentState() OVERRIDE;
53 virtual bool IsVisible() OVERRIDE; 55 virtual bool IsVisible() OVERRIDE;
54 virtual ActivityMediaState GetMediaState() OVERRIDE; 56 virtual ActivityMediaState GetMediaState() OVERRIDE;
55 virtual aura::Window* GetWindow() OVERRIDE; 57 virtual aura::Window* GetWindow() OVERRIDE;
56 58
57 // ActivityViewModel: 59 // ActivityViewModel:
58 virtual void Init() OVERRIDE; 60 virtual void Init() OVERRIDE;
59 virtual SkColor GetRepresentativeColor() const OVERRIDE; 61 virtual SkColor GetRepresentativeColor() const OVERRIDE;
60 virtual base::string16 GetTitle() const OVERRIDE; 62 virtual base::string16 GetTitle() const OVERRIDE;
61 virtual gfx::ImageSkia GetIcon() const OVERRIDE; 63 virtual gfx::ImageSkia GetIcon() const OVERRIDE;
62 virtual bool UsesFrame() const OVERRIDE; 64 virtual bool UsesFrame() const OVERRIDE;
63 virtual views::View* GetContentsView() OVERRIDE; 65 virtual views::View* GetContentsView() OVERRIDE;
64 virtual views::Widget* CreateWidget() OVERRIDE; 66 virtual views::Widget* CreateWidget() OVERRIDE;
65 virtual void CreateOverviewModeImage() OVERRIDE;
66 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; 67 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE;
67 virtual void PrepareContentsForOverview() OVERRIDE; 68 virtual void PrepareContentsForOverview() OVERRIDE;
68 virtual void ResetContentsView() OVERRIDE; 69 virtual void ResetContentsView() OVERRIDE;
69 70
70 // content::WebContentsObserver: 71 // content::WebContentsObserver:
71 virtual void DidNavigateMainFrame( 72 virtual void DidNavigateMainFrame(
72 const content::LoadCommittedDetails& details, 73 const content::LoadCommittedDetails& details,
73 const content::FrameNavigateParams& params) OVERRIDE; 74 const content::FrameNavigateParams& params) OVERRIDE;
74 virtual void TitleWasSet(content::NavigationEntry* entry, 75 virtual void TitleWasSet(content::NavigationEntry* entry,
75 bool explicit_set) OVERRIDE; 76 bool explicit_set) OVERRIDE;
76 virtual void DidUpdateFaviconURL( 77 virtual void DidUpdateFaviconURL(
77 const std::vector<content::FaviconURL>& candidates) OVERRIDE; 78 const std::vector<content::FaviconURL>& candidates) OVERRIDE;
78 virtual void DidChangeThemeColor(SkColor theme_color) OVERRIDE; 79 virtual void DidChangeThemeColor(SkColor theme_color) OVERRIDE;
79 80
80 private: 81 private:
81 // Called when a favicon download initiated in DidUpdateFaviconURL() 82 // Called when a favicon download initiated in DidUpdateFaviconURL()
82 // has completed. 83 // has completed.
83 void OnDidDownloadFavicon( 84 void OnDidDownloadFavicon(
84 int id, 85 int id,
85 int http_status_code, 86 int http_status_code,
86 const GURL& url, 87 const GURL& url,
87 const std::vector<SkBitmap>& bitmaps, 88 const std::vector<SkBitmap>& bitmaps,
88 const std::vector<gfx::Size>& original_bitmap_sizes); 89 const std::vector<gfx::Size>& original_bitmap_sizes);
89 90
90 // Make the content visible. This call should only be paired with 91 // Hiding the contet proxy and showing the real content instead.
91 // MakeInvisible. Note: Upon object creation the content is visible. 92 void HideContentProxy();
92 void MakeVisible();
93 93
94 // Make the content invisible. This call should only be paired with 94 // Showing a content proxy instead of the real content to save resoruces.
95 // MakeVisible. 95 void ShowContentProxy();
96 void MakeInvisible();
97 96
98 // Reload the content if required, and start observing it. 97 // Reload the content if required, and start observing it.
99 void ReloadAndObserve(); 98 void ReloadAndObserve();
100 99
101 content::BrowserContext* browser_context_; 100 content::BrowserContext* browser_context_;
102 const base::string16 title_; 101 const base::string16 title_;
103 gfx::ImageSkia icon_; 102 gfx::ImageSkia icon_;
104 const GURL url_; 103 const GURL url_;
105 AthenaWebView* web_view_; 104 AthenaWebView* web_view_;
106 SkColor title_color_; 105 SkColor title_color_;
107 106
108 // The current state for this activity. 107 // The current state for this activity.
109 ActivityState current_state_; 108 ActivityState current_state_;
110 109
111 // The image which will be used in overview mode. 110 // The content proxy.
112 gfx::ImageSkia overview_mode_image_; 111 scoped_ptr<ContentProxy> content_proxy_;
113 112
114 base::WeakPtrFactory<WebActivity> weak_ptr_factory_; 113 base::WeakPtrFactory<WebActivity> weak_ptr_factory_;
115 114
116 DISALLOW_COPY_AND_ASSIGN(WebActivity); 115 DISALLOW_COPY_AND_ASSIGN(WebActivity);
117 }; 116 };
118 117
119 } // namespace athena 118 } // namespace athena
120 119
121 #endif // ATHENA_CONTENT_WEB_ACTIVITY_H_ 120 #endif // ATHENA_CONTENT_WEB_ACTIVITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698