Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: athena/content/web_activity.cc

Issue 314303004: Use webview in web activity (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « athena/content/web_activity.h ('k') | athena/main/athena_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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());
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
OLDNEW
« no previous file with comments | « athena/content/web_activity.h ('k') | athena/main/athena_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698