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/web_activity.h" | 5 #include "athena/content/web_activity.h" |
6 | 6 |
7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/input/public/accelerator_manager.h" | 9 #include "athena/input/public/accelerator_manager.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 load_url_params.transferred_global_request_id = | 215 load_url_params.transferred_global_request_id = |
216 params.transferred_global_request_id; | 216 params.transferred_global_request_id; |
217 web_contents()->GetController().LoadURLWithParams(load_url_params); | 217 web_contents()->GetController().LoadURLWithParams(load_url_params); |
218 return web_contents(); | 218 return web_contents(); |
219 } | 219 } |
220 case NEW_FOREGROUND_TAB: | 220 case NEW_FOREGROUND_TAB: |
221 case NEW_BACKGROUND_TAB: | 221 case NEW_BACKGROUND_TAB: |
222 case NEW_POPUP: | 222 case NEW_POPUP: |
223 case NEW_WINDOW: { | 223 case NEW_WINDOW: { |
224 ActivityManager::Get()->AddActivity( | 224 ActivityManager::Get()->AddActivity( |
225 ActivityFactory::Get()->CreateWebActivity(browser_context(), | 225 ActivityFactory::Get()->CreateWebActivity( |
226 params.url)); | 226 browser_context(), base::string16(), params.url)); |
227 break; | 227 break; |
228 } | 228 } |
229 default: | 229 default: |
230 break; | 230 break; |
231 } | 231 } |
232 // NULL is returned if the URL wasn't opened immediately. | 232 // NULL is returned if the URL wasn't opened immediately. |
233 return NULL; | 233 return NULL; |
234 } | 234 } |
235 | 235 |
236 virtual bool CanOverscrollContent() const OVERRIDE { | 236 virtual bool CanOverscrollContent() const OVERRIDE { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 scoped_ptr<ui::Layer> progress_bar_; | 318 scoped_ptr<ui::Layer> progress_bar_; |
319 | 319 |
320 // TODO(oshima): Find out if we should support window fullscreen. | 320 // TODO(oshima): Find out if we should support window fullscreen. |
321 // It may still useful when a user is in split mode. | 321 // It may still useful when a user is in split mode. |
322 bool fullscreen_; | 322 bool fullscreen_; |
323 | 323 |
324 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); | 324 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); |
325 }; | 325 }; |
326 | 326 |
327 WebActivity::WebActivity(content::BrowserContext* browser_context, | 327 WebActivity::WebActivity(content::BrowserContext* browser_context, |
328 const base::string16& title, | |
328 const GURL& url) | 329 const GURL& url) |
329 : browser_context_(browser_context), | 330 : browser_context_(browser_context), |
331 title_(title), | |
330 url_(url), | 332 url_(url), |
331 web_view_(NULL), | 333 web_view_(NULL), |
332 title_color_(kDefaultTitleColor), | 334 title_color_(kDefaultTitleColor), |
333 current_state_(ACTIVITY_UNLOADED) { | 335 current_state_(ACTIVITY_UNLOADED) { |
334 } | 336 } |
335 | 337 |
336 WebActivity::WebActivity(AthenaWebView* web_view) | 338 WebActivity::WebActivity(AthenaWebView* web_view) |
337 : browser_context_(web_view->browser_context()), | 339 : browser_context_(web_view->browser_context()), |
338 url_(web_view->GetWebContents()->GetURL()), | 340 url_(web_view->GetWebContents()->GetURL()), |
339 web_view_(web_view), | 341 web_view_(web_view), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 DCHECK(web_view_); | 419 DCHECK(web_view_); |
418 web_view_->InstallAccelerators(); | 420 web_view_->InstallAccelerators(); |
419 } | 421 } |
420 | 422 |
421 SkColor WebActivity::GetRepresentativeColor() const { | 423 SkColor WebActivity::GetRepresentativeColor() const { |
422 // TODO(sad): Compute the color from the favicon. | 424 // TODO(sad): Compute the color from the favicon. |
423 return web_view_ ? title_color_ : kDefaultUnavailableColor; | 425 return web_view_ ? title_color_ : kDefaultUnavailableColor; |
424 } | 426 } |
425 | 427 |
426 base::string16 WebActivity::GetTitle() const { | 428 base::string16 WebActivity::GetTitle() const { |
429 if (!title_.empty()) | |
430 return title_; | |
431 // TODO(oshima): Use title set by the web contents. | |
sadrul
2014/09/05 15:48:26
We used to show the page-title, but switched to sh
oshima
2014/09/05 16:45:27
Thanks. We probably should confirm if this is stil
| |
427 return web_view_ ? base::UTF8ToUTF16( | 432 return web_view_ ? base::UTF8ToUTF16( |
428 web_view_->GetWebContents()->GetVisibleURL().host()) | 433 web_view_->GetWebContents()->GetVisibleURL().host()) |
429 : base::string16(); | 434 : base::string16(); |
430 } | 435 } |
431 | 436 |
432 bool WebActivity::UsesFrame() const { | 437 bool WebActivity::UsesFrame() const { |
433 return true; | 438 return true; |
434 } | 439 } |
435 | 440 |
436 views::View* WebActivity::GetContentsView() { | 441 views::View* WebActivity::GetContentsView() { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 | 514 |
510 void WebActivity::ReloadAndObserve() { | 515 void WebActivity::ReloadAndObserve() { |
511 if (web_view_->IsContentEvicted()) { | 516 if (web_view_->IsContentEvicted()) { |
512 DCHECK_EQ(ACTIVITY_UNLOADED, current_state_); | 517 DCHECK_EQ(ACTIVITY_UNLOADED, current_state_); |
513 web_view_->ReloadContent(); | 518 web_view_->ReloadContent(); |
514 } | 519 } |
515 Observe(web_view_->GetWebContents()); | 520 Observe(web_view_->GetWebContents()); |
516 } | 521 } |
517 | 522 |
518 } // namespace athena | 523 } // namespace athena |
OLD | NEW |