Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / athena / content / web_activity.h
blob1b978b1999a0a0b92a890c90e414023137aeedca
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.
5 #ifndef ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_
6 #define ATHENA_CONTENT_PUBLIC_WEB_ACTIVITY_H_
8 #include <vector>
10 #include "athena/activity/public/activity.h"
11 #include "athena/activity/public/activity_view_model.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h"
15 #include "content/public/browser/web_contents_observer.h"
16 #include "ui/gfx/image/image_skia.h"
18 class SkBitmap;
20 namespace content {
21 class BrowserContext;
22 class WebContents;
25 namespace gfx {
26 class Size;
29 namespace views {
30 class WebView;
31 class WidgetDelegate;
34 namespace athena {
36 class AthenaWebView;
37 class ContentProxy;
39 class WebActivity : public Activity,
40 public ActivityViewModel,
41 public content::WebContentsObserver {
42 public:
43 WebActivity(content::BrowserContext* context,
44 const base::string16& title,
45 const GURL& gurl);
46 explicit WebActivity(content::WebContents* contents);
48 protected:
49 ~WebActivity() override;
51 // Activity:
52 athena::ActivityViewModel* GetActivityViewModel() override;
53 void SetCurrentState(ActivityState state) override;
54 ActivityState GetCurrentState() override;
55 bool IsVisible() override;
56 ActivityMediaState GetMediaState() override;
57 aura::Window* GetWindow() override;
58 content::WebContents* GetWebContents() override;
60 // ActivityViewModel:
61 void Init() override;
62 SkColor GetRepresentativeColor() const override;
63 base::string16 GetTitle() const override;
64 gfx::ImageSkia GetIcon() const override;
65 void SetActivityView(ActivityView* activity_view) override;
66 bool UsesFrame() const override;
67 views::View* GetContentsView() override;
68 gfx::ImageSkia GetOverviewModeImage() override;
69 void PrepareContentsForOverview() override;
70 void ResetContentsView() override;
72 // content::WebContentsObserver:
73 void DidNavigateMainFrame(
74 const content::LoadCommittedDetails& details,
75 const content::FrameNavigateParams& params) override;
76 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
77 void DidUpdateFaviconURL(
78 const std::vector<content::FaviconURL>& candidates) override;
79 void DidChangeThemeColor(SkColor theme_color) override;
81 private:
82 // Called when a favicon download initiated in DidUpdateFaviconURL()
83 // has completed.
84 void OnDidDownloadFavicon(
85 int id,
86 int http_status_code,
87 const GURL& url,
88 const std::vector<SkBitmap>& bitmaps,
89 const std::vector<gfx::Size>& original_bitmap_sizes);
91 // Hiding the contet proxy and showing the real content instead.
92 void HideContentProxy();
94 // Showing a content proxy instead of the real content to save resoruces.
95 void ShowContentProxy();
97 content::BrowserContext* browser_context_;
98 AthenaWebView* web_view_;
99 const base::string16 title_;
100 SkColor title_color_;
101 gfx::ImageSkia icon_;
103 // The current state for this activity.
104 ActivityState current_state_;
106 // The content proxy.
107 scoped_ptr<ContentProxy> content_proxy_;
109 // WebActivity does not take ownership of |activity_view_|. If the view is
110 // destroyed before the activity, then it must be reset using
111 // SetActivityView(nullptr).
112 ActivityView* activity_view_;
114 base::WeakPtrFactory<WebActivity> weak_ptr_factory_;
116 DISALLOW_COPY_AND_ASSIGN(WebActivity);
119 } // namespace athena
121 #endif // ATHENA_CONTENT_WEB_ACTIVITY_H_