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

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, 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 source->DisableDenyXFrameOptions(); 201 source->DisableDenyXFrameOptions();
202 202
203 BrowserContext* browser_context = 203 BrowserContext* browser_context =
204 web_ui->GetWebContents()->GetBrowserContext(); 204 web_ui->GetWebContents()->GetBrowserContext();
205 WebUIDataSource::Add(browser_context, source); 205 WebUIDataSource::Add(browser_context, source);
206 206
207 web_ui->RegisterMessageCallback( 207 web_ui->RegisterMessageCallback(
208 "GetOptions",
209 base::Bind(&ServiceWorkerInternalsUI::GetOptions,
210 base::Unretained(this)));
211 web_ui->RegisterMessageCallback(
212 "SetOption",
213 base::Bind(&ServiceWorkerInternalsUI::SetOption, base::Unretained(this)));
214 web_ui->RegisterMessageCallback(
208 "getAllRegistrations", 215 "getAllRegistrations",
209 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations, 216 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations,
210 base::Unretained(this))); 217 base::Unretained(this)));
211 web_ui->RegisterMessageCallback( 218 web_ui->RegisterMessageCallback(
212 "start", 219 "start",
213 base::Bind(&ServiceWorkerInternalsUI::StartWorker, 220 base::Bind(&ServiceWorkerInternalsUI::StartWorker,
214 base::Unretained(this))); 221 base::Unretained(this)));
215 web_ui->RegisterMessageCallback( 222 web_ui->RegisterMessageCallback(
216 "stop", 223 "stop",
217 base::Bind(&ServiceWorkerInternalsUI::StopWorker, 224 base::Bind(&ServiceWorkerInternalsUI::StopWorker,
(...skipping 16 matching lines...) Expand all
234 BrowserContext* browser_context = 241 BrowserContext* browser_context =
235 web_ui()->GetWebContents()->GetBrowserContext(); 242 web_ui()->GetWebContents()->GetBrowserContext();
236 // Safe to use base::Unretained(this) because 243 // Safe to use base::Unretained(this) because
237 // ForEachStoragePartition is synchronous. 244 // ForEachStoragePartition is synchronous.
238 BrowserContext::StoragePartitionCallback remove_observer_cb = 245 BrowserContext::StoragePartitionCallback remove_observer_cb =
239 base::Bind(&ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition, 246 base::Bind(&ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition,
240 base::Unretained(this)); 247 base::Unretained(this));
241 BrowserContext::ForEachStoragePartition(browser_context, remove_observer_cb); 248 BrowserContext::ForEachStoragePartition(browser_context, remove_observer_cb);
242 } 249 }
243 250
251 void ServiceWorkerInternalsUI::GetOptions(const ListValue* args) {
252 DictionaryValue options;
253 options.SetBoolean("debug_on_start",
254 EmbeddedWorkerDevToolsManager::GetInstance()
255 ->debug_service_worker_on_start());
256 web_ui()->CallJavascriptFunction("serviceworker.onOptions", options);
257 }
258
259 void ServiceWorkerInternalsUI::SetOption(const ListValue* args) {
260 std::string option_name;
261 bool option_boolean;
262 if (!args->GetString(0, &option_name)||
263 option_name != "debug_on_start" ||
264 !args->GetBoolean(1, &option_boolean)) {
265 return;
266 }
267 EmbeddedWorkerDevToolsManager::GetInstance()
268 ->set_debug_service_worker_on_start(option_boolean);
269 }
270
244 void ServiceWorkerInternalsUI::GetAllRegistrations(const ListValue* args) { 271 void ServiceWorkerInternalsUI::GetAllRegistrations(const ListValue* args) {
245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
246 273
247 BrowserContext* browser_context = 274 BrowserContext* browser_context =
248 web_ui()->GetWebContents()->GetBrowserContext(); 275 web_ui()->GetWebContents()->GetBrowserContext();
249 276
250 // Safe to use base::Unretained(this) because 277 // Safe to use base::Unretained(this) because
251 // ForEachStoragePartition is synchronous. 278 // ForEachStoragePartition is synchronous.
252 BrowserContext::StoragePartitionCallback add_context_cb = 279 BrowserContext::StoragePartitionCallback add_context_cb =
253 base::Bind(&ServiceWorkerInternalsUI::AddContextFromStoragePartition, 280 base::Bind(&ServiceWorkerInternalsUI::AddContextFromStoragePartition,
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 DevToolsManagerImpl::GetInstance()->Inspect( 717 DevToolsManagerImpl::GetInstance()->Inspect(
691 internals_->web_ui()->GetWebContents()->GetBrowserContext(), 718 internals_->web_ui()->GetWebContents()->GetBrowserContext(),
692 agent_host.get()); 719 agent_host.get());
693 OperationComplete(SERVICE_WORKER_OK); 720 OperationComplete(SERVICE_WORKER_OK);
694 return; 721 return;
695 } 722 }
696 OperationComplete(SERVICE_WORKER_ERROR_NOT_FOUND); 723 OperationComplete(SERVICE_WORKER_ERROR_NOT_FOUND);
697 } 724 }
698 725
699 } // namespace content 726 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698