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

Side by Side Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 657173002: Guard against the app launcher having a custom start page URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list/start_page_service.h" 5 #include "chrome/browser/ui/app_list/start_page_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 observers_.AddObserver(observer); 130 observers_.AddObserver(observer);
131 } 131 }
132 132
133 void StartPageService::RemoveObserver(StartPageObserver* observer) { 133 void StartPageService::RemoveObserver(StartPageObserver* observer) {
134 observers_.RemoveObserver(observer); 134 observers_.RemoveObserver(observer);
135 } 135 }
136 136
137 void StartPageService::AppListShown() { 137 void StartPageService::AppListShown() {
138 if (!contents_) { 138 if (!contents_) {
139 LoadContents(); 139 LoadContents();
140 } else { 140 } else if (contents_->GetWebUI()) {
141 // If experimental hotwording is enabled, don't enable hotwording in the 141 // If experimental hotwording is enabled, don't enable hotwording in the
142 // start page, since the hotword extension is taking care of this. 142 // start page, since the hotword extension is taking care of this.
143 bool hotword_enabled = HotwordEnabled() && 143 bool hotword_enabled = HotwordEnabled() &&
144 !HotwordService::IsExperimentalHotwordingEnabled(); 144 !HotwordService::IsExperimentalHotwordingEnabled();
145 contents_->GetWebUI()->CallJavascriptFunction( 145 contents_->GetWebUI()->CallJavascriptFunction(
146 "appList.startPage.onAppListShown", 146 "appList.startPage.onAppListShown",
147 base::FundamentalValue(hotword_enabled)); 147 base::FundamentalValue(hotword_enabled));
148 } 148 }
149 } 149 }
150 150
151 void StartPageService::AppListHidden() { 151 void StartPageService::AppListHidden() {
152 contents_->GetWebUI()->CallJavascriptFunction( 152 if (contents_->GetWebUI()) {
153 "appList.startPage.onAppListHidden"); 153 contents_->GetWebUI()->CallJavascriptFunction(
154 "appList.startPage.onAppListHidden");
155 }
154 if (!app_list::switches::IsExperimentalAppListEnabled()) 156 if (!app_list::switches::IsExperimentalAppListEnabled())
155 UnloadContents(); 157 UnloadContents();
156 } 158 }
157 159
158 void StartPageService::ToggleSpeechRecognition() { 160 void StartPageService::ToggleSpeechRecognition() {
159 DCHECK(contents_); 161 DCHECK(contents_);
160 speech_button_toggled_manually_ = true; 162 speech_button_toggled_manually_ = true;
163 if (!contents_->GetWebUI())
164 return;
165
161 if (webui_finished_loading_) { 166 if (webui_finished_loading_) {
162 contents_->GetWebUI()->CallJavascriptFunction( 167 contents_->GetWebUI()->CallJavascriptFunction(
163 "appList.startPage.toggleSpeechRecognition"); 168 "appList.startPage.toggleSpeechRecognition");
164 } else { 169 } else {
165 pending_webui_callbacks_.push_back( 170 pending_webui_callbacks_.push_back(
166 base::Bind(&StartPageService::ToggleSpeechRecognition, 171 base::Bind(&StartPageService::ToggleSpeechRecognition,
167 base::Unretained(this))); 172 base::Unretained(this)));
168 } 173 }
169 } 174 }
170 175
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 273 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
269 std::string()); 274 std::string());
270 } 275 }
271 276
272 void StartPageService::UnloadContents() { 277 void StartPageService::UnloadContents() {
273 contents_.reset(); 278 contents_.reset();
274 webui_finished_loading_ = false; 279 webui_finished_loading_ = false;
275 } 280 }
276 281
277 } // namespace app_list 282 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698