Chromium Code Reviews| 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/app_activity.h" | 5 #include "athena/content/app_activity.h" |
| 6 | 6 |
| 7 #include "athena/activity/public/activity_manager.h" | 7 #include "athena/activity/public/activity_manager.h" |
| 8 #include "athena/content/app_activity_registry.h" | 8 #include "athena/content/app_activity_registry.h" |
| 9 #include "athena/content/public/app_content_control_delegate.h" | |
| 10 #include "athena/content/public/app_registry.h" | 9 #include "athena/content/public/app_registry.h" |
| 11 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 12 #include "ui/views/controls/webview/webview.h" | 11 #include "ui/views/controls/webview/webview.h" |
| 13 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 14 | 13 |
| 15 namespace athena { | 14 namespace athena { |
| 16 | 15 |
| 17 // TODO(mukai): specifies the same accelerators of WebActivity. | 16 // TODO(mukai): specifies the same accelerators of WebActivity. |
| 18 AppActivity::AppActivity() | 17 AppActivity::AppActivity(const std::string& app_id) |
| 19 : web_view_(NULL), | 18 : app_id_(app_id), |
| 19 web_view_(NULL), | |
| 20 current_state_(ACTIVITY_UNLOADED), | 20 current_state_(ACTIVITY_UNLOADED), |
| 21 app_activity_registry_(NULL) { | 21 app_activity_registry_(NULL) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 AppActivity::~AppActivity() { | 24 AppActivity::~AppActivity() { |
| 25 // If this activity is registered, we unregister it now. | 25 // If this activity is registered, we unregister it now. |
| 26 if (app_activity_registry_) | 26 if (app_activity_registry_) |
| 27 app_activity_registry_->UnregisterAppActivity(this); | 27 app_activity_registry_->UnregisterAppActivity(this); |
| 28 } | 28 } |
| 29 | 29 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 } | 112 } |
| 113 | 113 |
| 114 views::View* AppActivity::GetContentsView() { | 114 views::View* AppActivity::GetContentsView() { |
| 115 if (!web_view_) { | 115 if (!web_view_) { |
| 116 // TODO(oshima): use apps::NativeAppWindowViews | 116 // TODO(oshima): use apps::NativeAppWindowViews |
| 117 content::WebContents* web_contents = GetWebContents(); | 117 content::WebContents* web_contents = GetWebContents(); |
| 118 web_view_ = new views::WebView(web_contents->GetBrowserContext()); | 118 web_view_ = new views::WebView(web_contents->GetBrowserContext()); |
| 119 web_view_->SetWebContents(web_contents); | 119 web_view_->SetWebContents(web_contents); |
| 120 SetCurrentState(ACTIVITY_INVISIBLE); | 120 SetCurrentState(ACTIVITY_INVISIBLE); |
| 121 Observe(web_contents); | 121 Observe(web_contents); |
| 122 overview_mode_image_ = gfx::ImageSkia(); | 122 overview_mode_image_ = gfx::ImageSkia(); |
|
Mr4D (OOO till 08-26)
2014/08/27 20:22:19
Call RegisterActivity from here (or move the code
oshima
2014/08/27 21:20:19
Done.
| |
| 123 } | 123 } |
| 124 return web_view_; | 124 return web_view_; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void AppActivity::CreateOverviewModeImage() { | 127 void AppActivity::CreateOverviewModeImage() { |
| 128 // TODO(skuhne): Implement this! | 128 // TODO(skuhne): Implement this! |
| 129 } | 129 } |
| 130 | 130 |
| 131 gfx::ImageSkia AppActivity::GetOverviewModeImage() { | 131 gfx::ImageSkia AppActivity::GetOverviewModeImage() { |
| 132 return overview_mode_image_; | 132 return overview_mode_image_; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void AppActivity::TitleWasSet(content::NavigationEntry* entry, | 135 void AppActivity::TitleWasSet(content::NavigationEntry* entry, |
| 136 bool explicit_set) { | 136 bool explicit_set) { |
| 137 ActivityManager::Get()->UpdateActivity(this); | 137 ActivityManager::Get()->UpdateActivity(this); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void AppActivity::DidUpdateFaviconURL( | 140 void AppActivity::DidUpdateFaviconURL( |
| 141 const std::vector<content::FaviconURL>& candidates) { | 141 const std::vector<content::FaviconURL>& candidates) { |
| 142 ActivityManager::Get()->UpdateActivity(this); | 142 ActivityManager::Get()->UpdateActivity(this); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void AppActivity::DidStartNavigationToPendingEntry( | 145 void AppActivity::DidStartNavigationToPendingEntry( |
| 146 const GURL& url, | 146 const GURL& url, |
| 147 content::NavigationController::ReloadType reload_type) { | 147 content::NavigationController::ReloadType reload_type) { |
|
Mr4D (OOO till 08-26)
2014/08/27 20:22:19
Since this isn't needed anymore: Remove this funct
oshima
2014/08/27 21:20:19
Done.
| |
| 148 if (!app_activity_registry_) | 148 if (!app_activity_registry_) |
| 149 RegisterActivity(); | 149 RegisterActivity(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Register an |activity| with an application. | 152 // Register an |activity| with an application. |
| 153 // Note: This should only get called once for an |app_window| of the | 153 // Note: This should only get called once for an |app_window| of the |
| 154 // |activity|. | 154 // |activity|. |
| 155 void AppActivity::RegisterActivity() { | 155 void AppActivity::RegisterActivity() { |
| 156 content::WebContents* web_contents = GetWebContents(); | 156 content::WebContents* web_contents = GetWebContents(); |
| 157 AppRegistry* app_registry = AppRegistry::Get(); | 157 AppRegistry* app_registry = AppRegistry::Get(); |
| 158 // Get the application's registry. | 158 // Get the application's registry. |
| 159 app_activity_registry_ = app_registry->GetAppActivityRegistry( | 159 app_activity_registry_ = app_registry->GetAppActivityRegistry( |
| 160 app_registry->GetDelegate()->GetApplicationID(web_contents), | 160 app_id_, web_contents->GetBrowserContext()); |
| 161 web_contents->GetBrowserContext()); | |
| 162 DCHECK(app_activity_registry_); | 161 DCHECK(app_activity_registry_); |
| 163 // Register the activity. | 162 // Register the activity. |
| 164 app_activity_registry_->RegisterAppActivity(this); | 163 app_activity_registry_->RegisterAppActivity(this); |
| 165 } | 164 } |
| 166 | 165 |
| 167 } // namespace athena | 166 } // namespace athena |
| OLD | NEW |