OLD | NEW |
| (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_PUBLIC_WEB_ACTIVITY_H_ | |
6 #define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "athena/activity/public/activity.h" | |
11 #include "athena/activity/public/activity_view_model.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "base/strings/string16.h" | |
15 #include "content/public/browser/web_contents_observer.h" | |
16 #include "ui/gfx/image/image_skia.h" | |
17 | |
18 class SkBitmap; | |
19 | |
20 namespace content { | |
21 class BrowserContext; | |
22 class WebContents; | |
23 } | |
24 | |
25 namespace gfx { | |
26 class Size; | |
27 } | |
28 | |
29 namespace views { | |
30 class WebView; | |
31 class WidgetDelegate; | |
32 } | |
33 | |
34 namespace athena { | |
35 | |
36 class AthenaWebView; | |
37 class ContentProxy; | |
38 | |
39 class WebActivity : public Activity, | |
40 public ActivityViewModel, | |
41 public content::WebContentsObserver { | |
42 public: | |
43 WebActivity(content::BrowserContext* context, | |
44 const base::string16& title, | |
45 const GURL& gurl); | |
46 explicit WebActivity(content::WebContents* contents); | |
47 | |
48 protected: | |
49 ~WebActivity() override; | |
50 | |
51 // Activity: | |
52 athena::ActivityViewModel* GetActivityViewModel() override; | |
53 void SetCurrentState(ActivityState state) override; | |
54 ActivityState GetCurrentState() override; | |
55 bool IsVisible() override; | |
56 ActivityMediaState GetMediaState() override; | |
57 aura::Window* GetWindow() override; | |
58 content::WebContents* GetWebContents() override; | |
59 | |
60 // ActivityViewModel: | |
61 void Init() override; | |
62 SkColor GetRepresentativeColor() const override; | |
63 base::string16 GetTitle() const override; | |
64 gfx::ImageSkia GetIcon() const override; | |
65 void SetActivityView(ActivityView* activity_view) override; | |
66 bool UsesFrame() const override; | |
67 views::View* GetContentsView() override; | |
68 gfx::ImageSkia GetOverviewModeImage() override; | |
69 void PrepareContentsForOverview() override; | |
70 void ResetContentsView() override; | |
71 | |
72 // content::WebContentsObserver: | |
73 void DidNavigateMainFrame( | |
74 const content::LoadCommittedDetails& details, | |
75 const content::FrameNavigateParams& params) override; | |
76 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; | |
77 void DidUpdateFaviconURL( | |
78 const std::vector<content::FaviconURL>& candidates) override; | |
79 void DidChangeThemeColor(SkColor theme_color) override; | |
80 | |
81 private: | |
82 // Called when a favicon download initiated in DidUpdateFaviconURL() | |
83 // has completed. | |
84 void OnDidDownloadFavicon( | |
85 int id, | |
86 int http_status_code, | |
87 const GURL& url, | |
88 const std::vector<SkBitmap>& bitmaps, | |
89 const std::vector<gfx::Size>& original_bitmap_sizes); | |
90 | |
91 // Hiding the contet proxy and showing the real content instead. | |
92 void HideContentProxy(); | |
93 | |
94 // Showing a content proxy instead of the real content to save resoruces. | |
95 void ShowContentProxy(); | |
96 | |
97 content::BrowserContext* browser_context_; | |
98 AthenaWebView* web_view_; | |
99 const base::string16 title_; | |
100 SkColor title_color_; | |
101 gfx::ImageSkia icon_; | |
102 | |
103 // The current state for this activity. | |
104 ActivityState current_state_; | |
105 | |
106 // The content proxy. | |
107 scoped_ptr<ContentProxy> content_proxy_; | |
108 | |
109 // WebActivity does not take ownership of |activity_view_|. If the view is | |
110 // destroyed before the activity, then it must be reset using | |
111 // SetActivityView(nullptr). | |
112 ActivityView* activity_view_; | |
113 | |
114 base::WeakPtrFactory<WebActivity> weak_ptr_factory_; | |
115 | |
116 DISALLOW_COPY_AND_ASSIGN(WebActivity); | |
117 }; | |
118 | |
119 } // namespace athena | |
120 | |
121 #endif // ATHENA_CONTENT_WEB_ACTIVITY_H_ | |
OLD | NEW |