| 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 "chrome/browser/ui/webui/net_internals/net_internals_ui.h" | 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 CancelableRequestConsumer consumer_; | 244 CancelableRequestConsumer consumer_; |
| 245 // Libcros request handle. | 245 // Libcros request handle. |
| 246 CancelableRequestProvider::Handle syslogs_request_id_; | 246 CancelableRequestProvider::Handle syslogs_request_id_; |
| 247 }; | 247 }; |
| 248 #endif | 248 #endif |
| 249 | 249 |
| 250 // The pref member about whether HTTP throttling is enabled, which needs to | 250 // The pref member about whether HTTP throttling is enabled, which needs to |
| 251 // be accessed on the UI thread. | 251 // be accessed on the UI thread. |
| 252 BooleanPrefMember http_throttling_enabled_; | 252 BooleanPrefMember http_throttling_enabled_; |
| 253 | 253 |
| 254 // The pref member that determines whether experimentation on HTTP throttling | |
| 255 // is allowed (this becomes false once the user explicitly sets the | |
| 256 // feature to on or off). | |
| 257 BooleanPrefMember http_throttling_may_experiment_; | |
| 258 | |
| 259 // This is the "real" message handler, which lives on the IO thread. | 254 // This is the "real" message handler, which lives on the IO thread. |
| 260 scoped_refptr<IOThreadImpl> proxy_; | 255 scoped_refptr<IOThreadImpl> proxy_; |
| 261 | 256 |
| 262 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; | 257 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; |
| 263 | 258 |
| 264 #ifdef OS_CHROMEOS | 259 #ifdef OS_CHROMEOS |
| 265 // Class that handles getting and filtering system logs. | 260 // Class that handles getting and filtering system logs. |
| 266 scoped_ptr<SystemLogsGetter> syslogs_getter_; | 261 scoped_ptr<SystemLogsGetter> syslogs_getter_; |
| 267 #endif | 262 #endif |
| 268 | 263 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 417 } |
| 423 } | 418 } |
| 424 | 419 |
| 425 void NetInternalsMessageHandler::RegisterMessages() { | 420 void NetInternalsMessageHandler::RegisterMessages() { |
| 426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 427 | 422 |
| 428 Profile* profile = Profile::FromWebUI(web_ui()); | 423 Profile* profile = Profile::FromWebUI(web_ui()); |
| 429 PrefService* pref_service = profile->GetPrefs(); | 424 PrefService* pref_service = profile->GetPrefs(); |
| 430 http_throttling_enabled_.Init( | 425 http_throttling_enabled_.Init( |
| 431 prefs::kHttpThrottlingEnabled, pref_service, this); | 426 prefs::kHttpThrottlingEnabled, pref_service, this); |
| 432 http_throttling_may_experiment_.Init( | |
| 433 prefs::kHttpThrottlingMayExperiment, pref_service, NULL); | |
| 434 | 427 |
| 435 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), | 428 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), |
| 436 profile->GetRequestContext()); | 429 profile->GetRequestContext()); |
| 437 #ifdef OS_CHROMEOS | 430 #ifdef OS_CHROMEOS |
| 438 syslogs_getter_.reset(new SystemLogsGetter(this, | 431 syslogs_getter_.reset(new SystemLogsGetter(this, |
| 439 chromeos::system::SyslogsProvider::GetInstance())); | 432 chromeos::system::SyslogsProvider::GetInstance())); |
| 440 #endif | 433 #endif |
| 441 | 434 |
| 442 prerender::PrerenderManager* prerender_manager = | 435 prerender::PrerenderManager* prerender_manager = |
| 443 prerender::PrerenderManagerFactory::GetForProfile(profile); | 436 prerender::PrerenderManagerFactory::GetForProfile(profile); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) { | 601 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) { |
| 609 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 602 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 610 | 603 |
| 611 bool enable = false; | 604 bool enable = false; |
| 612 if (!list->GetBoolean(0, &enable)) { | 605 if (!list->GetBoolean(0, &enable)) { |
| 613 NOTREACHED(); | 606 NOTREACHED(); |
| 614 return; | 607 return; |
| 615 } | 608 } |
| 616 | 609 |
| 617 http_throttling_enabled_.SetValue(enable); | 610 http_throttling_enabled_.SetValue(enable); |
| 618 | |
| 619 // We never receive OnEnableHttpThrottling unless the user has modified | |
| 620 // the value of the checkbox on the about:net-internals page. Once the | |
| 621 // user does that, we no longer change its value automatically (e.g. | |
| 622 // by changing the default or running an experiment). | |
| 623 if (http_throttling_may_experiment_.GetValue()) { | |
| 624 http_throttling_may_experiment_.SetValue(false); | |
| 625 } | |
| 626 } | 611 } |
| 627 | 612 |
| 628 void NetInternalsMessageHandler::OnClearBrowserCache(const ListValue* list) { | 613 void NetInternalsMessageHandler::OnClearBrowserCache(const ListValue* list) { |
| 629 BrowsingDataRemover* remover = | 614 BrowsingDataRemover* remover = |
| 630 new BrowsingDataRemover(Profile::FromWebUI(web_ui()), | 615 new BrowsingDataRemover(Profile::FromWebUI(web_ui()), |
| 631 BrowsingDataRemover::EVERYTHING, | 616 BrowsingDataRemover::EVERYTHING, |
| 632 base::Time()); | 617 base::Time()); |
| 633 remover->Remove(BrowsingDataRemover::REMOVE_CACHE); | 618 remover->Remove(BrowsingDataRemover::REMOVE_CACHE); |
| 634 // BrowsingDataRemover deletes itself. | 619 // BrowsingDataRemover deletes itself. |
| 635 } | 620 } |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 | 1567 |
| 1583 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1568 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1584 : WebUIController(web_ui) { | 1569 : WebUIController(web_ui) { |
| 1585 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1570 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1586 | 1571 |
| 1587 // Set up the chrome://net-internals/ source. | 1572 // Set up the chrome://net-internals/ source. |
| 1588 Profile* profile = Profile::FromWebUI(web_ui); | 1573 Profile* profile = Profile::FromWebUI(web_ui); |
| 1589 profile->GetChromeURLDataManager()->AddDataSource( | 1574 profile->GetChromeURLDataManager()->AddDataSource( |
| 1590 CreateNetInternalsHTMLSource()); | 1575 CreateNetInternalsHTMLSource()); |
| 1591 } | 1576 } |
| OLD | NEW |