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/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 return (url.SchemeIsHTTPOrHTTPS() || | 762 return (url.SchemeIsHTTPOrHTTPS() || |
763 url.SchemeIs(extensions::kExtensionScheme) || | 763 url.SchemeIs(extensions::kExtensionScheme) || |
764 url.SchemeIs("data")); | 764 url.SchemeIs("data")); |
765 } | 765 } |
766 | 766 |
767 // static | 767 // static |
768 bool PrerenderManager::DoesSubresourceURLHaveValidScheme(const GURL& url) { | 768 bool PrerenderManager::DoesSubresourceURLHaveValidScheme(const GURL& url) { |
769 return DoesURLHaveValidScheme(url) || url == url::kAboutBlankURL; | 769 return DoesURLHaveValidScheme(url) || url == url::kAboutBlankURL; |
770 } | 770 } |
771 | 771 |
772 std::unique_ptr<base::DictionaryValue> PrerenderManager::GetAsValue() const { | 772 std::unique_ptr<base::DictionaryValue> PrerenderManager::CopyAsValue() const { |
773 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 773 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
774 | 774 |
775 auto dict_value = base::MakeUnique<base::DictionaryValue>(); | 775 auto dict_value = base::MakeUnique<base::DictionaryValue>(); |
776 dict_value->Set("history", prerender_history_->GetEntriesAsValue()); | 776 dict_value->Set("history", prerender_history_->CopyEntriesAsValue()); |
777 dict_value->Set("active", GetActivePrerendersAsValue()); | 777 dict_value->Set("active", GetActivePrerendersAsValue()); |
778 dict_value->SetBoolean("enabled", | 778 dict_value->SetBoolean("enabled", |
779 GetPredictionStatus() == NetworkPredictionStatus::ENABLED); | 779 GetPredictionStatus() == NetworkPredictionStatus::ENABLED); |
780 std::string disabled_note; | 780 std::string disabled_note; |
781 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_ALWAYS) | 781 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_ALWAYS) |
782 disabled_note = "Disabled by user setting"; | 782 disabled_note = "Disabled by user setting"; |
783 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK) | 783 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK) |
784 disabled_note = "Disabled on cellular connection by default"; | 784 disabled_note = "Disabled on cellular connection by default"; |
785 dict_value->SetString("disabled_note", disabled_note); | 785 dict_value->SetString("disabled_note", disabled_note); |
786 dict_value->SetBoolean("omnibox_enabled", IsOmniboxEnabled(profile_)); | 786 dict_value->SetBoolean("omnibox_enabled", IsOmniboxEnabled(profile_)); |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 return weak_factory_.GetWeakPtr(); | 1431 return weak_factory_.GetWeakPtr(); |
1432 } | 1432 } |
1433 | 1433 |
1434 void PrerenderManager::SetPrerenderContentsFactoryForTest( | 1434 void PrerenderManager::SetPrerenderContentsFactoryForTest( |
1435 PrerenderContents::Factory* prerender_contents_factory) { | 1435 PrerenderContents::Factory* prerender_contents_factory) { |
1436 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1436 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1437 prerender_contents_factory_.reset(prerender_contents_factory); | 1437 prerender_contents_factory_.reset(prerender_contents_factory); |
1438 } | 1438 } |
1439 | 1439 |
1440 } // namespace prerender | 1440 } // namespace prerender |
OLD | NEW |