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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 975293004: Start caching the theme color in web_contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Caching on web_contents_impl now Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 namespace { 121 namespace {
122 122
123 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; 123 const int kMinimumDelayBetweenLoadingUpdatesMS = 100;
124 124
125 // This matches what Blink's ProgressTracker has traditionally used for a 125 // This matches what Blink's ProgressTracker has traditionally used for a
126 // minimum progress value. 126 // minimum progress value.
127 const double kMinimumLoadingProgress = 0.1; 127 const double kMinimumLoadingProgress = 0.1;
128 128
129 const char kDotGoogleDotCom[] = ".google.com"; 129 const char kDotGoogleDotCom[] = ".google.com";
130 130
131 const SkColor kDefaultThemeColor = 0xFFF2F2F2;
no sievers 2015/03/05 20:18:41 It would be nice if this could be set by the appli
Yusuf 2015/03/05 22:05:15 Moved to setting it to transparent and handling th
132
131 #if defined(OS_ANDROID) 133 #if defined(OS_ANDROID)
132 const char kWebContentsAndroidKey[] = "web_contents_android"; 134 const char kWebContentsAndroidKey[] = "web_contents_android";
133 #endif // OS_ANDROID 135 #endif // OS_ANDROID
134 136
135 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > 137 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> >
136 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; 138 g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
137 139
138 static int StartDownload(RenderFrameHost* rfh, 140 static int StartDownload(RenderFrameHost* rfh,
139 const GURL& url, 141 const GURL& url,
140 bool is_favicon, 142 bool is_favicon,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), 336 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
335 crashed_error_code_(0), 337 crashed_error_code_(0),
336 waiting_for_response_(false), 338 waiting_for_response_(false),
337 load_state_(net::LOAD_STATE_IDLE, base::string16()), 339 load_state_(net::LOAD_STATE_IDLE, base::string16()),
338 loading_total_progress_(0.0), 340 loading_total_progress_(0.0),
339 loading_frames_in_progress_(0), 341 loading_frames_in_progress_(0),
340 upload_size_(0), 342 upload_size_(0),
341 upload_position_(0), 343 upload_position_(0),
342 displayed_insecure_content_(false), 344 displayed_insecure_content_(false),
343 has_accessed_initial_document_(false), 345 has_accessed_initial_document_(false),
346 theme_color_(kDefaultThemeColor),
344 capturer_count_(0), 347 capturer_count_(0),
345 should_normally_be_visible_(true), 348 should_normally_be_visible_(true),
346 is_being_destroyed_(false), 349 is_being_destroyed_(false),
347 notify_disconnection_(false), 350 notify_disconnection_(false),
348 dialog_manager_(NULL), 351 dialog_manager_(NULL),
349 is_showing_before_unload_dialog_(false), 352 is_showing_before_unload_dialog_(false),
350 last_active_time_(base::TimeTicks::Now()), 353 last_active_time_(base::TimeTicks::Now()),
351 closed_by_user_gesture_(false), 354 closed_by_user_gesture_(false),
352 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 355 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
353 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 356 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 RenderWidgetHost* const widget_host = 716 RenderWidgetHost* const widget_host =
714 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(), 717 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(),
715 GetFullscreenWidgetRoutingID()); 718 GetFullscreenWidgetRoutingID());
716 return widget_host ? widget_host->GetView() : NULL; 719 return widget_host ? widget_host->GetView() : NULL;
717 } 720 }
718 721
719 WebContentsView* WebContentsImpl::GetView() const { 722 WebContentsView* WebContentsImpl::GetView() const {
720 return view_.get(); 723 return view_.get();
721 } 724 }
722 725
726 SkColor WebContentsImpl::GetThemeColor() const {
727 return theme_color_;
728 }
729
723 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) { 730 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) {
724 if (mode == accessibility_mode_) 731 if (mode == accessibility_mode_)
725 return; 732 return;
726 733
727 accessibility_mode_ = mode; 734 accessibility_mode_ = mode;
728 frame_tree_.ForEach( 735 frame_tree_.ForEach(
729 base::Bind(&ForEachFrameInternal, 736 base::Bind(&ForEachFrameInternal,
730 base::Bind(&SetAccessibilityModeOnFrame, mode))); 737 base::Bind(&SetAccessibilityModeOnFrame, mode)));
731 frame_tree_.ForEach( 738 frame_tree_.ForEach(
732 base::Bind(&ForEachPendingFrameInternal, 739 base::Bind(&ForEachPendingFrameInternal,
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 // transition (this is also why the mouse cursor remains as a hand after 2717 // 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 2718 // 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 2719 // clear the bubble when a user navigates to a named anchor in the same
2713 // page. 2720 // page.
2714 UpdateTargetURL(render_frame_host->GetRenderViewHost(), GURL()); 2721 UpdateTargetURL(render_frame_host->GetRenderViewHost(), GURL());
2715 2722
2716 RenderWidgetHostViewBase* rwhvb = 2723 RenderWidgetHostViewBase* rwhvb =
2717 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); 2724 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView());
2718 if (rwhvb) 2725 if (rwhvb)
2719 rwhvb->OnDidNavigateMainFrameToNewPage(); 2726 rwhvb->OnDidNavigateMainFrameToNewPage();
2727
2728 // Reset theme color on navigation to new page.
2729 theme_color_ = kDefaultThemeColor;
2720 } 2730 }
2721 2731
2722 if (!details.is_in_page) { 2732 if (!details.is_in_page) {
2723 // Once the main frame is navigated, we're no longer considered to have 2733 // Once the main frame is navigated, we're no longer considered to have
2724 // displayed insecure content. 2734 // displayed insecure content.
2725 displayed_insecure_content_ = false; 2735 displayed_insecure_content_ = false;
2726 SSLManager::NotifySSLInternalStateChanged( 2736 SSLManager::NotifySSLInternalStateChanged(
2727 GetController().GetBrowserContext()); 2737 GetController().GetBrowserContext());
2728 } 2738 }
2729 2739
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 if (force_disable_overscroll_content_) 2772 if (force_disable_overscroll_content_)
2763 return false; 2773 return false;
2764 2774
2765 if (delegate_) 2775 if (delegate_)
2766 return delegate_->CanOverscrollContent(); 2776 return delegate_->CanOverscrollContent();
2767 2777
2768 return false; 2778 return false;
2769 } 2779 }
2770 2780
2771 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) { 2781 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) {
2772 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2782 // Update the theme color. This is to be published to observers on visually
2773 DidChangeThemeColor(theme_color)); 2783 // non empty paint.
2784 theme_color_ = theme_color;
2774 } 2785 }
2775 2786
2776 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( 2787 void WebContentsImpl::OnDidLoadResourceFromMemoryCache(
2777 const GURL& url, 2788 const GURL& url,
2778 const std::string& security_info, 2789 const std::string& security_info,
2779 const std::string& http_method, 2790 const std::string& http_method,
2780 const std::string& mime_type, 2791 const std::string& mime_type,
2781 ResourceType resource_type) { 2792 ResourceType resource_type) {
2782 2793
2783 // Send out a notification that we loaded a resource from our memory cache. 2794 // 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
3257 3268
3258 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { 3269 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) {
3259 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); 3270 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_);
3260 RemoveMediaPlayerEntry(player_cookie, &active_video_players_); 3271 RemoveMediaPlayerEntry(player_cookie, &active_video_players_);
3261 MaybeReleasePowerSaveBlockers(); 3272 MaybeReleasePowerSaveBlockers();
3262 } 3273 }
3263 3274
3264 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { 3275 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() {
3265 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3276 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3266 DidFirstVisuallyNonEmptyPaint()); 3277 DidFirstVisuallyNonEmptyPaint());
3278
3279 // Theme color should have updated by now if there was one.
3280 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3281 DidChangeThemeColor(theme_color_));
no sievers 2015/03/05 20:18:41 Should we cache the last sent color and only notif
Yusuf 2015/03/05 22:05:15 Done.
3267 } 3282 }
3268 3283
3269 void WebContentsImpl::DidChangeVisibleSSLState() { 3284 void WebContentsImpl::DidChangeVisibleSSLState() {
3270 if (delegate_) 3285 if (delegate_)
3271 delegate_->VisibleSSLStateChanged(this); 3286 delegate_->VisibleSSLStateChanged(this);
3272 } 3287 }
3273 3288
3274 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { 3289 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() {
3275 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3290 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3276 BeforeFormRepostWarningShow()); 3291 BeforeFormRepostWarningShow());
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4537 node->render_manager()->ResumeResponseDeferredAtStart(); 4552 node->render_manager()->ResumeResponseDeferredAtStart();
4538 } 4553 }
4539 4554
4540 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4555 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4541 force_disable_overscroll_content_ = force_disable; 4556 force_disable_overscroll_content_ = force_disable;
4542 if (view_) 4557 if (view_)
4543 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4558 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4544 } 4559 }
4545 4560
4546 } // namespace content 4561 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698