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

Side by Side Diff: content/browser/service_worker/service_worker_internals_ui.cc

Issue 299693002: Add option to open the DevTools window for ServiceWorker on start in serviceworker-internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/service_worker/service_worker_internals_ui.h" 5 #include "content/browser/service_worker/service_worker_internals_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 IDR_SERVICE_WORKER_INTERNALS_JS); 197 IDR_SERVICE_WORKER_INTERNALS_JS);
198 source->AddResourcePath("serviceworker_internals.css", 198 source->AddResourcePath("serviceworker_internals.css",
199 IDR_SERVICE_WORKER_INTERNALS_CSS); 199 IDR_SERVICE_WORKER_INTERNALS_CSS);
200 source->SetDefaultResource(IDR_SERVICE_WORKER_INTERNALS_HTML); 200 source->SetDefaultResource(IDR_SERVICE_WORKER_INTERNALS_HTML);
201 201
202 BrowserContext* browser_context = 202 BrowserContext* browser_context =
203 web_ui->GetWebContents()->GetBrowserContext(); 203 web_ui->GetWebContents()->GetBrowserContext();
204 WebUIDataSource::Add(browser_context, source); 204 WebUIDataSource::Add(browser_context, source);
205 205
206 web_ui->RegisterMessageCallback( 206 web_ui->RegisterMessageCallback(
207 "GetOptions",
208 base::Bind(&ServiceWorkerInternalsUI::GetOptions,
209 base::Unretained(this)));
210 web_ui->RegisterMessageCallback(
211 "SetOption",
212 base::Bind(&ServiceWorkerInternalsUI::SetOption, base::Unretained(this)));
213 web_ui->RegisterMessageCallback(
207 "getAllRegistrations", 214 "getAllRegistrations",
208 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations, 215 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations,
209 base::Unretained(this))); 216 base::Unretained(this)));
210 web_ui->RegisterMessageCallback( 217 web_ui->RegisterMessageCallback(
211 "start", 218 "start",
212 base::Bind(&ServiceWorkerInternalsUI::StartWorker, 219 base::Bind(&ServiceWorkerInternalsUI::StartWorker,
213 base::Unretained(this))); 220 base::Unretained(this)));
214 web_ui->RegisterMessageCallback( 221 web_ui->RegisterMessageCallback(
215 "stop", 222 "stop",
216 base::Bind(&ServiceWorkerInternalsUI::StopWorker, 223 base::Bind(&ServiceWorkerInternalsUI::StopWorker,
(...skipping 16 matching lines...) Expand all
233 BrowserContext* browser_context = 240 BrowserContext* browser_context =
234 web_ui()->GetWebContents()->GetBrowserContext(); 241 web_ui()->GetWebContents()->GetBrowserContext();
235 // Safe to use base::Unretained(this) because 242 // Safe to use base::Unretained(this) because
236 // ForEachStoragePartition is synchronous. 243 // ForEachStoragePartition is synchronous.
237 BrowserContext::StoragePartitionCallback remove_observer_cb = 244 BrowserContext::StoragePartitionCallback remove_observer_cb =
238 base::Bind(&ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition, 245 base::Bind(&ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition,
239 base::Unretained(this)); 246 base::Unretained(this));
240 BrowserContext::ForEachStoragePartition(browser_context, remove_observer_cb); 247 BrowserContext::ForEachStoragePartition(browser_context, remove_observer_cb);
241 } 248 }
242 249
250 void ServiceWorkerInternalsUI::GetOptions(const ListValue* args) {
251 DictionaryValue options;
252 options.SetBoolean("debug_on_start",
253 EmbeddedWorkerDevToolsManager::GetInstance()
254 ->debug_service_worker_on_start());
255 web_ui()->CallJavascriptFunction("serviceworker.onOptions", options);
256 }
257
258 void ServiceWorkerInternalsUI::SetOption(const ListValue* args) {
259 std::string option_name;
260 bool option_boolean;
261 if (!args->GetString(0, &option_name)||
262 option_name != "debug_on_start" ||
263 !args->GetBoolean(1, &option_boolean)) {
264 return;
265 }
266 EmbeddedWorkerDevToolsManager::GetInstance()
267 ->set_debug_service_worker_on_start(option_boolean);
268 }
269
243 void ServiceWorkerInternalsUI::GetAllRegistrations(const ListValue* args) { 270 void ServiceWorkerInternalsUI::GetAllRegistrations(const ListValue* args) {
244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
245 272
246 BrowserContext* browser_context = 273 BrowserContext* browser_context =
247 web_ui()->GetWebContents()->GetBrowserContext(); 274 web_ui()->GetWebContents()->GetBrowserContext();
248 275
249 // Safe to use base::Unretained(this) because 276 // Safe to use base::Unretained(this) because
250 // ForEachStoragePartition is synchronous. 277 // ForEachStoragePartition is synchronous.
251 BrowserContext::StoragePartitionCallback add_context_cb = 278 BrowserContext::StoragePartitionCallback add_context_cb =
252 base::Bind(&ServiceWorkerInternalsUI::AddContextFromStoragePartition, 279 base::Bind(&ServiceWorkerInternalsUI::AddContextFromStoragePartition,
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 DevToolsManagerImpl::GetInstance()->Inspect( 716 DevToolsManagerImpl::GetInstance()->Inspect(
690 internals_->web_ui()->GetWebContents()->GetBrowserContext(), 717 internals_->web_ui()->GetWebContents()->GetBrowserContext(),
691 agent_host.get()); 718 agent_host.get());
692 OperationComplete(SERVICE_WORKER_OK); 719 OperationComplete(SERVICE_WORKER_OK);
693 return; 720 return;
694 } 721 }
695 OperationComplete(SERVICE_WORKER_ERROR_NOT_FOUND); 722 OperationComplete(SERVICE_WORKER_ERROR_NOT_FOUND);
696 } 723 }
697 724
698 } // namespace content 725 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698