summaryrefslogtreecommitdiffstats
path: root/athena/content/shell/shell_app_activity.cc
blob: 50eb45b6e4804f855aea7a9ef45ad9f1f8c570b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "athena/content/shell/shell_app_activity.h"

#include "content/public/browser/web_contents.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/shell/browser/shell_app_window.h"
#include "ui/views/controls/webview/webview.h"

namespace athena {

ShellAppActivity::ShellAppActivity(extensions::AppWindow* app_window)
    : AppActivity(app_window->extension_id()), app_window_(app_window) {
}

ShellAppActivity::ShellAppActivity(extensions::ShellAppWindow* app_window,
                                   const std::string& app_id)
    : AppActivity(app_id), app_window_(NULL), shell_app_window_(app_window) {
}

ShellAppActivity::~ShellAppActivity() {
  if (app_window_)
    app_window_->GetBaseWindow()->Close();  // Deletes |app_window_|.
}

views::Widget* ShellAppActivity::CreateWidget() {
  return NULL;  // Use default widget.
}

views::WebView* ShellAppActivity::GetWebView() {
  content::WebContents* web_contents =
      app_window_ ? app_window_->web_contents() :
      shell_app_window_->GetAssociatedWebContents();
  views::WebView* web_view =
      new views::WebView(web_contents->GetBrowserContext());
  web_view->SetWebContents(web_contents);
  Observe(web_contents);
  return web_view;
}

}  // namespace athena