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

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 1016413004: [Extensions] Update Error Console UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dan's Created 5 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/developer_private/developer_private_api. h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 return render_view_host->GetSiteInstance()->GetSiteURL().host(); 147 return render_view_host->GetSiteInstance()->GetSiteURL().host();
148 } 148 }
149 149
150 void BroadcastItemStateChanged(content::BrowserContext* browser_context, 150 void BroadcastItemStateChanged(content::BrowserContext* browser_context,
151 developer::EventType event_type, 151 developer::EventType event_type,
152 const std::string& item_id) { 152 const std::string& item_id) {
153 developer::EventData event_data; 153 developer::EventData event_data;
154 event_data.event_type = event_type; 154 event_data.event_type = event_type;
155 event_data.item_id = item_id; 155 event_data.item_id = item_id;
156 event_data.info =
157 ExtensionInfoGenerator(browser_context).CreateExtensionInfo(item_id);
156 158
157 scoped_ptr<base::ListValue> args(new base::ListValue()); 159 scoped_ptr<base::ListValue> args(new base::ListValue());
158 args->Append(event_data.ToValue().release()); 160 args->Append(event_data.ToValue().release());
159 scoped_ptr<Event> event(new Event( 161 scoped_ptr<Event> event(new Event(
160 developer_private::OnItemStateChanged::kEventName, args.Pass())); 162 developer_private::OnItemStateChanged::kEventName, args.Pass()));
161 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass()); 163 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass());
162 } 164 }
163 165
164 std::string ReadFileToString(const base::FilePath& path) { 166 std::string ReadFileToString(const base::FilePath& path) {
165 std::string data; 167 std::string data;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 extensions::UninstallReason reason) { 313 extensions::UninstallReason reason) {
312 DCHECK(profile_->IsSameProfile(Profile::FromBrowserContext(browser_context))); 314 DCHECK(profile_->IsSameProfile(Profile::FromBrowserContext(browser_context)));
313 BroadcastItemStateChanged( 315 BroadcastItemStateChanged(
314 browser_context, developer::EVENT_TYPE_UNINSTALLED, extension->id()); 316 browser_context, developer::EVENT_TYPE_UNINSTALLED, extension->id());
315 } 317 }
316 318
317 void DeveloperPrivateEventRouter::OnErrorAdded(const ExtensionError* error) { 319 void DeveloperPrivateEventRouter::OnErrorAdded(const ExtensionError* error) {
318 // We don't want to handle errors thrown by extensions subscribed to these 320 // We don't want to handle errors thrown by extensions subscribed to these
319 // events (currently only the Apps Developer Tool), because doing so risks 321 // events (currently only the Apps Developer Tool), because doing so risks
320 // entering a loop. 322 // entering a loop.
321 if (extension_ids_.find(error->extension_id()) != extension_ids_.end()) 323 if (extension_ids_.count(error->extension_id()))
322 return; 324 return;
323 325
324 BroadcastItemStateChanged( 326 BroadcastItemStateChanged(
325 profile_, developer::EVENT_TYPE_ERROR_ADDED, error->extension_id()); 327 profile_, developer::EVENT_TYPE_ERROR_ADDED, error->extension_id());
326 } 328 }
327 329
330 void DeveloperPrivateEventRouter::OnErrorsRemoved(
331 const std::set<std::string>& extension_ids) {
332 for (const std::string& id : extension_ids) {
333 if (!extension_ids_.count(id)) {
Dan Beam 2015/04/22 21:02:37 extension_ids vs extension_ids_ is pretty dubious
Devlin 2015/04/22 23:17:31 Fair, done.
334 BroadcastItemStateChanged(
335 profile_, developer::EVENT_TYPE_ERRORS_REMOVED, id);
336 }
337 }
338 }
339
328 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) { 340 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) {
329 last_unpacked_directory_ = path; 341 last_unpacked_directory_ = path;
330 } 342 }
331 343
332 void DeveloperPrivateAPI::RegisterNotifications() { 344 void DeveloperPrivateAPI::RegisterNotifications() {
333 EventRouter::Get(profile_)->RegisterObserver( 345 EventRouter::Get(profile_)->RegisterObserver(
334 this, developer_private::OnItemStateChanged::kEventName); 346 this, developer_private::OnItemStateChanged::kEventName);
335 } 347 }
336 348
337 DeveloperPrivateAPI::~DeveloperPrivateAPI() {} 349 DeveloperPrivateAPI::~DeveloperPrivateAPI() {}
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 DeveloperPrivateGetExtensionInfoFunction:: 421 DeveloperPrivateGetExtensionInfoFunction::
410 ~DeveloperPrivateGetExtensionInfoFunction() { 422 ~DeveloperPrivateGetExtensionInfoFunction() {
411 } 423 }
412 424
413 ExtensionFunction::ResponseAction 425 ExtensionFunction::ResponseAction
414 DeveloperPrivateGetExtensionInfoFunction::Run() { 426 DeveloperPrivateGetExtensionInfoFunction::Run() {
415 scoped_ptr<developer::GetExtensionInfo::Params> params( 427 scoped_ptr<developer::GetExtensionInfo::Params> params(
416 developer::GetExtensionInfo::Params::Create(*args_)); 428 developer::GetExtensionInfo::Params::Create(*args_));
417 EXTENSION_FUNCTION_VALIDATE(params); 429 EXTENSION_FUNCTION_VALIDATE(params);
418 430
419 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); 431 scoped_ptr<developer::ExtensionInfo> info =
420 developer::ExtensionState state = developer::EXTENSION_STATE_ENABLED; 432 ExtensionInfoGenerator(browser_context()).CreateExtensionInfo(params->id);
421 const Extension* extension =
422 registry->enabled_extensions().GetByID(params->id);
423 if (!extension &&
424 (extension = registry->disabled_extensions().GetByID(params->id)) !=
425 nullptr) {
426 state = developer::EXTENSION_STATE_DISABLED;
427 } else if (!extension &&
428 (extension =
429 registry->terminated_extensions().GetByID(params->id)) !=
430 nullptr) {
431 state = developer::EXTENSION_STATE_TERMINATED;
432 }
433 433
434 if (!extension) 434 if (!info)
435 return RespondNow(Error(kNoSuchExtensionError)); 435 return RespondNow(Error(kNoSuchExtensionError));
436 436
437 return RespondNow(OneArgument(ExtensionInfoGenerator(browser_context()). 437 return RespondNow(OneArgument(info->ToValue().release()));
438 CreateExtensionInfo(*extension, state)->ToValue().release()));
439 } 438 }
440 439
441 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} 440 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {}
442 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} 441 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {}
443 442
444 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { 443 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() {
445 scoped_ptr<developer::GetItemsInfo::Params> params( 444 scoped_ptr<developer::GetItemsInfo::Params> params(
446 developer::GetItemsInfo::Params::Create(*args_)); 445 developer::GetItemsInfo::Params::Create(*args_));
447 EXTENSION_FUNCTION_VALIDATE(params); 446 EXTENSION_FUNCTION_VALIDATE(params);
448 447
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 } 1233 }
1235 error_console->RemoveErrors(ErrorMap::Filter( 1234 error_console->RemoveErrors(ErrorMap::Filter(
1236 properties.extension_id, type, error_ids, false)); 1235 properties.extension_id, type, error_ids, false));
1237 1236
1238 return RespondNow(NoArguments()); 1237 return RespondNow(NoArguments());
1239 } 1238 }
1240 1239
1241 } // namespace api 1240 } // namespace api
1242 1241
1243 } // namespace extensions 1242 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698