Commit 6a94f689 authored by mgiuca's avatar mgiuca Committed by Commit bot

app_list::StartPageService: Document and check nulls.

This adds null checks for the result of StartPageService::Get in a few
places where it was missing.

Review URL: https://codereview.chromium.org/970863003

Cr-Commit-Position: refs/heads/master@{#318985}
parent 59016318
...@@ -55,7 +55,7 @@ class StartPageService : public KeyedService, ...@@ -55,7 +55,7 @@ class StartPageService : public KeyedService,
public: public:
typedef std::vector<scoped_refptr<const extensions::Extension> > typedef std::vector<scoped_refptr<const extensions::Extension> >
ExtensionList; ExtensionList;
// Gets the instance for the given profile. // Gets the instance for the given profile. May return nullptr.
static StartPageService* Get(Profile* profile); static StartPageService* Get(Profile* profile);
void AddObserver(StartPageObserver* observer); void AddObserver(StartPageObserver* observer);
......
...@@ -16,7 +16,8 @@ class StartPageService; ...@@ -16,7 +16,8 @@ class StartPageService;
// Singleton factory to create StartPageService. // Singleton factory to create StartPageService.
class StartPageServiceFactory : public BrowserContextKeyedServiceFactory { class StartPageServiceFactory : public BrowserContextKeyedServiceFactory {
public: public:
// Gets or creates the instance of StartPageService for |profile|. // Gets or creates the instance of StartPageService for |profile|. May return
// nullptr.
static StartPageService* GetForProfile(Profile* profile); static StartPageService* GetForProfile(Profile* profile);
// Gets the singleton instance of this factory. // Gets the singleton instance of this factory.
......
...@@ -56,7 +56,10 @@ void AppListServiceAsh::ShowAndSwitchToState( ...@@ -56,7 +56,10 @@ void AppListServiceAsh::ShowAndSwitchToState(
void AppListServiceAsh::Init(Profile* initial_profile) { void AppListServiceAsh::Init(Profile* initial_profile) {
// Ensure the StartPageService is created here. This early initialization is // Ensure the StartPageService is created here. This early initialization is
// necessary to allow the WebContents to load before the app list is shown. // necessary to allow the WebContents to load before the app list is shown.
app_list::StartPageService::Get(initial_profile)->Init(); app_list::StartPageService* service =
app_list::StartPageService::Get(initial_profile);
if (service)
service->Init();
} }
base::FilePath AppListServiceAsh::GetProfilePath( base::FilePath AppListServiceAsh::GetProfilePath(
......
...@@ -127,7 +127,7 @@ void StartPageHandler::OnHotwordEnabledChanged() { ...@@ -127,7 +127,7 @@ void StartPageHandler::OnHotwordEnabledChanged() {
StartPageService* service = StartPageService::Get(profile); StartPageService* service = StartPageService::Get(profile);
web_ui()->CallJavascriptFunction( web_ui()->CallJavascriptFunction(
"appList.startPage.setHotwordEnabled", "appList.startPage.setHotwordEnabled",
base::FundamentalValue(service->HotwordEnabled())); base::FundamentalValue(service && service->HotwordEnabled()));
} }
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment