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