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

Side by Side Diff: chrome/browser/ui/webui/settings/md_settings_ui.cc

Issue 1776393003: MD Settings: avoid double pref observation on Startup Pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix cros compile Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/webui/settings/md_settings_ui.h" 5 #include "chrome/browser/ui/webui/settings/md_settings_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 AddLocalizedStrings(html_source, profile); 116 AddLocalizedStrings(html_source, profile);
117 html_source->SetDefaultResource(IDR_SETTINGS_SETTINGS_HTML); 117 html_source->SetDefaultResource(IDR_SETTINGS_SETTINGS_HTML);
118 118
119 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), 119 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
120 html_source); 120 html_source);
121 } 121 }
122 122
123 MdSettingsUI::~MdSettingsUI() { 123 MdSettingsUI::~MdSettingsUI() {
124 } 124 }
125 125
126 void MdSettingsUI::AddSettingsPageUIHandler( 126 void MdSettingsUI::RenderViewReused(
127 content::WebUIMessageHandler* handler_raw) { 127 content::RenderViewHost* /*render_view_host*/) {
128 scoped_ptr<content::WebUIMessageHandler> handler(handler_raw); 128 for (size_t i = 0; i < handlers_.size(); ++i)
129 DCHECK(handler.get()); 129 handlers_[i]->RenderViewReused();
dschuyler 2016/03/10 21:49:49 How about this instead? for (auto handler : handle
Dan Beam 2016/03/11 00:07:12 Done.
130 }
130 131
131 web_ui()->AddMessageHandler(handler.release()); 132 void MdSettingsUI::AddSettingsPageUIHandler(SettingsPageUIHandler* handler) {
133 DCHECK(handler);
dschuyler 2016/03/10 21:49:49 Would it be bad to have the same handler added twi
Dan Beam 2016/03/11 00:07:11 Done.
134 handlers_.push_back(handler);
135 web_ui()->AddMessageHandler(handler); // |handler| is owned by |web_ui()|.
132 } 136 }
133 137
134 void MdSettingsUI::DidStartProvisionalLoadForFrame( 138 void MdSettingsUI::DidStartProvisionalLoadForFrame(
135 content::RenderFrameHost* render_frame_host, 139 content::RenderFrameHost* render_frame_host,
136 const GURL& validated_url, 140 const GURL& validated_url,
137 bool is_error_page, 141 bool is_error_page,
138 bool is_iframe_srcdoc) { 142 bool is_iframe_srcdoc) {
139 load_start_time_ = base::Time::Now(); 143 load_start_time_ = base::Time::Now();
140 } 144 }
141 145
142 void MdSettingsUI::DocumentLoadedInFrame( 146 void MdSettingsUI::DocumentLoadedInFrame(
143 content::RenderFrameHost* render_frame_host) { 147 content::RenderFrameHost* render_frame_host) {
144 UMA_HISTOGRAM_TIMES("Settings.LoadDocumentTime.MD", 148 UMA_HISTOGRAM_TIMES("Settings.LoadDocumentTime.MD",
145 base::Time::Now() - load_start_time_); 149 base::Time::Now() - load_start_time_);
146 } 150 }
147 151
148 void MdSettingsUI::DocumentOnLoadCompletedInMainFrame() { 152 void MdSettingsUI::DocumentOnLoadCompletedInMainFrame() {
149 UMA_HISTOGRAM_TIMES("Settings.LoadCompletedTime.MD", 153 UMA_HISTOGRAM_TIMES("Settings.LoadCompletedTime.MD",
150 base::Time::Now() - load_start_time_); 154 base::Time::Now() - load_start_time_);
151 } 155 }
152 156
153 } // namespace settings 157 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698