Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2545)

Unified Diff: athena/content/web_activity.cc

Issue 548633005: Adding overview / layer framework to Activities so that unloaded / sleeping activities can be shown… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: athena/content/web_activity.cc
diff --git a/athena/content/web_activity.cc b/athena/content/web_activity.cc
index 85ede624a7f6383ceb3c3bc5f9e846e920038617..ce14bf84db99d7f73fc62237afae0cb3f56e1080 100644
--- a/athena/content/web_activity.cc
+++ b/athena/content/web_activity.cc
@@ -6,6 +6,7 @@
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
+#include "athena/content/content_proxy.h"
#include "athena/input/public/accelerator_manager.h"
#include "base/bind.h"
#include "base/command_line.h"
@@ -175,6 +176,10 @@ class AthenaWebView : public views::WebView {
scoped_ptr<content::WebContents> old_contents(SwapWebContents(
scoped_ptr<content::WebContents>(content::WebContents::Create(
content::WebContents::CreateParams(browser_context())))));
+ // If there is a progress bar, we need to get rid of it now since its
+ // associated content, parent window and layers will disappear with evicting
+ // the content.
+ progress_bar_.reset();
evicted_web_contents_.reset(
content::WebContents::Create(content::WebContents::CreateParams(
old_contents->GetBrowserContext())));
@@ -360,15 +365,18 @@ void WebActivity::SetCurrentState(Activity::ActivityState state) {
case ACTIVITY_VISIBLE:
if (!web_view_)
break;
- MakeVisible();
+ HideContentProxy();
ReloadAndObserve();
break;
case ACTIVITY_INVISIBLE:
if (!web_view_)
break;
+
if (current_state_ == ACTIVITY_VISIBLE)
- MakeInvisible();
- ReloadAndObserve();
+ ShowContentProxy();
+ else
+ ReloadAndObserve();
+
break;
case ACTIVITY_BACKGROUND_LOW_PRIORITY:
DCHECK(ACTIVITY_VISIBLE == current_state_ ||
@@ -382,6 +390,8 @@ void WebActivity::SetCurrentState(Activity::ActivityState state) {
break;
case ACTIVITY_UNLOADED:
DCHECK_NE(ACTIVITY_UNLOADED, current_state_);
+ if (content_proxy_.get())
+ content_proxy_->ContentWillUnload();
Observe(NULL);
web_view_->EvictContent();
break;
@@ -444,10 +454,10 @@ views::View* WebActivity::GetContentsView() {
web_view_->LoadInitialURL(url_);
// Make sure the content gets properly shown.
if (current_state_ == ACTIVITY_VISIBLE) {
- MakeVisible();
+ HideContentProxy();
ReloadAndObserve();
} else if (current_state_ == ACTIVITY_INVISIBLE) {
- MakeInvisible();
+ ShowContentProxy();
ReloadAndObserve();
} else {
// If not previously specified, we change the state now to invisible..
@@ -457,23 +467,26 @@ views::View* WebActivity::GetContentsView() {
return web_view_;
}
-void WebActivity::CreateOverviewModeImage() {
- // TODO(skuhne): Create an overview.
-}
-
gfx::ImageSkia WebActivity::GetOverviewModeImage() {
- return overview_mode_image_;
+ if (content_proxy_.get())
+ content_proxy_->GetContentImage();
+ return gfx::ImageSkia();
}
void WebActivity::PrepareContentsForOverview() {
// Turn on fast resizing to avoid re-laying out the web contents when
- // entering / exiting overview mode.
- web_view_->SetFastResize(true);
+ // entering / exiting overview mode and the content is visible.
+ if (!content_proxy_.get())
+ web_view_->SetFastResize(true);
}
void WebActivity::ResetContentsView() {
- web_view_->SetFastResize(false);
- web_view_->Layout();
+ // Turn on fast resizing to avoid re-laying out the web contents when
+ // entering / exiting overview mode and the content is visible.
+ if (!content_proxy_.get()) {
+ web_view_->SetFastResize(false);
+ web_view_->Layout();
+ }
}
void WebActivity::TitleWasSet(content::NavigationEntry* entry,
@@ -491,37 +504,14 @@ void WebActivity::DidChangeThemeColor(SkColor theme_color) {
ActivityManager::Get()->UpdateActivity(this);
}
-void WebActivity::MakeVisible() {
- // TODO(skuhne): Once we know how to handle the Overview mode, this has to
- // be moved into an ActivityContentController which is used by all activities.
- // Make the content visible.
- // TODO(skuhne): If this can be combined with app_activity, move this into a
- // separate class.
- web_view_->SetVisible(true);
- web_view_->GetWebContents()->GetNativeView()->Show();
- // If we have a proxy image, we can delete it now since the contet goes live.
- // TODO(skuhne): Once we have figured out how to do overview mode that code
- // needs to go here.
- overview_mode_image_ = gfx::ImageSkia();
+void WebActivity::HideContentProxy() {
+ if (content_proxy_.get())
+ content_proxy_.reset(NULL);
}
-void WebActivity::MakeInvisible() {
- // TODO(skuhne): Once we know how to handle the Overview mode, this has to
- // be moved into an ActivityContentController which is used by all activities.
- // TODO(skuhne): If this can be combined with app_activity, move this into a
- // separate class.
- DCHECK(web_view_->visible());
- // Create our proxy image / layer.
- if (current_state_ == ACTIVITY_VISIBLE) {
- // Create a proxy image of the current visible content.
- // TODO(skuhne): Do this once we figure out how to do overview mode.
- overview_mode_image_ = gfx::ImageSkia();
- }
- // Now we can hide this.
- // Note: This might have to be done asynchronously after the read back took
- // place.
- web_view_->GetWebContents()->GetNativeView()->Hide();
- web_view_->SetVisible(false);
+void WebActivity::ShowContentProxy() {
+ if (!content_proxy_.get() && web_view_)
+ content_proxy_.reset(new ContentProxy(web_view_, this));
}
void WebActivity::ReloadAndObserve() {

Powered by Google App Engine
This is Rietveld 408576698