| 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/content/content_proxy.h" | 9 #include "athena/content/content_proxy.h" |
| 10 #include "athena/content/media_utils.h" | 10 #include "athena/content/media_utils.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 views::WebView* web_view_; | 148 views::WebView* web_view_; |
| 149 bool reserved_accelerator_enabled_; | 149 bool reserved_accelerator_enabled_; |
| 150 scoped_ptr<AcceleratorManager> accelerator_manager_; | 150 scoped_ptr<AcceleratorManager> accelerator_manager_; |
| 151 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 151 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
| 152 | 152 |
| 153 DISALLOW_COPY_AND_ASSIGN(WebActivityController); | 153 DISALLOW_COPY_AND_ASSIGN(WebActivityController); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 const SkColor kDefaultTitleColor = SkColorSetRGB(0xf2, 0xf2, 0xf2); | 156 const SkColor kDefaultTitleColor = SkColorSetRGB(0xf2, 0xf2, 0xf2); |
| 157 const int kIconSize = 32; | 157 const int kIconSize = 32; |
| 158 const int kDistanceShowReloadMessage = 100; | 158 const float kDistanceShowReloadMessage = 100; |
| 159 const int kDistanceReload = 150; | 159 const float kDistanceReload = 150; |
| 160 | 160 |
| 161 } // namespace | 161 } // namespace |
| 162 | 162 |
| 163 // A web view for athena's web activity. Note that AthenaWebView will create its | 163 // A web view for athena's web activity. Note that AthenaWebView will create its |
| 164 // own content so that it can eject and reload it. | 164 // own content so that it can eject and reload it. |
| 165 class AthenaWebView : public views::WebView { | 165 class AthenaWebView : public views::WebView { |
| 166 public: | 166 public: |
| 167 explicit AthenaWebView(content::BrowserContext* context) | 167 explicit AthenaWebView(content::BrowserContext* context) |
| 168 : views::WebView(context), | 168 : views::WebView(context), |
| 169 controller_(new WebActivityController(this)), | 169 controller_(new WebActivityController(this)), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // NULL is returned if the URL wasn't opened immediately. | 260 // NULL is returned if the URL wasn't opened immediately. |
| 261 return NULL; | 261 return NULL; |
| 262 } | 262 } |
| 263 | 263 |
| 264 virtual bool CanOverscrollContent() const override { | 264 virtual bool CanOverscrollContent() const override { |
| 265 const std::string value = CommandLine::ForCurrentProcess()-> | 265 const std::string value = CommandLine::ForCurrentProcess()-> |
| 266 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); | 266 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); |
| 267 return value != "0"; | 267 return value != "0"; |
| 268 } | 268 } |
| 269 | 269 |
| 270 virtual void OverscrollUpdate(int delta_y) override { | 270 virtual void OverscrollUpdate(float delta_y) override { |
| 271 overscroll_y_ = delta_y; | 271 overscroll_y_ = delta_y; |
| 272 if (overscroll_y_ > kDistanceShowReloadMessage) { | 272 if (overscroll_y_ > kDistanceShowReloadMessage) { |
| 273 if (!reload_message_) | 273 if (!reload_message_) |
| 274 CreateReloadMessage(); | 274 CreateReloadMessage(); |
| 275 reload_message_->Show(); | 275 reload_message_->Show(); |
| 276 float opacity = 1.0f; | 276 float opacity = 1.0f; |
| 277 if (overscroll_y_ < kDistanceReload) { | 277 if (overscroll_y_ < kDistanceReload) { |
| 278 opacity = | 278 opacity = (overscroll_y_ - kDistanceShowReloadMessage) / |
| 279 (overscroll_y_ - kDistanceShowReloadMessage) / | 279 (kDistanceReload - kDistanceShowReloadMessage); |
| 280 static_cast<float>(kDistanceReload - kDistanceShowReloadMessage); | |
| 281 } | 280 } |
| 282 reload_message_->GetLayer()->SetOpacity(opacity); | 281 reload_message_->GetLayer()->SetOpacity(opacity); |
| 283 } else if (reload_message_) { | 282 } else if (reload_message_) { |
| 284 reload_message_->Hide(); | 283 reload_message_->Hide(); |
| 285 } | 284 } |
| 286 } | 285 } |
| 287 | 286 |
| 288 virtual void OverscrollComplete() override { | 287 virtual void OverscrollComplete() override { |
| 289 if (overscroll_y_ >= kDistanceReload) | 288 if (overscroll_y_ >= kDistanceReload) |
| 290 GetWebContents()->GetController().Reload(false); | 289 GetWebContents()->GetController().Reload(false); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 404 |
| 406 scoped_ptr<ui::Layer> progress_bar_; | 405 scoped_ptr<ui::Layer> progress_bar_; |
| 407 | 406 |
| 408 scoped_ptr<views::Widget> reload_message_; | 407 scoped_ptr<views::Widget> reload_message_; |
| 409 | 408 |
| 410 // TODO(oshima): Find out if we should support window fullscreen. | 409 // TODO(oshima): Find out if we should support window fullscreen. |
| 411 // It may still useful when a user is in split mode. | 410 // It may still useful when a user is in split mode. |
| 412 bool fullscreen_; | 411 bool fullscreen_; |
| 413 | 412 |
| 414 // The distance that the user has overscrolled vertically. | 413 // The distance that the user has overscrolled vertically. |
| 415 int overscroll_y_; | 414 float overscroll_y_; |
| 416 | 415 |
| 417 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); | 416 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); |
| 418 }; | 417 }; |
| 419 | 418 |
| 420 WebActivity::WebActivity(content::BrowserContext* browser_context, | 419 WebActivity::WebActivity(content::BrowserContext* browser_context, |
| 421 const base::string16& title, | 420 const base::string16& title, |
| 422 const GURL& url) | 421 const GURL& url) |
| 423 : browser_context_(browser_context), | 422 : browser_context_(browser_context), |
| 424 web_view_(new AthenaWebView(browser_context)), | 423 web_view_(new AthenaWebView(browser_context)), |
| 425 title_(title), | 424 title_(title), |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 if (content_proxy_.get()) | 624 if (content_proxy_.get()) |
| 626 content_proxy_.reset(NULL); | 625 content_proxy_.reset(NULL); |
| 627 } | 626 } |
| 628 | 627 |
| 629 void WebActivity::ShowContentProxy() { | 628 void WebActivity::ShowContentProxy() { |
| 630 if (!content_proxy_.get()) | 629 if (!content_proxy_.get()) |
| 631 content_proxy_.reset(new ContentProxy(web_view_)); | 630 content_proxy_.reset(new ContentProxy(web_view_)); |
| 632 } | 631 } |
| 633 | 632 |
| 634 } // namespace athena | 633 } // namespace athena |
| OLD | NEW |