| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 334 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 335 crashed_error_code_(0), | 335 crashed_error_code_(0), |
| 336 waiting_for_response_(false), | 336 waiting_for_response_(false), |
| 337 load_state_(net::LOAD_STATE_IDLE, base::string16()), | 337 load_state_(net::LOAD_STATE_IDLE, base::string16()), |
| 338 loading_total_progress_(0.0), | 338 loading_total_progress_(0.0), |
| 339 loading_frames_in_progress_(0), | 339 loading_frames_in_progress_(0), |
| 340 upload_size_(0), | 340 upload_size_(0), |
| 341 upload_position_(0), | 341 upload_position_(0), |
| 342 displayed_insecure_content_(false), | 342 displayed_insecure_content_(false), |
| 343 has_accessed_initial_document_(false), | 343 has_accessed_initial_document_(false), |
| 344 theme_color_(SK_ColorTRANSPARENT), |
| 345 last_sent_theme_color_(SK_ColorTRANSPARENT), |
| 344 capturer_count_(0), | 346 capturer_count_(0), |
| 345 should_normally_be_visible_(true), | 347 should_normally_be_visible_(true), |
| 346 is_being_destroyed_(false), | 348 is_being_destroyed_(false), |
| 347 notify_disconnection_(false), | 349 notify_disconnection_(false), |
| 348 dialog_manager_(NULL), | 350 dialog_manager_(NULL), |
| 349 is_showing_before_unload_dialog_(false), | 351 is_showing_before_unload_dialog_(false), |
| 350 last_active_time_(base::TimeTicks::Now()), | 352 last_active_time_(base::TimeTicks::Now()), |
| 351 closed_by_user_gesture_(false), | 353 closed_by_user_gesture_(false), |
| 352 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 354 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
| 353 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 355 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 RenderWidgetHost* const widget_host = | 715 RenderWidgetHost* const widget_host = |
| 714 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(), | 716 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(), |
| 715 GetFullscreenWidgetRoutingID()); | 717 GetFullscreenWidgetRoutingID()); |
| 716 return widget_host ? widget_host->GetView() : NULL; | 718 return widget_host ? widget_host->GetView() : NULL; |
| 717 } | 719 } |
| 718 | 720 |
| 719 WebContentsView* WebContentsImpl::GetView() const { | 721 WebContentsView* WebContentsImpl::GetView() const { |
| 720 return view_.get(); | 722 return view_.get(); |
| 721 } | 723 } |
| 722 | 724 |
| 725 SkColor WebContentsImpl::GetThemeColor() const { |
| 726 return theme_color_; |
| 727 } |
| 728 |
| 723 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) { | 729 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 724 if (mode == accessibility_mode_) | 730 if (mode == accessibility_mode_) |
| 725 return; | 731 return; |
| 726 | 732 |
| 727 accessibility_mode_ = mode; | 733 accessibility_mode_ = mode; |
| 728 frame_tree_.ForEach( | 734 frame_tree_.ForEach( |
| 729 base::Bind(&ForEachFrameInternal, | 735 base::Bind(&ForEachFrameInternal, |
| 730 base::Bind(&SetAccessibilityModeOnFrame, mode))); | 736 base::Bind(&SetAccessibilityModeOnFrame, mode))); |
| 731 frame_tree_.ForEach( | 737 frame_tree_.ForEach( |
| 732 base::Bind(&ForEachPendingFrameInternal, | 738 base::Bind(&ForEachPendingFrameInternal, |
| (...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 // transition (this is also why the mouse cursor remains as a hand after | 2716 // transition (this is also why the mouse cursor remains as a hand after |
| 2711 // clicking on a link); see bugs 1184641 and 980803. We don't want to | 2717 // clicking on a link); see bugs 1184641 and 980803. We don't want to |
| 2712 // clear the bubble when a user navigates to a named anchor in the same | 2718 // clear the bubble when a user navigates to a named anchor in the same |
| 2713 // page. | 2719 // page. |
| 2714 UpdateTargetURL(render_frame_host->GetRenderViewHost(), GURL()); | 2720 UpdateTargetURL(render_frame_host->GetRenderViewHost(), GURL()); |
| 2715 | 2721 |
| 2716 RenderWidgetHostViewBase* rwhvb = | 2722 RenderWidgetHostViewBase* rwhvb = |
| 2717 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); | 2723 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); |
| 2718 if (rwhvb) | 2724 if (rwhvb) |
| 2719 rwhvb->OnDidNavigateMainFrameToNewPage(); | 2725 rwhvb->OnDidNavigateMainFrameToNewPage(); |
| 2726 |
| 2727 // Reset theme color on navigation to new page. |
| 2728 theme_color_ = SK_ColorTRANSPARENT; |
| 2720 } | 2729 } |
| 2721 | 2730 |
| 2722 if (!details.is_in_page) { | 2731 if (!details.is_in_page) { |
| 2723 // Once the main frame is navigated, we're no longer considered to have | 2732 // Once the main frame is navigated, we're no longer considered to have |
| 2724 // displayed insecure content. | 2733 // displayed insecure content. |
| 2725 displayed_insecure_content_ = false; | 2734 displayed_insecure_content_ = false; |
| 2726 SSLManager::NotifySSLInternalStateChanged( | 2735 SSLManager::NotifySSLInternalStateChanged( |
| 2727 GetController().GetBrowserContext()); | 2736 GetController().GetBrowserContext()); |
| 2728 } | 2737 } |
| 2729 | 2738 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2762 if (force_disable_overscroll_content_) | 2771 if (force_disable_overscroll_content_) |
| 2763 return false; | 2772 return false; |
| 2764 | 2773 |
| 2765 if (delegate_) | 2774 if (delegate_) |
| 2766 return delegate_->CanOverscrollContent(); | 2775 return delegate_->CanOverscrollContent(); |
| 2767 | 2776 |
| 2768 return false; | 2777 return false; |
| 2769 } | 2778 } |
| 2770 | 2779 |
| 2771 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) { | 2780 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) { |
| 2772 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2781 // Update the theme color. This is to be published to observers on visually |
| 2773 DidChangeThemeColor(theme_color)); | 2782 // non empty paint. |
| 2783 theme_color_ = theme_color; |
| 2774 } | 2784 } |
| 2775 | 2785 |
| 2776 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( | 2786 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( |
| 2777 const GURL& url, | 2787 const GURL& url, |
| 2778 const std::string& security_info, | 2788 const std::string& security_info, |
| 2779 const std::string& http_method, | 2789 const std::string& http_method, |
| 2780 const std::string& mime_type, | 2790 const std::string& mime_type, |
| 2781 ResourceType resource_type) { | 2791 ResourceType resource_type) { |
| 2782 | 2792 |
| 2783 // Send out a notification that we loaded a resource from our memory cache. | 2793 // Send out a notification that we loaded a resource from our memory cache. |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3257 | 3267 |
| 3258 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { | 3268 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { |
| 3259 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); | 3269 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); |
| 3260 RemoveMediaPlayerEntry(player_cookie, &active_video_players_); | 3270 RemoveMediaPlayerEntry(player_cookie, &active_video_players_); |
| 3261 MaybeReleasePowerSaveBlockers(); | 3271 MaybeReleasePowerSaveBlockers(); |
| 3262 } | 3272 } |
| 3263 | 3273 |
| 3264 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { | 3274 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { |
| 3265 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3275 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3266 DidFirstVisuallyNonEmptyPaint()); | 3276 DidFirstVisuallyNonEmptyPaint()); |
| 3277 |
| 3278 if (theme_color_ != last_sent_theme_color_) { |
| 3279 // Theme color should have updated by now if there was one. |
| 3280 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3281 DidChangeThemeColor(theme_color_)); |
| 3282 last_sent_theme_color_ = theme_color_; |
| 3283 } |
| 3267 } | 3284 } |
| 3268 | 3285 |
| 3269 void WebContentsImpl::DidChangeVisibleSSLState() { | 3286 void WebContentsImpl::DidChangeVisibleSSLState() { |
| 3270 if (delegate_) | 3287 if (delegate_) |
| 3271 delegate_->VisibleSSLStateChanged(this); | 3288 delegate_->VisibleSSLStateChanged(this); |
| 3272 } | 3289 } |
| 3273 | 3290 |
| 3274 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { | 3291 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { |
| 3275 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3292 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3276 BeforeFormRepostWarningShow()); | 3293 BeforeFormRepostWarningShow()); |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4537 node->render_manager()->ResumeResponseDeferredAtStart(); | 4554 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4538 } | 4555 } |
| 4539 | 4556 |
| 4540 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4557 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4541 force_disable_overscroll_content_ = force_disable; | 4558 force_disable_overscroll_content_ = force_disable; |
| 4542 if (view_) | 4559 if (view_) |
| 4543 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4560 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4544 } | 4561 } |
| 4545 | 4562 |
| 4546 } // namespace content | 4563 } // namespace content |
| OLD | NEW |