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/input/public/accelerator_manager.h" | 9 #include "athena/input/public/accelerator_manager.h" |
| 10 #include "base/bind.h" | |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "content/public/browser/native_web_keyboard_event.h" | 12 #include "content/public/browser/native_web_keyboard_event.h" |
| 12 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
| 13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_contents_delegate.h" | 15 #include "content/public/browser/web_contents_delegate.h" |
| 15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/compositor/closure_animation_observer.h" | |
| 18 #include "ui/compositor/scoped_layer_animation_settings.h" | |
| 16 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | 19 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" |
| 17 #include "ui/views/controls/webview/webview.h" | 20 #include "ui/views/controls/webview/webview.h" |
| 18 #include "ui/views/focus/focus_manager.h" | 21 #include "ui/views/focus/focus_manager.h" |
| 19 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 20 | 23 |
| 21 namespace athena { | 24 namespace athena { |
| 22 namespace { | 25 namespace { |
| 23 | 26 |
| 24 class WebActivityController : public AcceleratorHandler { | 27 class WebActivityController : public AcceleratorHandler { |
| 25 public: | 28 public: |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 bool enter_fullscreen) OVERRIDE { | 252 bool enter_fullscreen) OVERRIDE { |
| 250 fullscreen_ = enter_fullscreen; | 253 fullscreen_ = enter_fullscreen; |
| 251 GetWidget()->SetFullscreen(fullscreen_); | 254 GetWidget()->SetFullscreen(fullscreen_); |
| 252 } | 255 } |
| 253 | 256 |
| 254 virtual bool IsFullscreenForTabOrPending( | 257 virtual bool IsFullscreenForTabOrPending( |
| 255 const content::WebContents* web_contents) const OVERRIDE { | 258 const content::WebContents* web_contents) const OVERRIDE { |
| 256 return fullscreen_; | 259 return fullscreen_; |
| 257 } | 260 } |
| 258 | 261 |
| 262 virtual void LoadingStateChanged(content::WebContents* source, | |
| 263 bool to_different_document) OVERRIDE { | |
| 264 bool has_stopped = source == NULL || !source->IsLoading(); | |
| 265 LoadProgressChanged(source, has_stopped ? 1 : 0); | |
| 266 } | |
| 267 | |
| 268 virtual void LoadProgressChanged(content::WebContents* source, | |
| 269 double progress) OVERRIDE { | |
| 270 if (!progress) | |
| 271 return; | |
|
Jun Mukai
2014/08/30 09:04:18
I think progress_bar_ should be reset here.
Otherw
sadrul
2014/08/30 15:06:48
Cancelling the load triggers a LoadingStateChanged
Jun Mukai
2014/08/30 16:24:18
cool, I didn't know.
| |
| 272 | |
| 273 if (!progress_bar_) { | |
| 274 CreateProgressBar(); | |
| 275 source->GetNativeView()->layer()->Add(progress_bar_.get()); | |
| 276 } | |
| 277 progress_bar_->SetBounds(gfx::Rect( | |
| 278 0, 0, progress * progress_bar_->parent()->bounds().width(), 3)); | |
| 279 if (progress < 1) | |
| 280 return; | |
| 281 | |
| 282 ui::ScopedLayerAnimationSettings settings(progress_bar_->GetAnimator()); | |
|
Jun Mukai
2014/08/30 09:04:18
EASE_IN tween type in this case maybe?
http://www.
sadrul
2014/08/30 15:06:48
Done (Thanks for the link! Is there a specific sec
Jun Mukai
2014/08/30 16:24:18
I couldn't find the case specifically for fade-out
| |
| 283 ui::Layer* layer = progress_bar_.get(); | |
| 284 settings.AddObserver(new ui::ClosureAnimationObserver( | |
| 285 base::Bind(&base::DeletePointer<ui::Layer>, progress_bar_.release()))); | |
| 286 layer->SetOpacity(0.f); | |
| 287 } | |
| 288 | |
| 259 private: | 289 private: |
| 290 void CreateProgressBar() { | |
| 291 CHECK(!progress_bar_); | |
| 292 progress_bar_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | |
| 293 progress_bar_->SetColor(SkColorSetRGB(0x00, 0xb0, 0xc7)); | |
| 294 } | |
| 295 | |
| 260 scoped_ptr<WebActivityController> controller_; | 296 scoped_ptr<WebActivityController> controller_; |
| 261 | 297 |
| 262 // If the activity got evicted, this is the web content which holds the known | 298 // If the activity got evicted, this is the web content which holds the known |
| 263 // state of the content before eviction. | 299 // state of the content before eviction. |
| 264 scoped_ptr<content::WebContents> evicted_web_contents_; | 300 scoped_ptr<content::WebContents> evicted_web_contents_; |
| 265 | 301 |
| 302 scoped_ptr<ui::Layer> progress_bar_; | |
| 303 | |
| 266 // TODO(oshima): Find out if we should support window fullscreen. | 304 // TODO(oshima): Find out if we should support window fullscreen. |
| 267 // It may still useful when a user is in split mode. | 305 // It may still useful when a user is in split mode. |
| 268 bool fullscreen_; | 306 bool fullscreen_; |
| 269 | 307 |
| 270 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); | 308 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); |
| 271 }; | 309 }; |
| 272 | 310 |
| 273 WebActivity::WebActivity(content::BrowserContext* browser_context, | 311 WebActivity::WebActivity(content::BrowserContext* browser_context, |
| 274 const GURL& url) | 312 const GURL& url) |
| 275 : browser_context_(browser_context), | 313 : browser_context_(browser_context), |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 void WebActivity::DidUpdateFaviconURL( | 450 void WebActivity::DidUpdateFaviconURL( |
| 413 const std::vector<content::FaviconURL>& candidates) { | 451 const std::vector<content::FaviconURL>& candidates) { |
| 414 ActivityManager::Get()->UpdateActivity(this); | 452 ActivityManager::Get()->UpdateActivity(this); |
| 415 } | 453 } |
| 416 | 454 |
| 417 void WebActivity::DidChangeThemeColor(SkColor theme_color) { | 455 void WebActivity::DidChangeThemeColor(SkColor theme_color) { |
| 418 title_color_ = theme_color; | 456 title_color_ = theme_color; |
| 419 } | 457 } |
| 420 | 458 |
| 421 } // namespace athena | 459 } // namespace athena |
| OLD | NEW |