diff options
author | Sadrul Habib Chowdhury <sadrul@chromium.org> | 2014-08-30 12:40:25 -0400 |
---|---|---|
committer | Sadrul Habib Chowdhury <sadrul@chromium.org> | 2014-08-30 16:42:19 +0000 |
commit | a596d7b3c51ff8a96be897e1185308fd41f2084f (patch) | |
tree | edca71aedcc9b5bd3522fd66a71e336fa207592a /athena/content | |
parent | d74e0b9e36ef8b296452b14546f8d4b63e07a94c (diff) | |
download | chromium_src-a596d7b3c51ff8a96be897e1185308fd41f2084f.zip chromium_src-a596d7b3c51ff8a96be897e1185308fd41f2084f.tar.gz chromium_src-a596d7b3c51ff8a96be897e1185308fd41f2084f.tar.bz2 |
athena: Show a progress-bar when loading a web-page.
BUG=none
R=mukai@chromium.org
TBR=vollick@chromium.org for DEPS addition on //ui/compositor
Review URL: https://codereview.chromium.org/521013004
Cr-Commit-Position: refs/heads/master@{#292793}
Diffstat (limited to 'athena/content')
-rw-r--r-- | athena/content/DEPS | 1 | ||||
-rw-r--r-- | athena/content/web_activity.cc | 39 |
2 files changed, 40 insertions, 0 deletions
diff --git a/athena/content/DEPS b/athena/content/DEPS index 92cf9e6..1a36f1c 100644 --- a/athena/content/DEPS +++ b/athena/content/DEPS @@ -10,6 +10,7 @@ include_rules = [ "+extensions/common", "+ui/app_list", "+ui/aura", + "+ui/compositor", "+ui/gfx", "+ui/views", diff --git a/athena/content/web_activity.cc b/athena/content/web_activity.cc index 795c8c3..bfc6e3c 100644 --- a/athena/content/web_activity.cc +++ b/athena/content/web_activity.cc @@ -7,12 +7,15 @@ #include "athena/activity/public/activity_factory.h" #include "athena/activity/public/activity_manager.h" #include "athena/input/public/accelerator_manager.h" +#include "base/bind.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" #include "ui/aura/window.h" +#include "ui/compositor/closure_animation_observer.h" +#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/focus/focus_manager.h" @@ -256,13 +259,49 @@ class AthenaWebView : public views::WebView { return fullscreen_; } + virtual void LoadingStateChanged(content::WebContents* source, + bool to_different_document) OVERRIDE { + bool has_stopped = source == NULL || !source->IsLoading(); + LoadProgressChanged(source, has_stopped ? 1 : 0); + } + + virtual void LoadProgressChanged(content::WebContents* source, + double progress) OVERRIDE { + if (!progress) + return; + + if (!progress_bar_) { + CreateProgressBar(); + source->GetNativeView()->layer()->Add(progress_bar_.get()); + } + progress_bar_->SetBounds(gfx::Rect( + 0, 0, progress * progress_bar_->parent()->bounds().width(), 3)); + if (progress < 1) + return; + + ui::ScopedLayerAnimationSettings settings(progress_bar_->GetAnimator()); + settings.SetTweenType(gfx::Tween::EASE_IN); + ui::Layer* layer = progress_bar_.get(); + settings.AddObserver(new ui::ClosureAnimationObserver( + base::Bind(&base::DeletePointer<ui::Layer>, progress_bar_.release()))); + layer->SetOpacity(0.f); + } + private: + void CreateProgressBar() { + CHECK(!progress_bar_); + progress_bar_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); + progress_bar_->SetColor(SkColorSetRGB(0x00, 0xb0, 0xc7)); + } + scoped_ptr<WebActivityController> controller_; // If the activity got evicted, this is the web content which holds the known // state of the content before eviction. scoped_ptr<content::WebContents> evicted_web_contents_; + scoped_ptr<ui::Layer> progress_bar_; + // TODO(oshima): Find out if we should support window fullscreen. // It may still useful when a user is in split mode. bool fullscreen_; |