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

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: rebase Created 6 years, 6 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 | « content/browser/service_worker/service_worker_internals_ui.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 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 source->AddResourcePath("serviceworker_internals.css", 372 source->AddResourcePath("serviceworker_internals.css",
373 IDR_SERVICE_WORKER_INTERNALS_CSS); 373 IDR_SERVICE_WORKER_INTERNALS_CSS);
374 source->SetDefaultResource(IDR_SERVICE_WORKER_INTERNALS_HTML); 374 source->SetDefaultResource(IDR_SERVICE_WORKER_INTERNALS_HTML);
375 source->DisableDenyXFrameOptions(); 375 source->DisableDenyXFrameOptions();
376 376
377 BrowserContext* browser_context = 377 BrowserContext* browser_context =
378 web_ui->GetWebContents()->GetBrowserContext(); 378 web_ui->GetWebContents()->GetBrowserContext();
379 WebUIDataSource::Add(browser_context, source); 379 WebUIDataSource::Add(browser_context, source);
380 380
381 web_ui->RegisterMessageCallback( 381 web_ui->RegisterMessageCallback(
382 "GetOptions",
383 base::Bind(&ServiceWorkerInternalsUI::GetOptions,
384 base::Unretained(this)));
385 web_ui->RegisterMessageCallback(
386 "SetOption",
387 base::Bind(&ServiceWorkerInternalsUI::SetOption, base::Unretained(this)));
388 web_ui->RegisterMessageCallback(
382 "getAllRegistrations", 389 "getAllRegistrations",
383 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations, 390 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations,
384 base::Unretained(this))); 391 base::Unretained(this)));
385 web_ui->RegisterMessageCallback( 392 web_ui->RegisterMessageCallback(
386 "stop", 393 "stop",
387 base::Bind(&ServiceWorkerInternalsUI::CallServiceWorkerVersionMethod, 394 base::Bind(&ServiceWorkerInternalsUI::CallServiceWorkerVersionMethod,
388 base::Unretained(this), 395 base::Unretained(this),
389 &ServiceWorkerVersion::StopWorker)); 396 &ServiceWorkerVersion::StopWorker));
390 web_ui->RegisterMessageCallback( 397 web_ui->RegisterMessageCallback(
391 "sync", 398 "sync",
(...skipping 18 matching lines...) Expand all
410 BrowserContext* browser_context = 417 BrowserContext* browser_context =
411 web_ui()->GetWebContents()->GetBrowserContext(); 418 web_ui()->GetWebContents()->GetBrowserContext();
412 // Safe to use base::Unretained(this) because 419 // Safe to use base::Unretained(this) because
413 // ForEachStoragePartition is synchronous. 420 // ForEachStoragePartition is synchronous.
414 BrowserContext::StoragePartitionCallback remove_observer_cb = 421 BrowserContext::StoragePartitionCallback remove_observer_cb =
415 base::Bind(&ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition, 422 base::Bind(&ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition,
416 base::Unretained(this)); 423 base::Unretained(this));
417 BrowserContext::ForEachStoragePartition(browser_context, remove_observer_cb); 424 BrowserContext::ForEachStoragePartition(browser_context, remove_observer_cb);
418 } 425 }
419 426
427 void ServiceWorkerInternalsUI::GetOptions(const ListValue* args) {
428 DictionaryValue options;
429 options.SetBoolean("debug_on_start",
430 EmbeddedWorkerDevToolsManager::GetInstance()
431 ->debug_service_worker_on_start());
432 web_ui()->CallJavascriptFunction("serviceworker.onOptions", options);
433 }
434
435 void ServiceWorkerInternalsUI::SetOption(const ListValue* args) {
436 std::string option_name;
437 bool option_boolean;
438 if (!args->GetString(0, &option_name) || option_name != "debug_on_start" ||
439 !args->GetBoolean(1, &option_boolean)) {
440 return;
441 }
442 EmbeddedWorkerDevToolsManager::GetInstance()
443 ->set_debug_service_worker_on_start(option_boolean);
444 }
445
420 void ServiceWorkerInternalsUI::GetAllRegistrations(const ListValue* args) { 446 void ServiceWorkerInternalsUI::GetAllRegistrations(const ListValue* args) {
421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 447 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
422 BrowserContext* browser_context = 448 BrowserContext* browser_context =
423 web_ui()->GetWebContents()->GetBrowserContext(); 449 web_ui()->GetWebContents()->GetBrowserContext();
424 // Safe to use base::Unretained(this) because 450 // Safe to use base::Unretained(this) because
425 // ForEachStoragePartition is synchronous. 451 // ForEachStoragePartition is synchronous.
426 BrowserContext::StoragePartitionCallback add_context_cb = 452 BrowserContext::StoragePartitionCallback add_context_cb =
427 base::Bind(&ServiceWorkerInternalsUI::AddContextFromStoragePartition, 453 base::Bind(&ServiceWorkerInternalsUI::AddContextFromStoragePartition,
428 base::Unretained(this)); 454 base::Unretained(this));
429 BrowserContext::ForEachStoragePartition(browser_context, add_context_cb); 455 BrowserContext::ForEachStoragePartition(browser_context, add_context_cb);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 return; 614 return;
589 } 615 }
590 616
591 base::Callback<void(ServiceWorkerStatusCode)> callback = 617 base::Callback<void(ServiceWorkerStatusCode)> callback =
592 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); 618 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id);
593 FindRegistrationForPattern( 619 FindRegistrationForPattern(
594 context, GURL(scope_string), base::Bind(StartActiveWorker, callback)); 620 context, GURL(scope_string), base::Bind(StartActiveWorker, callback));
595 } 621 }
596 622
597 } // namespace content 623 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_internals_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698