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