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_APP_ACTIVITY_H_
6 #define ATHENA_CONTENT_APP_ACTIVITY_H_
8 #include "athena/activity/public/activity.h"
9 #include "athena/activity/public/activity_view_model.h"
10 #include "athena/content/app_activity_proxy.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_contents_observer.h"
20 class AppActivityRegistry
;
23 // The activity object for a hosted V2 application.
24 class AppActivity
: public Activity
,
25 public ActivityViewModel
,
26 public content::WebContentsObserver
{
28 AppActivity(const std::string
& app_id
, views::WebView
* web_view
);
30 // Gets the content proxy so that the AppActivityProxy can take it over.
31 scoped_ptr
<ContentProxy
> GetContentProxy();
34 virtual athena::ActivityViewModel
* GetActivityViewModel() override
;
35 virtual void SetCurrentState(Activity::ActivityState state
) override
;
36 virtual ActivityState
GetCurrentState() override
;
37 virtual bool IsVisible() override
;
38 virtual ActivityMediaState
GetMediaState() override
;
39 virtual aura::Window
* GetWindow() override
;
40 virtual content::WebContents
* GetWebContents() override
;
43 virtual void Init() override
;
44 virtual SkColor
GetRepresentativeColor() const override
;
45 virtual base::string16
GetTitle() const override
;
46 virtual gfx::ImageSkia
GetIcon() const override
;
47 virtual bool UsesFrame() const override
;
48 virtual views::Widget
* CreateWidget() override
;
49 virtual views::View
* GetContentsView() override
;
50 virtual gfx::ImageSkia
GetOverviewModeImage() override
;
51 virtual void PrepareContentsForOverview() override
;
52 virtual void ResetContentsView() override
;
55 // Constructor for test.
56 explicit AppActivity(const std::string
& app_id
);
58 virtual ~AppActivity();
61 // content::WebContentsObserver:
62 virtual void TitleWasSet(content::NavigationEntry
* entry
,
63 bool explicit_set
) override
;
64 virtual void DidUpdateFaviconURL(
65 const std::vector
<content::FaviconURL
>& candidates
) override
;
67 // Register this activity with its application.
68 void RegisterActivity();
70 // Hiding the contet proxy and showing the real content instead.
71 void HideContentProxy();
73 // Showing a content proxy instead of the real content to save resources.
74 void ShowContentProxy();
76 const std::string app_id_
;
78 views::WebView
* web_view_
;
80 // The current state for this activity.
81 ActivityState current_state_
;
83 // If known the registry which holds all activities for the associated app.
84 // This object is owned by |AppRegistry| and will be a valid pointer as long
85 // as this object lives.
86 AppActivityRegistry
* app_activity_registry_
;
89 scoped_ptr
<ContentProxy
> content_proxy_
;
91 DISALLOW_COPY_AND_ASSIGN(AppActivity
);
96 #endif // ATHENA_CONTENT_APP_ACTIVITY_H_