| 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_PUBLIC_WEB_ACTIVITY_H_ | 5 #ifndef ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ |
| 6 #define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ | 6 #define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_ |
| 7 | 7 |
| 8 #include <vector> |
| 9 |
| 8 #include "athena/activity/public/activity.h" | 10 #include "athena/activity/public/activity.h" |
| 9 #include "athena/activity/public/activity_view_model.h" | 11 #include "athena/activity/public/activity_view_model.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 10 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
| 13 | 16 |
| 17 class SkBitmap; |
| 18 |
| 14 namespace content { | 19 namespace content { |
| 15 class BrowserContext; | 20 class BrowserContext; |
| 16 class WebContents; | 21 class WebContents; |
| 17 } | 22 } |
| 18 | 23 |
| 24 namespace gfx { |
| 25 class Size; |
| 26 } |
| 27 |
| 19 namespace views { | 28 namespace views { |
| 20 class WebView; | 29 class WebView; |
| 21 class WidgetDelegate; | 30 class WidgetDelegate; |
| 22 } | 31 } |
| 23 | 32 |
| 24 namespace athena { | 33 namespace athena { |
| 25 | 34 |
| 26 class AthenaWebView; | 35 class AthenaWebView; |
| 27 | 36 |
| 28 class WebActivity : public Activity, | 37 class WebActivity : public Activity, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 virtual void SetCurrentState(ActivityState state) OVERRIDE; | 51 virtual void SetCurrentState(ActivityState state) OVERRIDE; |
| 43 virtual ActivityState GetCurrentState() OVERRIDE; | 52 virtual ActivityState GetCurrentState() OVERRIDE; |
| 44 virtual bool IsVisible() OVERRIDE; | 53 virtual bool IsVisible() OVERRIDE; |
| 45 virtual ActivityMediaState GetMediaState() OVERRIDE; | 54 virtual ActivityMediaState GetMediaState() OVERRIDE; |
| 46 virtual aura::Window* GetWindow() OVERRIDE; | 55 virtual aura::Window* GetWindow() OVERRIDE; |
| 47 | 56 |
| 48 // ActivityViewModel: | 57 // ActivityViewModel: |
| 49 virtual void Init() OVERRIDE; | 58 virtual void Init() OVERRIDE; |
| 50 virtual SkColor GetRepresentativeColor() const OVERRIDE; | 59 virtual SkColor GetRepresentativeColor() const OVERRIDE; |
| 51 virtual base::string16 GetTitle() const OVERRIDE; | 60 virtual base::string16 GetTitle() const OVERRIDE; |
| 61 virtual gfx::ImageSkia GetIcon() const OVERRIDE; |
| 52 virtual bool UsesFrame() const OVERRIDE; | 62 virtual bool UsesFrame() const OVERRIDE; |
| 53 virtual views::View* GetContentsView() OVERRIDE; | 63 virtual views::View* GetContentsView() OVERRIDE; |
| 54 virtual views::Widget* CreateWidget() OVERRIDE; | 64 virtual views::Widget* CreateWidget() OVERRIDE; |
| 55 virtual void CreateOverviewModeImage() OVERRIDE; | 65 virtual void CreateOverviewModeImage() OVERRIDE; |
| 56 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; | 66 virtual gfx::ImageSkia GetOverviewModeImage() OVERRIDE; |
| 57 virtual void PrepareContentsForOverview() OVERRIDE; | 67 virtual void PrepareContentsForOverview() OVERRIDE; |
| 58 virtual void ResetContentsView() OVERRIDE; | 68 virtual void ResetContentsView() OVERRIDE; |
| 59 | 69 |
| 60 // content::WebContentsObserver: | 70 // content::WebContentsObserver: |
| 71 virtual void DidNavigateMainFrame( |
| 72 const content::LoadCommittedDetails& details, |
| 73 const content::FrameNavigateParams& params) OVERRIDE; |
| 61 virtual void TitleWasSet(content::NavigationEntry* entry, | 74 virtual void TitleWasSet(content::NavigationEntry* entry, |
| 62 bool explicit_set) OVERRIDE; | 75 bool explicit_set) OVERRIDE; |
| 63 virtual void DidUpdateFaviconURL( | 76 virtual void DidUpdateFaviconURL( |
| 64 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | 77 const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
| 65 virtual void DidChangeThemeColor(SkColor theme_color) OVERRIDE; | 78 virtual void DidChangeThemeColor(SkColor theme_color) OVERRIDE; |
| 66 | 79 |
| 67 private: | 80 private: |
| 81 // Called when a favicon download initiated in DidUpdateFaviconURL() |
| 82 // has completed. |
| 83 void OnDidDownloadFavicon( |
| 84 int id, |
| 85 int http_status_code, |
| 86 const GURL& url, |
| 87 const std::vector<SkBitmap>& bitmaps, |
| 88 const std::vector<gfx::Size>& original_bitmap_sizes); |
| 89 |
| 68 // Make the content visible. This call should only be paired with | 90 // Make the content visible. This call should only be paired with |
| 69 // MakeInvisible. Note: Upon object creation the content is visible. | 91 // MakeInvisible. Note: Upon object creation the content is visible. |
| 70 void MakeVisible(); | 92 void MakeVisible(); |
| 71 | 93 |
| 72 // Make the content invisible. This call should only be paired with | 94 // Make the content invisible. This call should only be paired with |
| 73 // MakeVisible. | 95 // MakeVisible. |
| 74 void MakeInvisible(); | 96 void MakeInvisible(); |
| 75 | 97 |
| 76 // Reload the content if required, and start observing it. | 98 // Reload the content if required, and start observing it. |
| 77 void ReloadAndObserve(); | 99 void ReloadAndObserve(); |
| 78 | 100 |
| 79 content::BrowserContext* browser_context_; | 101 content::BrowserContext* browser_context_; |
| 80 const base::string16 title_; | 102 const base::string16 title_; |
| 103 gfx::ImageSkia icon_; |
| 81 const GURL url_; | 104 const GURL url_; |
| 82 AthenaWebView* web_view_; | 105 AthenaWebView* web_view_; |
| 83 SkColor title_color_; | 106 SkColor title_color_; |
| 84 | 107 |
| 85 // The current state for this activity. | 108 // The current state for this activity. |
| 86 ActivityState current_state_; | 109 ActivityState current_state_; |
| 87 | 110 |
| 88 // The image which will be used in overview mode. | 111 // The image which will be used in overview mode. |
| 89 gfx::ImageSkia overview_mode_image_; | 112 gfx::ImageSkia overview_mode_image_; |
| 90 | 113 |
| 114 base::WeakPtrFactory<WebActivity> weak_ptr_factory_; |
| 115 |
| 91 DISALLOW_COPY_AND_ASSIGN(WebActivity); | 116 DISALLOW_COPY_AND_ASSIGN(WebActivity); |
| 92 }; | 117 }; |
| 93 | 118 |
| 94 } // namespace athena | 119 } // namespace athena |
| 95 | 120 |
| 96 #endif // ATHENA_CONTENT_WEB_ACTIVITY_H_ | 121 #endif // ATHENA_CONTENT_WEB_ACTIVITY_H_ |
| OLD | NEW |