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" | 10 #include "athena/content/app_activity_proxy.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
13 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
14 | 14 |
| 15 namespace extensions { |
| 16 class AppWindow; |
| 17 } |
| 18 |
15 namespace views { | 19 namespace views { |
16 class WebView; | 20 class WebView; |
17 } | 21 } |
18 | 22 |
19 namespace athena { | 23 namespace athena { |
20 | 24 |
21 class AppActivityRegistry; | 25 class AppActivityRegistry; |
22 class ContentProxy; | 26 class ContentProxy; |
23 | 27 |
24 // The activity object for a hosted V2 application. | 28 // The activity object for a hosted V2 application. |
| 29 // TODO(oshima): Move this to athena/extensions |
25 class AppActivity : public Activity, | 30 class AppActivity : public Activity, |
26 public ActivityViewModel, | 31 public ActivityViewModel, |
27 public content::WebContentsObserver { | 32 public content::WebContentsObserver { |
28 public: | 33 public: |
29 explicit AppActivity(const std::string& app_id); | 34 AppActivity(extensions::AppWindow* app_window, views::WebView* web_view); |
30 | 35 |
31 // Gets the content proxy so that the AppProxy can take it over. | 36 // Gets the content proxy so that the AppProxy can take it over. |
32 scoped_ptr<ContentProxy> GetContentProxy(aura::Window* window); | 37 scoped_ptr<ContentProxy> GetContentProxy(aura::Window* window); |
33 | 38 |
34 // Activity: | 39 // Activity: |
35 virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE; | 40 virtual athena::ActivityViewModel* GetActivityViewModel() OVERRIDE; |
36 virtual void SetCurrentState(Activity::ActivityState state) OVERRIDE; | 41 virtual void SetCurrentState(Activity::ActivityState state) OVERRIDE; |
37 virtual ActivityState GetCurrentState() OVERRIDE; | 42 virtual ActivityState GetCurrentState() OVERRIDE; |
38 virtual bool IsVisible() OVERRIDE; | 43 virtual bool IsVisible() OVERRIDE; |
39 virtual ActivityMediaState GetMediaState() OVERRIDE; | 44 virtual ActivityMediaState GetMediaState() OVERRIDE; |
40 virtual aura::Window* GetWindow() OVERRIDE; | 45 virtual aura::Window* GetWindow() OVERRIDE; |
41 | 46 |
42 // ActivityViewModel: | 47 // ActivityViewModel: |
43 virtual void Init() OVERRIDE; | 48 virtual void Init() OVERRIDE; |
44 virtual SkColor GetRepresentativeColor() const OVERRIDE; | 49 virtual SkColor GetRepresentativeColor() const OVERRIDE; |
45 virtual base::string16 GetTitle() const OVERRIDE; | 50 virtual base::string16 GetTitle() const OVERRIDE; |
46 virtual gfx::ImageSkia GetIcon() const OVERRIDE; | 51 virtual gfx::ImageSkia GetIcon() const OVERRIDE; |
47 virtual bool UsesFrame() const OVERRIDE; | 52 virtual bool UsesFrame() const OVERRIDE; |
| 53 virtual views::Widget* CreateWidget() OVERRIDE; |
48 virtual views::View* GetContentsView() OVERRIDE; | 54 virtual views::View* GetContentsView() OVERRIDE; |
49 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; | 55 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; |
50 virtual void PrepareContentsForOverview() OVERRIDE; | 56 virtual void PrepareContentsForOverview() OVERRIDE; |
51 virtual void ResetContentsView() OVERRIDE; | 57 virtual void ResetContentsView() OVERRIDE; |
52 | 58 |
53 protected: | 59 protected: |
| 60 // Constructor for test. |
| 61 explicit AppActivity(const std::string& app_id); |
| 62 |
54 virtual ~AppActivity(); | 63 virtual ~AppActivity(); |
55 | 64 |
| 65 private: |
56 // content::WebContentsObserver: | 66 // content::WebContentsObserver: |
57 virtual void TitleWasSet(content::NavigationEntry* entry, | 67 virtual void TitleWasSet(content::NavigationEntry* entry, |
58 bool explicit_set) OVERRIDE; | 68 bool explicit_set) OVERRIDE; |
59 virtual void DidUpdateFaviconURL( | 69 virtual void DidUpdateFaviconURL( |
60 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | 70 const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
61 | 71 |
62 virtual views::WebView* GetWebView() = 0; | |
63 | |
64 private: | |
65 // Register this activity with its application. | 72 // Register this activity with its application. |
66 void RegisterActivity(); | 73 void RegisterActivity(); |
67 | 74 |
68 // Hiding the contet proxy and showing the real content instead. | 75 // Hiding the contet proxy and showing the real content instead. |
69 void HideContentProxy(); | 76 void HideContentProxy(); |
70 | 77 |
71 // Showing a content proxy instead of the real content to save resources. | 78 // Showing a content proxy instead of the real content to save resources. |
72 void ShowContentProxy(); | 79 void ShowContentProxy(); |
73 | 80 |
74 const std::string app_id_; | 81 const std::string app_id_; |
(...skipping 10 matching lines...) Expand all Loading... |
85 | 92 |
86 // The content proxy. | 93 // The content proxy. |
87 scoped_ptr<ContentProxy> content_proxy_; | 94 scoped_ptr<ContentProxy> content_proxy_; |
88 | 95 |
89 DISALLOW_COPY_AND_ASSIGN(AppActivity); | 96 DISALLOW_COPY_AND_ASSIGN(AppActivity); |
90 }; | 97 }; |
91 | 98 |
92 } // namespace athena | 99 } // namespace athena |
93 | 100 |
94 #endif // ATHENA_CONTENT_APP_ACTIVITY_H_ | 101 #endif // ATHENA_CONTENT_APP_ACTIVITY_H_ |
OLD | NEW |