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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(); |
| 123 RegisterActivity(); |
123 } | 124 } |
124 return web_view_; | 125 return web_view_; |
125 } | 126 } |
126 | 127 |
127 void AppActivity::CreateOverviewModeImage() { | 128 void AppActivity::CreateOverviewModeImage() { |
128 // TODO(skuhne): Implement this! | 129 // TODO(skuhne): Implement this! |
129 } | 130 } |
130 | 131 |
131 gfx::ImageSkia AppActivity::GetOverviewModeImage() { | 132 gfx::ImageSkia AppActivity::GetOverviewModeImage() { |
132 return overview_mode_image_; | 133 return overview_mode_image_; |
133 } | 134 } |
134 | 135 |
135 void AppActivity::TitleWasSet(content::NavigationEntry* entry, | 136 void AppActivity::TitleWasSet(content::NavigationEntry* entry, |
136 bool explicit_set) { | 137 bool explicit_set) { |
137 ActivityManager::Get()->UpdateActivity(this); | 138 ActivityManager::Get()->UpdateActivity(this); |
138 } | 139 } |
139 | 140 |
140 void AppActivity::DidUpdateFaviconURL( | 141 void AppActivity::DidUpdateFaviconURL( |
141 const std::vector<content::FaviconURL>& candidates) { | 142 const std::vector<content::FaviconURL>& candidates) { |
142 ActivityManager::Get()->UpdateActivity(this); | 143 ActivityManager::Get()->UpdateActivity(this); |
143 } | 144 } |
144 | 145 |
145 void AppActivity::DidStartNavigationToPendingEntry( | |
146 const GURL& url, | |
147 content::NavigationController::ReloadType reload_type) { | |
148 if (!app_activity_registry_) | |
149 RegisterActivity(); | |
150 } | |
151 | |
152 // Register an |activity| with an application. | 146 // Register an |activity| with an application. |
153 // Note: This should only get called once for an |app_window| of the | 147 // Note: This should only get called once for an |app_window| of the |
154 // |activity|. | 148 // |activity|. |
155 void AppActivity::RegisterActivity() { | 149 void AppActivity::RegisterActivity() { |
156 content::WebContents* web_contents = GetWebContents(); | 150 content::WebContents* web_contents = GetWebContents(); |
157 AppRegistry* app_registry = AppRegistry::Get(); | 151 AppRegistry* app_registry = AppRegistry::Get(); |
158 // Get the application's registry. | 152 // Get the application's registry. |
159 app_activity_registry_ = app_registry->GetAppActivityRegistry( | 153 app_activity_registry_ = app_registry->GetAppActivityRegistry( |
160 app_registry->GetDelegate()->GetApplicationID(web_contents), | 154 app_id_, web_contents->GetBrowserContext()); |
161 web_contents->GetBrowserContext()); | |
162 DCHECK(app_activity_registry_); | 155 DCHECK(app_activity_registry_); |
163 // Register the activity. | 156 // Register the activity. |
164 app_activity_registry_->RegisterAppActivity(this); | 157 app_activity_registry_->RegisterAppActivity(this); |
165 } | 158 } |
166 | 159 |
167 } // namespace athena | 160 } // namespace athena |
OLD | NEW |