app_activity.cc revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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.
4
5#include "athena/content/app_activity.h"
6
7#include "apps/shell/browser/shell_app_window.h"
8#include "athena/activity/public/activity_manager.h"
9#include "content/public/browser/web_contents.h"
10#include "ui/views/controls/webview/webview.h"
11
12namespace athena {
13
14// TODO(mukai): specifies the same accelerators of WebActivity.
15AppActivity::AppActivity(apps::ShellAppWindow* app_window)
16    : app_window_(app_window), web_view_(NULL) {
17  DCHECK(app_window_);
18}
19
20AppActivity::~AppActivity() {
21}
22
23ActivityViewModel* AppActivity::GetActivityViewModel() {
24  return this;
25}
26
27void AppActivity::Init() {
28}
29
30SkColor AppActivity::GetRepresentativeColor() {
31  // TODO(sad): Compute the color from the favicon.
32  return SK_ColorGRAY;
33}
34
35base::string16 AppActivity::GetTitle() {
36  return web_view_->GetWebContents()->GetTitle();
37}
38
39views::View* AppActivity::GetContentsView() {
40  if (!web_view_) {
41    content::WebContents* web_contents =
42        app_window_->GetAssociatedWebContents();
43    web_view_ = new views::WebView(web_contents->GetBrowserContext());
44    web_view_->SetWebContents(web_contents);
45    Observe(web_contents);
46  }
47  return web_view_;
48}
49
50void AppActivity::TitleWasSet(content::NavigationEntry* entry,
51                              bool explicit_set) {
52  ActivityManager::Get()->UpdateActivity(this);
53}
54
55void AppActivity::DidUpdateFaviconURL(
56    const std::vector<content::FaviconURL>& candidates) {
57  ActivityManager::Get()->UpdateActivity(this);
58}
59
60}  // namespace athena
61