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/shell/shell_app_activity.h" | 5 #include "athena/content/shell/shell_app_activity.h" |
6 | 6 |
7 #include "content/public/browser/web_contents.h" | 7 #include "content/public/browser/web_contents.h" |
8 #include "extensions/browser/app_window/app_window.h" | 8 #include "extensions/browser/app_window/app_window.h" |
9 #include "extensions/browser/app_window/native_app_window.h" | 9 #include "extensions/browser/app_window/native_app_window.h" |
10 #include "extensions/shell/browser/shell_app_window.h" | |
11 #include "ui/views/controls/webview/webview.h" | 10 #include "ui/views/controls/webview/webview.h" |
12 | 11 |
13 namespace athena { | 12 namespace athena { |
14 | 13 |
15 ShellAppActivity::ShellAppActivity(extensions::AppWindow* app_window) | 14 ShellAppActivity::ShellAppActivity(extensions::AppWindow* app_window) |
16 : AppActivity(app_window->extension_id()), app_window_(app_window) { | 15 : AppActivity(app_window->extension_id()), app_window_(app_window) { |
17 } | 16 DCHECK(app_window_); |
18 | |
19 ShellAppActivity::ShellAppActivity(extensions::ShellAppWindow* app_window, | |
20 const std::string& app_id) | |
21 : AppActivity(app_id), app_window_(NULL), shell_app_window_(app_window) { | |
22 } | 17 } |
23 | 18 |
24 ShellAppActivity::~ShellAppActivity() { | 19 ShellAppActivity::~ShellAppActivity() { |
25 if (app_window_) | 20 app_window_->GetBaseWindow()->Close(); // Deletes |app_window_|. |
26 app_window_->GetBaseWindow()->Close(); // Deletes |app_window_|. | |
27 } | 21 } |
28 | 22 |
29 views::Widget* ShellAppActivity::CreateWidget() { | 23 views::Widget* ShellAppActivity::CreateWidget() { |
30 return NULL; // Use default widget. | 24 return NULL; // Use default widget. |
31 } | 25 } |
32 | 26 |
33 views::WebView* ShellAppActivity::GetWebView() { | 27 views::WebView* ShellAppActivity::GetWebView() { |
34 content::WebContents* web_contents = | 28 content::WebContents* web_contents = app_window_->web_contents(); |
35 app_window_ ? app_window_->web_contents() : | |
36 shell_app_window_->GetAssociatedWebContents(); | |
37 views::WebView* web_view = | 29 views::WebView* web_view = |
38 new views::WebView(web_contents->GetBrowserContext()); | 30 new views::WebView(web_contents->GetBrowserContext()); |
39 web_view->SetWebContents(web_contents); | 31 web_view->SetWebContents(web_contents); |
40 Observe(web_contents); | 32 Observe(web_contents); |
41 return web_view; | 33 return web_view; |
42 } | 34 } |
43 | 35 |
44 } // namespace athena | 36 } // namespace athena |
OLD | NEW |