| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef ATHENA_CONTENT_APP_ACTIVITY_H_ |
| #define ATHENA_CONTENT_APP_ACTIVITY_H_ |
| |
| #include "athena/activity/public/activity.h" |
| #include "athena/activity/public/activity_view_model.h" |
| #include "athena/content/app_activity_proxy.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "content/public/browser/web_contents_observer.h" |
| |
| namespace extensions { |
| class AppWindow; |
| } |
| |
| namespace views { |
| class WebView; |
| } |
| |
| namespace athena { |
| |
| class AppActivityRegistry; |
| class ContentProxy; |
| |
| // The activity object for a hosted V2 application. |
| // TODO(oshima): Move this to athena/extensions |
| class AppActivity : public Activity, |
| public ActivityViewModel, |
| public content::WebContentsObserver { |
| public: |
| AppActivity(extensions::AppWindow* app_window, views::WebView* web_view); |
| |
| // Gets the content proxy so that the AppActivityProxy can take it over. |
| scoped_ptr<ContentProxy> GetContentProxy(); |
| |
| // Activity: |
| virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE; |
| virtual void SetCurrentState(Activity::ActivityState state) OVERRIDE; |
| virtual ActivityState GetCurrentState() OVERRIDE; |
| virtual bool IsVisible() OVERRIDE; |
| virtual ActivityMediaState GetMediaState() OVERRIDE; |
| virtual aura::Window* GetWindow() OVERRIDE; |
| virtual content::WebContents* GetWebContents() OVERRIDE; |
| |
| // ActivityViewModel: |
| virtual void Init() OVERRIDE; |
| virtual SkColor GetRepresentativeColor() const OVERRIDE; |
| virtual base::string16 GetTitle() const OVERRIDE; |
| virtual gfx::ImageSkia GetIcon() const OVERRIDE; |
| virtual bool UsesFrame() const OVERRIDE; |
| virtual views::Widget* CreateWidget() OVERRIDE; |
| virtual views::View* GetContentsView() OVERRIDE; |
| virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; |
| virtual void PrepareContentsForOverview() OVERRIDE; |
| virtual void ResetContentsView() OVERRIDE; |
| |
| protected: |
| // Constructor for test. |
| explicit AppActivity(const std::string& app_id); |
| |
| virtual ~AppActivity(); |
| |
| private: |
| // content::WebContentsObserver: |
| virtual void TitleWasSet(content::NavigationEntry* entry, |
| bool explicit_set) OVERRIDE; |
| virtual void DidUpdateFaviconURL( |
| const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
| |
| // Register this activity with its application. |
| void RegisterActivity(); |
| |
| // Hiding the contet proxy and showing the real content instead. |
| void HideContentProxy(); |
| |
| // Showing a content proxy instead of the real content to save resources. |
| void ShowContentProxy(); |
| |
| const std::string app_id_; |
| |
| views::WebView* web_view_; |
| |
| // The current state for this activity. |
| ActivityState current_state_; |
| |
| // If known the registry which holds all activities for the associated app. |
| // This object is owned by |AppRegistry| and will be a valid pointer as long |
| // as this object lives. |
| AppActivityRegistry* app_activity_registry_; |
| |
| // The content proxy. |
| scoped_ptr<ContentProxy> content_proxy_; |
| |
| DISALLOW_COPY_AND_ASSIGN(AppActivity); |
| }; |
| |
| } // namespace athena |
| |
| #endif // ATHENA_CONTENT_APP_ACTIVITY_H_ |