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 #include "athena/content/web_activity.h" | 5 #include "athena/content/web_activity.h" |
6 | 6 |
7 #include "athena/activity/public/activity_manager.h" | 7 #include "athena/activity/public/activity_manager.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "ui/views/controls/webview/webview.h" | |
10 | 11 |
11 namespace athena { | 12 namespace athena { |
12 | 13 |
13 WebActivity::WebActivity(content::WebContents* contents) | 14 WebActivity::WebActivity(content::BrowserContext* browser_context, |
14 : content::WebContentsObserver(contents) { | 15 const GURL& url) |
16 : browser_context_(browser_context), url_(url), web_view_(NULL) { | |
15 } | 17 } |
16 | 18 |
17 WebActivity::~WebActivity() { | 19 WebActivity::~WebActivity() { |
18 } | 20 } |
19 | 21 |
20 ActivityViewModel* WebActivity::GetActivityViewModel() { | 22 ActivityViewModel* WebActivity::GetActivityViewModel() { |
21 return this; | 23 return this; |
22 } | 24 } |
23 | 25 |
24 SkColor WebActivity::GetRepresentativeColor() { | 26 SkColor WebActivity::GetRepresentativeColor() { |
25 // TODO(sad): Compute the color from the favicon. | 27 // TODO(sad): Compute the color from the favicon. |
26 return SK_ColorGRAY; | 28 return SK_ColorGRAY; |
27 } | 29 } |
28 | 30 |
29 std::string WebActivity::GetTitle() { | 31 std::string WebActivity::GetTitle() { |
30 return base::UTF16ToUTF8(web_contents()->GetTitle()); | 32 return base::UTF16ToUTF8(web_view_->GetWebContents()->GetTitle()); |
Jun Mukai
2014/06/06 20:17:29
Don't we need to check web_view_? It might be cal
oshima
2014/06/06 20:55:51
This never called before GetContentsView(), and th
Jun Mukai
2014/06/06 20:57:03
fair enough. thanks.
| |
31 } | 33 } |
32 | 34 |
33 aura::Window* WebActivity::GetNativeWindow() { | 35 views::View* WebActivity::GetContentsView() { |
34 return web_contents()->GetNativeView(); | 36 if (!web_view_) { |
37 web_view_ = new views::WebView(browser_context_); | |
38 web_view_->LoadInitialURL(url_); | |
39 Observe(web_view_->GetWebContents()); | |
40 } | |
41 return web_view_; | |
35 } | 42 } |
36 | 43 |
37 void WebActivity::TitleWasSet(content::NavigationEntry* entry, | 44 void WebActivity::TitleWasSet(content::NavigationEntry* entry, |
38 bool explicit_set) { | 45 bool explicit_set) { |
39 ActivityManager::Get()->UpdateActivity(this); | 46 ActivityManager::Get()->UpdateActivity(this); |
40 } | 47 } |
41 | 48 |
42 void WebActivity::DidUpdateFaviconURL( | 49 void WebActivity::DidUpdateFaviconURL( |
43 const std::vector<content::FaviconURL>& candidates) { | 50 const std::vector<content::FaviconURL>& candidates) { |
44 ActivityManager::Get()->UpdateActivity(this); | 51 ActivityManager::Get()->UpdateActivity(this); |
45 } | 52 } |
46 | 53 |
47 } // namespace athena | 54 } // namespace athena |
OLD | NEW |