| OLD | NEW |
| 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_APP_ACTIVITY_H_ | 5 #ifndef ATHENA_CONTENT_APP_ACTIVITY_H_ |
| 6 #define ATHENA_CONTENT_APP_ACTIVITY_H_ | 6 #define ATHENA_CONTENT_APP_ACTIVITY_H_ |
| 7 | 7 |
| 8 #include "athena/activity/public/activity.h" | 8 #include "athena/activity/public/activity.h" |
| 9 #include "athena/activity/public/activity_view_model.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" |
| 10 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
| 12 | 14 |
| 13 namespace views { | 15 namespace views { |
| 14 class WebView; | 16 class WebView; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace athena { | 19 namespace athena { |
| 18 | 20 |
| 19 class AppActivityRegistry; | 21 class AppActivityRegistry; |
| 22 class ContentProxy; |
| 20 | 23 |
| 21 // The activity object for a hosted V2 application. | 24 // The activity object for a hosted V2 application. |
| 22 class AppActivity : public Activity, | 25 class AppActivity : public Activity, |
| 23 public ActivityViewModel, | 26 public ActivityViewModel, |
| 24 public content::WebContentsObserver { | 27 public content::WebContentsObserver { |
| 25 public: | 28 public: |
| 26 explicit AppActivity(const std::string& app_id); | 29 explicit AppActivity(const std::string& app_id); |
| 27 | 30 |
| 31 // Gets the content proxy so that the AppProxy can take it over. |
| 32 scoped_ptr<ContentProxy> GetContentProxy(aura::Window* window); |
| 33 |
| 28 // Activity: | 34 // Activity: |
| 29 virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE; | 35 virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE; |
| 30 virtual void SetCurrentState(Activity::ActivityState state) OVERRIDE; | 36 virtual void SetCurrentState(Activity::ActivityState state) OVERRIDE; |
| 31 virtual ActivityState GetCurrentState() OVERRIDE; | 37 virtual ActivityState GetCurrentState() OVERRIDE; |
| 32 virtual bool IsVisible() OVERRIDE; | 38 virtual bool IsVisible() OVERRIDE; |
| 33 virtual ActivityMediaState GetMediaState() OVERRIDE; | 39 virtual ActivityMediaState GetMediaState() OVERRIDE; |
| 34 virtual aura::Window* GetWindow() OVERRIDE; | 40 virtual aura::Window* GetWindow() OVERRIDE; |
| 35 | 41 |
| 36 // ActivityViewModel: | 42 // ActivityViewModel: |
| 37 virtual void Init() OVERRIDE; | 43 virtual void Init() OVERRIDE; |
| 38 virtual SkColor GetRepresentativeColor() const OVERRIDE; | 44 virtual SkColor GetRepresentativeColor() const OVERRIDE; |
| 39 virtual base::string16 GetTitle() const OVERRIDE; | 45 virtual base::string16 GetTitle() const OVERRIDE; |
| 40 virtual gfx::ImageSkia GetIcon() const OVERRIDE; | 46 virtual gfx::ImageSkia GetIcon() const OVERRIDE; |
| 41 virtual bool UsesFrame() const OVERRIDE; | 47 virtual bool UsesFrame() const OVERRIDE; |
| 42 virtual views::View* GetContentsView() OVERRIDE; | 48 virtual views::View* GetContentsView() OVERRIDE; |
| 43 virtual void CreateOverviewModeImage() OVERRIDE; | |
| 44 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; | 49 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; |
| 45 virtual void PrepareContentsForOverview() OVERRIDE; | 50 virtual void PrepareContentsForOverview() OVERRIDE; |
| 46 virtual void ResetContentsView() OVERRIDE; | 51 virtual void ResetContentsView() OVERRIDE; |
| 47 | 52 |
| 48 protected: | 53 protected: |
| 49 virtual ~AppActivity(); | 54 virtual ~AppActivity(); |
| 50 | 55 |
| 51 // content::WebContentsObserver: | 56 // content::WebContentsObserver: |
| 52 virtual void TitleWasSet(content::NavigationEntry* entry, | 57 virtual void TitleWasSet(content::NavigationEntry* entry, |
| 53 bool explicit_set) OVERRIDE; | 58 bool explicit_set) OVERRIDE; |
| 54 virtual void DidUpdateFaviconURL( | 59 virtual void DidUpdateFaviconURL( |
| 55 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | 60 const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
| 56 | 61 |
| 57 virtual views::WebView* GetWebView() = 0; | 62 virtual views::WebView* GetWebView() = 0; |
| 58 | 63 |
| 59 private: | 64 private: |
| 60 // Register this activity with its application. | 65 // Register this activity with its application. |
| 61 void RegisterActivity(); | 66 void RegisterActivity(); |
| 62 | 67 |
| 63 // Make the content visible. This call should only be paired with | 68 // Hiding the contet proxy and showing the real content instead. |
| 64 // MakeInvisible. Note: Upon start the content is visible. | 69 void HideContentProxy(); |
| 65 // TODO(skuhne): If this can be combined with web_activity, move this into a | |
| 66 // separate class. | |
| 67 void MakeVisible(); | |
| 68 | 70 |
| 69 // Make the content invisible. This call should only be paired with | 71 // Showing a content proxy instead of the real content to save resources. |
| 70 // MakeVisible. | 72 void ShowContentProxy(); |
| 71 // TODO(skuhne): If this can be combined with web_activity, move this into a | |
| 72 // separate class. | |
| 73 void MakeInvisible(); | |
| 74 | 73 |
| 75 const std::string app_id_; | 74 const std::string app_id_; |
| 76 | 75 |
| 77 views::WebView* web_view_; | 76 views::WebView* web_view_; |
| 78 | 77 |
| 79 // The current state for this activity. | 78 // The current state for this activity. |
| 80 ActivityState current_state_; | 79 ActivityState current_state_; |
| 81 | 80 |
| 82 // The image which will be used in overview mode. | |
| 83 gfx::ImageSkia overview_mode_image_; | |
| 84 | |
| 85 // If known the registry which holds all activities for the associated app. | 81 // If known the registry which holds all activities for the associated app. |
| 86 // This object is owned by |AppRegistry| and will be a valid pointer as long | 82 // This object is owned by |AppRegistry| and will be a valid pointer as long |
| 87 // as this object lives. | 83 // as this object lives. |
| 88 AppActivityRegistry* app_activity_registry_; | 84 AppActivityRegistry* app_activity_registry_; |
| 89 | 85 |
| 86 // The content proxy. |
| 87 scoped_ptr<ContentProxy> content_proxy_; |
| 88 |
| 90 DISALLOW_COPY_AND_ASSIGN(AppActivity); | 89 DISALLOW_COPY_AND_ASSIGN(AppActivity); |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 } // namespace athena | 92 } // namespace athena |
| 94 | 93 |
| 95 #endif // ATHENA_CONTENT_APP_ACTIVITY_H_ | 94 #endif // ATHENA_CONTENT_APP_ACTIVITY_H_ |
| OLD | NEW |