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.
5 #ifndef ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_
6 #define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_
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"
39 class WebActivity
: public Activity
,
40 public ActivityViewModel
,
41 public content::WebContentsObserver
{
43 WebActivity(content::BrowserContext
* context
,
44 const base::string16
& title
,
46 explicit WebActivity(content::WebContents
* contents
);
49 ~WebActivity() override
;
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
;
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
;
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
;
82 // Called when a favicon download initiated in DidUpdateFaviconURL()
84 void OnDidDownloadFavicon(
88 const std::vector
<SkBitmap
>& bitmaps
,
89 const std::vector
<gfx::Size
>& original_bitmap_sizes
);
91 // Hiding the contet proxy and showing the real content instead.
92 void HideContentProxy();
94 // Showing a content proxy instead of the real content to save resoruces.
95 void ShowContentProxy();
97 content::BrowserContext
* browser_context_
;
98 AthenaWebView
* web_view_
;
99 const base::string16 title_
;
100 SkColor title_color_
;
101 gfx::ImageSkia icon_
;
103 // The current state for this activity.
104 ActivityState current_state_
;
106 // The content proxy.
107 scoped_ptr
<ContentProxy
> content_proxy_
;
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_
;
114 base::WeakPtrFactory
<WebActivity
> weak_ptr_factory_
;
116 DISALLOW_COPY_AND_ASSIGN(WebActivity
);
119 } // namespace athena
121 #endif // ATHENA_CONTENT_WEB_ACTIVITY_H_