| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef ATHENA_CONTENT_APP_ACTIVITY_H_ | |
| 6 #define ATHENA_CONTENT_APP_ACTIVITY_H_ | |
| 7 | |
| 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" | |
| 13 | |
| 14 namespace views { | |
| 15 class WebView; | |
| 16 } | |
| 17 | |
| 18 namespace athena { | |
| 19 | |
| 20 class AppActivityRegistry; | |
| 21 class ContentProxy; | |
| 22 | |
| 23 // The activity object for a hosted V2 application. | |
| 24 class AppActivity : public Activity, | |
| 25 public ActivityViewModel, | |
| 26 public content::WebContentsObserver { | |
| 27 public: | |
| 28 AppActivity(const std::string& app_id, views::WebView* web_view); | |
| 29 | |
| 30 // Gets the content proxy so that the AppActivityProxy can take it over. | |
| 31 scoped_ptr<ContentProxy> GetContentProxy(); | |
| 32 | |
| 33 // Activity: | |
| 34 athena::ActivityViewModel* GetActivityViewModel() override; | |
| 35 void SetCurrentState(Activity::ActivityState state) override; | |
| 36 ActivityState GetCurrentState() override; | |
| 37 bool IsVisible() override; | |
| 38 ActivityMediaState GetMediaState() override; | |
| 39 aura::Window* GetWindow() override; | |
| 40 content::WebContents* GetWebContents() override; | |
| 41 | |
| 42 // ActivityViewModel: | |
| 43 void Init() override; | |
| 44 SkColor GetRepresentativeColor() const override; | |
| 45 base::string16 GetTitle() const override; | |
| 46 gfx::ImageSkia GetIcon() const override; | |
| 47 void SetActivityView(ActivityView* activity_view) override; | |
| 48 bool UsesFrame() const override; | |
| 49 views::View* GetContentsView() override; | |
| 50 gfx::ImageSkia GetOverviewModeImage() override; | |
| 51 void PrepareContentsForOverview() override; | |
| 52 void ResetContentsView() override; | |
| 53 | |
| 54 protected: | |
| 55 // Constructor for test. | |
| 56 explicit AppActivity(const std::string& app_id); | |
| 57 | |
| 58 ~AppActivity() override; | |
| 59 | |
| 60 private: | |
| 61 // content::WebContentsObserver: | |
| 62 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; | |
| 63 void DidUpdateFaviconURL( | |
| 64 const std::vector<content::FaviconURL>& candidates) override; | |
| 65 | |
| 66 // Register this activity with its application. | |
| 67 void RegisterActivity(); | |
| 68 | |
| 69 // Hiding the contet proxy and showing the real content instead. | |
| 70 void HideContentProxy(); | |
| 71 | |
| 72 // Showing a content proxy instead of the real content to save resources. | |
| 73 void ShowContentProxy(); | |
| 74 | |
| 75 const std::string app_id_; | |
| 76 | |
| 77 views::WebView* web_view_; | |
| 78 | |
| 79 // The current state for this activity. | |
| 80 ActivityState current_state_; | |
| 81 | |
| 82 // If known the registry which holds all activities for the associated app. | |
| 83 // This object is owned by |AppRegistry| and will be a valid pointer as long | |
| 84 // as this object lives. | |
| 85 AppActivityRegistry* app_activity_registry_; | |
| 86 | |
| 87 // The content proxy. | |
| 88 scoped_ptr<ContentProxy> content_proxy_; | |
| 89 | |
| 90 // WebActivity does not take ownership of |activity_view_|. If the view is | |
| 91 // destroyed before the activity, then it must be reset using | |
| 92 // SetActivityView(nullptr). | |
| 93 ActivityView* activity_view_; | |
| 94 | |
| 95 DISALLOW_COPY_AND_ASSIGN(AppActivity); | |
| 96 }; | |
| 97 | |
| 98 } // namespace athena | |
| 99 | |
| 100 #endif // ATHENA_CONTENT_APP_ACTIVITY_H_ | |
| OLD | NEW |