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

Side by Side Diff: ios/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc

Issue 2584483002: Fix ntp-tiles-internals crash in incognito mode (Closed)
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ui/webui/ntp_tiles_internals_ui.h" 5 #include "ios/chrome/browser/ui/webui/ntp_tiles_internals_ui.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "components/grit/components_resources.h" 8 #include "components/grit/components_resources.h"
9 #include "components/ntp_tiles/field_trial.h" 9 #include "components/ntp_tiles/field_trial.h"
10 #include "components/ntp_tiles/most_visited_sites.h" 10 #include "components/ntp_tiles/most_visited_sites.h"
(...skipping 16 matching lines...) Expand all
27 : public web::WebUIIOSMessageHandler, 27 : public web::WebUIIOSMessageHandler,
28 public ntp_tiles::NTPTilesInternalsMessageHandlerClient { 28 public ntp_tiles::NTPTilesInternalsMessageHandlerClient {
29 public: 29 public:
30 IOSNTPTilesInternalsMessageHandlerBridge() {} 30 IOSNTPTilesInternalsMessageHandlerBridge() {}
31 31
32 private: 32 private:
33 // web::WebUIIOSMessageHandler: 33 // web::WebUIIOSMessageHandler:
34 void RegisterMessages() override; 34 void RegisterMessages() override;
35 35
36 // ntp_tiles::NTPTilesInternalsMessageHandlerClient 36 // ntp_tiles::NTPTilesInternalsMessageHandlerClient
37 bool SupportsNTPTiles() override;
37 bool DoesSourceExist(ntp_tiles::NTPTileSource source) override; 38 bool DoesSourceExist(ntp_tiles::NTPTileSource source) override;
38 std::unique_ptr<ntp_tiles::MostVisitedSites> MakeMostVisitedSites() override; 39 std::unique_ptr<ntp_tiles::MostVisitedSites> MakeMostVisitedSites() override;
39 std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() override; 40 std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() override;
40 PrefService* GetPrefs() override; 41 PrefService* GetPrefs() override;
41 void RegisterMessageCallback( 42 void RegisterMessageCallback(
42 const std::string& message, 43 const std::string& message,
43 const base::Callback<void(const base::ListValue*)>& callback) override; 44 const base::Callback<void(const base::ListValue*)>& callback) override;
44 void CallJavascriptFunctionVector( 45 void CallJavascriptFunctionVector(
45 const std::string& name, 46 const std::string& name,
46 const std::vector<const base::Value*>& values) override; 47 const std::vector<const base::Value*>& values) override;
47 48
48 ntp_tiles::NTPTilesInternalsMessageHandler handler_; 49 ntp_tiles::NTPTilesInternalsMessageHandler handler_;
49 50
50 DISALLOW_COPY_AND_ASSIGN(IOSNTPTilesInternalsMessageHandlerBridge); 51 DISALLOW_COPY_AND_ASSIGN(IOSNTPTilesInternalsMessageHandlerBridge);
51 }; 52 };
52 53
53 void IOSNTPTilesInternalsMessageHandlerBridge::RegisterMessages() { 54 void IOSNTPTilesInternalsMessageHandlerBridge::RegisterMessages() {
54 handler_.RegisterMessages(this); 55 handler_.RegisterMessages(this);
55 } 56 }
56 57
58 bool IOSNTPTilesInternalsMessageHandlerBridge::SupportsNTPTiles() {
59 auto* state = ios::ChromeBrowserState::FromWebUIIOS(web_ui());
60 return !state->HasOffTheRecordChromeBrowserState();
61 }
62
57 bool IOSNTPTilesInternalsMessageHandlerBridge::DoesSourceExist( 63 bool IOSNTPTilesInternalsMessageHandlerBridge::DoesSourceExist(
58 ntp_tiles::NTPTileSource source) { 64 ntp_tiles::NTPTileSource source) {
59 switch (source) { 65 switch (source) {
60 case ntp_tiles::NTPTileSource::TOP_SITES: 66 case ntp_tiles::NTPTileSource::TOP_SITES:
61 case ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE: 67 case ntp_tiles::NTPTileSource::SUGGESTIONS_SERVICE:
62 case ntp_tiles::NTPTileSource::POPULAR: 68 case ntp_tiles::NTPTileSource::POPULAR:
63 return true; 69 return true;
64 case ntp_tiles::NTPTileSource::WHITELIST: 70 case ntp_tiles::NTPTileSource::WHITELIST:
65 return false; 71 return false;
66 } 72 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 117
112 NTPTilesInternalsUI::NTPTilesInternalsUI(web::WebUIIOS* web_ui) 118 NTPTilesInternalsUI::NTPTilesInternalsUI(web::WebUIIOS* web_ui)
113 : web::WebUIIOSController(web_ui) { 119 : web::WebUIIOSController(web_ui) {
114 web::WebUIIOSDataSource::Add(ios::ChromeBrowserState::FromWebUIIOS(web_ui), 120 web::WebUIIOSDataSource::Add(ios::ChromeBrowserState::FromWebUIIOS(web_ui),
115 CreateNTPTilesInternalsHTMLSource()); 121 CreateNTPTilesInternalsHTMLSource());
116 web_ui->AddMessageHandler( 122 web_ui->AddMessageHandler(
117 base::MakeUnique<IOSNTPTilesInternalsMessageHandlerBridge>()); 123 base::MakeUnique<IOSNTPTilesInternalsMessageHandlerBridge>());
118 } 124 }
119 125
120 NTPTilesInternalsUI::~NTPTilesInternalsUI() {} 126 NTPTilesInternalsUI::~NTPTilesInternalsUI() {}
OLDNEW
« no previous file with comments | « components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698