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/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/activity/public/activity_view.h" | |
| 9 #include "athena/content/content_proxy.h" | 10 #include "athena/content/content_proxy.h" |
| 10 #include "athena/content/media_utils.h" | 11 #include "athena/content/media_utils.h" |
| 11 #include "athena/content/public/dialogs.h" | 12 #include "athena/content/public/dialogs.h" |
| 12 #include "athena/content/web_activity_helpers.h" | 13 #include "athena/content/web_activity_helpers.h" |
| 13 #include "athena/input/public/accelerator_manager.h" | 14 #include "athena/input/public/accelerator_manager.h" |
| 14 #include "athena/strings/grit/athena_strings.h" | 15 #include "athena/strings/grit/athena_strings.h" |
| 15 #include "base/bind.h" | 16 #include "base/bind.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "components/favicon_base/select_favicon_frames.h" | 19 #include "components/favicon_base/select_favicon_frames.h" |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 const base::string16& title = web_view_->GetWebContents()->GetTitle(); | 551 const base::string16& title = web_view_->GetWebContents()->GetTitle(); |
| 551 if (!title.empty()) | 552 if (!title.empty()) |
| 552 return title; | 553 return title; |
| 553 return base::UTF8ToUTF16(web_view_->GetWebContents()->GetVisibleURL().host()); | 554 return base::UTF8ToUTF16(web_view_->GetWebContents()->GetVisibleURL().host()); |
| 554 } | 555 } |
| 555 | 556 |
| 556 gfx::ImageSkia WebActivity::GetIcon() const { | 557 gfx::ImageSkia WebActivity::GetIcon() const { |
| 557 return icon_; | 558 return icon_; |
| 558 } | 559 } |
| 559 | 560 |
| 561 void WebActivity::SetActivityView(ActivityView* view) { | |
|
oshima
2014/11/04 22:17:04
ditto
sadrul
2014/11/04 23:26:09
Done.
| |
| 562 activity_view_ = view; | |
| 563 } | |
| 564 | |
| 560 bool WebActivity::UsesFrame() const { | 565 bool WebActivity::UsesFrame() const { |
| 561 return true; | 566 return true; |
| 562 } | 567 } |
| 563 | 568 |
| 564 views::View* WebActivity::GetContentsView() { | 569 views::View* WebActivity::GetContentsView() { |
| 565 return web_view_; | 570 return web_view_; |
| 566 } | 571 } |
| 567 | 572 |
| 568 gfx::ImageSkia WebActivity::GetOverviewModeImage() { | 573 gfx::ImageSkia WebActivity::GetOverviewModeImage() { |
| 569 if (content_proxy_.get()) | 574 if (content_proxy_.get()) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 582 // Turn on fast resizing to avoid re-laying out the web contents when | 587 // Turn on fast resizing to avoid re-laying out the web contents when |
| 583 // entering / exiting overview mode and the content is visible. | 588 // entering / exiting overview mode and the content is visible. |
| 584 if (!content_proxy_.get()) { | 589 if (!content_proxy_.get()) { |
| 585 web_view_->SetFastResize(false); | 590 web_view_->SetFastResize(false); |
| 586 web_view_->Layout(); | 591 web_view_->Layout(); |
| 587 } | 592 } |
| 588 } | 593 } |
| 589 | 594 |
| 590 void WebActivity::TitleWasSet(content::NavigationEntry* entry, | 595 void WebActivity::TitleWasSet(content::NavigationEntry* entry, |
| 591 bool explicit_set) { | 596 bool explicit_set) { |
| 592 ActivityManager::Get()->UpdateActivity(this); | 597 if (activity_view_) |
| 598 activity_view_->UpdateTitle(); | |
| 593 } | 599 } |
| 594 | 600 |
| 595 void WebActivity::DidNavigateMainFrame( | 601 void WebActivity::DidNavigateMainFrame( |
| 596 const content::LoadCommittedDetails& details, | 602 const content::LoadCommittedDetails& details, |
| 597 const content::FrameNavigateParams& params) { | 603 const content::FrameNavigateParams& params) { |
| 598 // Prevent old image requests from calling back to OnDidDownloadFavicon(). | 604 // Prevent old image requests from calling back to OnDidDownloadFavicon(). |
| 599 weak_ptr_factory_.InvalidateWeakPtrs(); | 605 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 600 | 606 |
| 601 icon_ = gfx::ImageSkia(); | 607 icon_ = gfx::ImageSkia(); |
| 602 ActivityManager::Get()->UpdateActivity(this); | 608 if (activity_view_) |
| 609 activity_view_->UpdateIcon(); | |
| 603 } | 610 } |
| 604 | 611 |
| 605 void WebActivity::DidUpdateFaviconURL( | 612 void WebActivity::DidUpdateFaviconURL( |
| 606 const std::vector<content::FaviconURL>& candidates) { | 613 const std::vector<content::FaviconURL>& candidates) { |
| 607 // Pick an arbitrary favicon of type FAVICON to use. | 614 // Pick an arbitrary favicon of type FAVICON to use. |
| 608 // TODO(pkotwicz): Do something better once the favicon code is componentized. | 615 // TODO(pkotwicz): Do something better once the favicon code is componentized. |
| 609 // (crbug.com/401997) | 616 // (crbug.com/401997) |
| 610 weak_ptr_factory_.InvalidateWeakPtrs(); | 617 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 611 for (size_t i = 0; i < candidates.size(); ++i) { | 618 for (size_t i = 0; i < candidates.size(); ++i) { |
| 612 if (candidates[i].icon_type == content::FaviconURL::FAVICON) { | 619 if (candidates[i].icon_type == content::FaviconURL::FAVICON) { |
| 613 web_view_->GetWebContents()->DownloadImage( | 620 web_view_->GetWebContents()->DownloadImage( |
| 614 candidates[i].icon_url, | 621 candidates[i].icon_url, |
| 615 true, | 622 true, |
| 616 0, | 623 0, |
| 617 base::Bind(&WebActivity::OnDidDownloadFavicon, | 624 base::Bind(&WebActivity::OnDidDownloadFavicon, |
| 618 weak_ptr_factory_.GetWeakPtr())); | 625 weak_ptr_factory_.GetWeakPtr())); |
| 619 break; | 626 break; |
| 620 } | 627 } |
| 621 } | 628 } |
| 622 } | 629 } |
| 623 | 630 |
| 624 void WebActivity::OnDidDownloadFavicon( | 631 void WebActivity::OnDidDownloadFavicon( |
| 625 int id, | 632 int id, |
| 626 int http_status_code, | 633 int http_status_code, |
| 627 const GURL& url, | 634 const GURL& url, |
| 628 const std::vector<SkBitmap>& bitmaps, | 635 const std::vector<SkBitmap>& bitmaps, |
| 629 const std::vector<gfx::Size>& original_bitmap_sizes) { | 636 const std::vector<gfx::Size>& original_bitmap_sizes) { |
| 630 icon_ = CreateFaviconImageSkia( | 637 icon_ = CreateFaviconImageSkia( |
| 631 bitmaps, original_bitmap_sizes, kIconSize, nullptr); | 638 bitmaps, original_bitmap_sizes, kIconSize, nullptr); |
| 632 ActivityManager::Get()->UpdateActivity(this); | 639 if (activity_view_) |
| 640 activity_view_->UpdateIcon(); | |
| 633 } | 641 } |
| 634 | 642 |
| 635 void WebActivity::DidChangeThemeColor(SkColor theme_color) { | 643 void WebActivity::DidChangeThemeColor(SkColor theme_color) { |
| 636 title_color_ = theme_color; | 644 title_color_ = theme_color; |
| 637 ActivityManager::Get()->UpdateActivity(this); | 645 if (activity_view_) |
| 646 activity_view_->UpdateRepresentativeColor(); | |
| 638 } | 647 } |
| 639 | 648 |
| 640 void WebActivity::HideContentProxy() { | 649 void WebActivity::HideContentProxy() { |
| 641 if (content_proxy_.get()) | 650 if (content_proxy_.get()) |
| 642 content_proxy_.reset(nullptr); | 651 content_proxy_.reset(nullptr); |
| 643 } | 652 } |
| 644 | 653 |
| 645 void WebActivity::ShowContentProxy() { | 654 void WebActivity::ShowContentProxy() { |
| 646 if (!content_proxy_.get()) | 655 if (!content_proxy_.get()) |
| 647 content_proxy_.reset(new ContentProxy(web_view_)); | 656 content_proxy_.reset(new ContentProxy(web_view_)); |
| 648 } | 657 } |
| 649 | 658 |
| 650 } // namespace athena | 659 } // namespace athena |
| OLD | NEW |