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" | |
9 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
10 #include "ui/views/controls/webview/webview.h" | 9 #include "ui/views/controls/webview/webview.h" |
11 | 10 |
12 namespace athena { | 11 namespace athena { |
13 | 12 |
14 WebActivity::WebActivity(content::BrowserContext* browser_context, | 13 WebActivity::WebActivity(content::BrowserContext* browser_context, |
15 const GURL& url) | 14 const GURL& url) |
16 : browser_context_(browser_context), url_(url), web_view_(NULL) { | 15 : browser_context_(browser_context), url_(url), web_view_(NULL) { |
17 } | 16 } |
18 | 17 |
19 WebActivity::~WebActivity() { | 18 WebActivity::~WebActivity() { |
20 } | 19 } |
21 | 20 |
22 ActivityViewModel* WebActivity::GetActivityViewModel() { | 21 ActivityViewModel* WebActivity::GetActivityViewModel() { |
23 return this; | 22 return this; |
24 } | 23 } |
25 | 24 |
26 SkColor WebActivity::GetRepresentativeColor() { | 25 SkColor WebActivity::GetRepresentativeColor() { |
27 // TODO(sad): Compute the color from the favicon. | 26 // TODO(sad): Compute the color from the favicon. |
28 return SK_ColorGRAY; | 27 return SK_ColorGRAY; |
29 } | 28 } |
30 | 29 |
31 std::string WebActivity::GetTitle() { | 30 base::string16 WebActivity::GetTitle() { |
32 return base::UTF16ToUTF8(web_view_->GetWebContents()->GetTitle()); | 31 return web_view_->GetWebContents()->GetTitle(); |
33 } | 32 } |
34 | 33 |
35 views::View* WebActivity::GetContentsView() { | 34 views::View* WebActivity::GetContentsView() { |
36 if (!web_view_) { | 35 if (!web_view_) { |
37 web_view_ = new views::WebView(browser_context_); | 36 web_view_ = new views::WebView(browser_context_); |
38 web_view_->LoadInitialURL(url_); | 37 web_view_->LoadInitialURL(url_); |
39 Observe(web_view_->GetWebContents()); | 38 Observe(web_view_->GetWebContents()); |
40 } | 39 } |
41 return web_view_; | 40 return web_view_; |
42 } | 41 } |
43 | 42 |
44 void WebActivity::TitleWasSet(content::NavigationEntry* entry, | 43 void WebActivity::TitleWasSet(content::NavigationEntry* entry, |
45 bool explicit_set) { | 44 bool explicit_set) { |
46 ActivityManager::Get()->UpdateActivity(this); | 45 ActivityManager::Get()->UpdateActivity(this); |
47 } | 46 } |
48 | 47 |
49 void WebActivity::DidUpdateFaviconURL( | 48 void WebActivity::DidUpdateFaviconURL( |
50 const std::vector<content::FaviconURL>& candidates) { | 49 const std::vector<content::FaviconURL>& candidates) { |
51 ActivityManager::Get()->UpdateActivity(this); | 50 ActivityManager::Get()->UpdateActivity(this); |
52 } | 51 } |
53 | 52 |
54 } // namespace athena | 53 } // namespace athena |
OLD | NEW |