Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 144 |
| 145 return render_view_host->GetSiteInstance()->GetSiteURL().host(); | 145 return render_view_host->GetSiteInstance()->GetSiteURL().host(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void BroadcastItemStateChanged(content::BrowserContext* browser_context, | 148 void BroadcastItemStateChanged(content::BrowserContext* browser_context, |
| 149 developer::EventType event_type, | 149 developer::EventType event_type, |
| 150 const std::string& item_id) { | 150 const std::string& item_id) { |
| 151 developer::EventData event_data; | 151 developer::EventData event_data; |
| 152 event_data.event_type = event_type; | 152 event_data.event_type = event_type; |
| 153 event_data.item_id = item_id; | 153 event_data.item_id = item_id; |
| 154 event_data.extension_info = | |
| 155 ExtensionInfoGenerator(browser_context).CreateExtensionInfo(item_id); | |
| 154 | 156 |
| 155 scoped_ptr<base::ListValue> args(new base::ListValue()); | 157 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 156 args->Append(event_data.ToValue().release()); | 158 args->Append(event_data.ToValue().release()); |
| 157 scoped_ptr<Event> event(new Event( | 159 scoped_ptr<Event> event(new Event( |
| 158 developer_private::OnItemStateChanged::kEventName, args.Pass())); | 160 developer_private::OnItemStateChanged::kEventName, args.Pass())); |
| 159 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass()); | 161 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass()); |
| 160 } | 162 } |
| 161 | 163 |
| 162 std::string ReadFileToString(const base::FilePath& path) { | 164 std::string ReadFileToString(const base::FilePath& path) { |
| 163 std::string data; | 165 std::string data; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 DeveloperPrivateGetExtensionInfoFunction:: | 402 DeveloperPrivateGetExtensionInfoFunction:: |
| 401 ~DeveloperPrivateGetExtensionInfoFunction() { | 403 ~DeveloperPrivateGetExtensionInfoFunction() { |
| 402 } | 404 } |
| 403 | 405 |
| 404 ExtensionFunction::ResponseAction | 406 ExtensionFunction::ResponseAction |
| 405 DeveloperPrivateGetExtensionInfoFunction::Run() { | 407 DeveloperPrivateGetExtensionInfoFunction::Run() { |
| 406 scoped_ptr<developer::GetExtensionInfo::Params> params( | 408 scoped_ptr<developer::GetExtensionInfo::Params> params( |
| 407 developer::GetExtensionInfo::Params::Create(*args_)); | 409 developer::GetExtensionInfo::Params::Create(*args_)); |
| 408 EXTENSION_FUNCTION_VALIDATE(params); | 410 EXTENSION_FUNCTION_VALIDATE(params); |
| 409 | 411 |
| 410 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); | 412 scoped_ptr<developer::ExtensionInfo> info = |
| 411 developer::ExtensionState state = developer::EXTENSION_STATE_ENABLED; | 413 ExtensionInfoGenerator(browser_context()).CreateExtensionInfo(params->id); |
|
Dan Beam
2015/04/06 23:53:11
+\s\s
Devlin
2015/04/07 16:07:54
Done.
| |
| 412 const Extension* extension = | |
| 413 registry->enabled_extensions().GetByID(params->id); | |
| 414 if (!extension && | |
| 415 (extension = registry->disabled_extensions().GetByID(params->id)) != | |
| 416 nullptr) { | |
| 417 state = developer::EXTENSION_STATE_DISABLED; | |
| 418 } else if (!extension && | |
| 419 (extension = | |
| 420 registry->terminated_extensions().GetByID(params->id)) != | |
| 421 nullptr) { | |
| 422 state = developer::EXTENSION_STATE_TERMINATED; | |
| 423 } | |
| 424 | 414 |
| 425 if (!extension) | 415 if (!info) |
|
Dan Beam
2015/04/06 23:53:12
how is info ever empty?
https://code.google.com/p/
Devlin
2015/04/07 16:07:54
Two methods. One takes a const Extension& (resulta
Dan Beam
2015/04/07 17:21:13
yeah, sorry, found the answer but didn't delete co
| |
| 426 return RespondNow(Error(kNoSuchExtensionError)); | 416 return RespondNow(Error(kNoSuchExtensionError)); |
| 427 | 417 |
| 428 return RespondNow(OneArgument(ExtensionInfoGenerator(browser_context()). | 418 return RespondNow(OneArgument(info->ToValue().release())); |
| 429 CreateExtensionInfo(*extension, state)->ToValue().release())); | |
| 430 } | 419 } |
| 431 | 420 |
| 432 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} | 421 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} |
| 433 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} | 422 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} |
| 434 | 423 |
| 435 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { | 424 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { |
| 436 scoped_ptr<developer::GetItemsInfo::Params> params( | 425 scoped_ptr<developer::GetItemsInfo::Params> params( |
| 437 developer::GetItemsInfo::Params::Create(*args_)); | 426 developer::GetItemsInfo::Params::Create(*args_)); |
| 438 EXTENSION_FUNCTION_VALIDATE(params); | 427 EXTENSION_FUNCTION_VALIDATE(params); |
| 439 | 428 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1225 } | 1214 } |
| 1226 error_console->RemoveErrors(ErrorMap::Filter( | 1215 error_console->RemoveErrors(ErrorMap::Filter( |
| 1227 properties.extension_id, type, error_ids, false)); | 1216 properties.extension_id, type, error_ids, false)); |
| 1228 | 1217 |
| 1229 return RespondNow(NoArguments()); | 1218 return RespondNow(NoArguments()); |
| 1230 } | 1219 } |
| 1231 | 1220 |
| 1232 } // namespace api | 1221 } // namespace api |
| 1233 | 1222 |
| 1234 } // namespace extensions | 1223 } // namespace extensions |
| OLD | NEW |