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