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

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

Issue 1549233002: Convert Pass()→std::move() in //chrome/browser/extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 12 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 <stddef.h> 7 #include <stddef.h>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
11 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
12 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/devtools/devtools_window.h" 17 #include "chrome/browser/devtools/devtools_window.h"
17 #include "chrome/browser/extensions/api/developer_private/developer_private_mang le.h" 18 #include "chrome/browser/extensions/api/developer_private/developer_private_mang le.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 info->is_incognito_available = 166 info->is_incognito_available =
166 IncognitoModePrefs::GetAvailability(prefs) != 167 IncognitoModePrefs::GetAvailability(prefs) !=
167 IncognitoModePrefs::DISABLED; 168 IncognitoModePrefs::DISABLED;
168 info->in_developer_mode = 169 info->in_developer_mode =
169 !info->is_supervised && 170 !info->is_supervised &&
170 prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode); 171 prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode);
171 info->app_info_dialog_enabled = CanShowAppInfoDialog(); 172 info->app_info_dialog_enabled = CanShowAppInfoDialog();
172 info->can_load_unpacked = 173 info->can_load_unpacked =
173 !ExtensionManagementFactory::GetForBrowserContext(profile) 174 !ExtensionManagementFactory::GetForBrowserContext(profile)
174 ->BlacklistedByDefault(); 175 ->BlacklistedByDefault();
175 return info.Pass(); 176 return info;
176 } 177 }
177 178
178 } // namespace 179 } // namespace
179 180
180 namespace ChoosePath = api::developer_private::ChoosePath; 181 namespace ChoosePath = api::developer_private::ChoosePath;
181 namespace GetItemsInfo = api::developer_private::GetItemsInfo; 182 namespace GetItemsInfo = api::developer_private::GetItemsInfo;
182 namespace PackDirectory = api::developer_private::PackDirectory; 183 namespace PackDirectory = api::developer_private::PackDirectory;
183 namespace Reload = api::developer_private::Reload; 184 namespace Reload = api::developer_private::Reload;
184 185
185 static base::LazyInstance<BrowserContextKeyedAPIFactory<DeveloperPrivateAPI> > 186 static base::LazyInstance<BrowserContextKeyedAPIFactory<DeveloperPrivateAPI> >
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 void DeveloperPrivateEventRouter::OnExtensionDisableReasonsChanged( 345 void DeveloperPrivateEventRouter::OnExtensionDisableReasonsChanged(
345 const std::string& extension_id, int disable_reasons) { 346 const std::string& extension_id, int disable_reasons) {
346 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); 347 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id);
347 } 348 }
348 349
349 void DeveloperPrivateEventRouter::OnExtensionManagementSettingsChanged() { 350 void DeveloperPrivateEventRouter::OnExtensionManagementSettingsChanged() {
350 scoped_ptr<base::ListValue> args(new base::ListValue()); 351 scoped_ptr<base::ListValue> args(new base::ListValue());
351 args->Append(CreateProfileInfo(profile_)->ToValue()); 352 args->Append(CreateProfileInfo(profile_)->ToValue());
352 scoped_ptr<Event> event( 353 scoped_ptr<Event> event(
353 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED, 354 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED,
354 developer::OnProfileStateChanged::kEventName, args.Pass())); 355 developer::OnProfileStateChanged::kEventName, std::move(args)));
355 event_router_->BroadcastEvent(event.Pass()); 356 event_router_->BroadcastEvent(std::move(event));
356 } 357 }
357 358
358 void DeveloperPrivateEventRouter::ExtensionWarningsChanged( 359 void DeveloperPrivateEventRouter::ExtensionWarningsChanged(
359 const ExtensionIdSet& affected_extensions) { 360 const ExtensionIdSet& affected_extensions) {
360 for (const ExtensionId& id : affected_extensions) 361 for (const ExtensionId& id : affected_extensions)
361 BroadcastItemStateChanged(developer::EVENT_TYPE_WARNINGS_CHANGED, id); 362 BroadcastItemStateChanged(developer::EVENT_TYPE_WARNINGS_CHANGED, id);
362 } 363 }
363 364
364 void DeveloperPrivateEventRouter::OnProfilePrefChanged() { 365 void DeveloperPrivateEventRouter::OnProfilePrefChanged() {
365 scoped_ptr<base::ListValue> args(new base::ListValue()); 366 scoped_ptr<base::ListValue> args(new base::ListValue());
366 args->Append(CreateProfileInfo(profile_)->ToValue()); 367 args->Append(CreateProfileInfo(profile_)->ToValue());
367 scoped_ptr<Event> event( 368 scoped_ptr<Event> event(
368 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED, 369 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED,
369 developer::OnProfileStateChanged::kEventName, args.Pass())); 370 developer::OnProfileStateChanged::kEventName, std::move(args)));
370 event_router_->BroadcastEvent(event.Pass()); 371 event_router_->BroadcastEvent(std::move(event));
371 } 372 }
372 373
373 void DeveloperPrivateEventRouter::BroadcastItemStateChanged( 374 void DeveloperPrivateEventRouter::BroadcastItemStateChanged(
374 developer::EventType event_type, 375 developer::EventType event_type,
375 const std::string& extension_id) { 376 const std::string& extension_id) {
376 scoped_ptr<ExtensionInfoGenerator> info_generator( 377 scoped_ptr<ExtensionInfoGenerator> info_generator(
377 new ExtensionInfoGenerator(profile_)); 378 new ExtensionInfoGenerator(profile_));
378 ExtensionInfoGenerator* info_generator_weak = info_generator.get(); 379 ExtensionInfoGenerator* info_generator_weak = info_generator.get();
379 info_generator_weak->CreateExtensionInfo( 380 info_generator_weak->CreateExtensionInfo(
380 extension_id, 381 extension_id,
381 base::Bind(&DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper, 382 base::Bind(&DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper,
382 weak_factory_.GetWeakPtr(), 383 weak_factory_.GetWeakPtr(), event_type, extension_id,
383 event_type, 384 base::Passed(std::move(info_generator))));
384 extension_id,
385 base::Passed(info_generator.Pass())));
386 } 385 }
387 386
388 void DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper( 387 void DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper(
389 developer::EventType event_type, 388 developer::EventType event_type,
390 const std::string& extension_id, 389 const std::string& extension_id,
391 scoped_ptr<ExtensionInfoGenerator> info_generator, 390 scoped_ptr<ExtensionInfoGenerator> info_generator,
392 const ExtensionInfoGenerator::ExtensionInfoList& infos) { 391 const ExtensionInfoGenerator::ExtensionInfoList& infos) {
393 DCHECK_LE(infos.size(), 1u); 392 DCHECK_LE(infos.size(), 1u);
394 393
395 developer::EventData event_data; 394 developer::EventData event_data;
396 event_data.event_type = event_type; 395 event_data.event_type = event_type;
397 event_data.item_id = extension_id; 396 event_data.item_id = extension_id;
398 scoped_ptr<base::DictionaryValue> dict = event_data.ToValue(); 397 scoped_ptr<base::DictionaryValue> dict = event_data.ToValue();
399 398
400 if (!infos.empty()) { 399 if (!infos.empty()) {
401 // Hack: Ideally, we would use event_data.extension_info to set the 400 // Hack: Ideally, we would use event_data.extension_info to set the
402 // extension info, but since it's an optional field, it's implemented as a 401 // extension info, but since it's an optional field, it's implemented as a
403 // scoped ptr, and so ownership between that and the vector of linked ptrs 402 // scoped ptr, and so ownership between that and the vector of linked ptrs
404 // here is, well, messy. Easier to just set it like this. 403 // here is, well, messy. Easier to just set it like this.
405 dict->SetWithoutPathExpansion("extensionInfo", 404 dict->SetWithoutPathExpansion("extensionInfo",
406 infos[0]->ToValue().release()); 405 infos[0]->ToValue().release());
407 } 406 }
408 407
409 scoped_ptr<base::ListValue> args(new base::ListValue()); 408 scoped_ptr<base::ListValue> args(new base::ListValue());
410 args->Append(dict.release()); 409 args->Append(dict.release());
411 scoped_ptr<Event> event( 410 scoped_ptr<Event> event(
412 new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED, 411 new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED,
413 developer::OnItemStateChanged::kEventName, args.Pass())); 412 developer::OnItemStateChanged::kEventName, std::move(args)));
414 event_router_->BroadcastEvent(event.Pass()); 413 event_router_->BroadcastEvent(std::move(event));
415 } 414 }
416 415
417 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) { 416 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) {
418 last_unpacked_directory_ = path; 417 last_unpacked_directory_ = path;
419 } 418 }
420 419
421 void DeveloperPrivateAPI::RegisterNotifications() { 420 void DeveloperPrivateAPI::RegisterNotifications() {
422 EventRouter::Get(profile_)->RegisterObserver( 421 EventRouter::Get(profile_)->RegisterObserver(
423 this, developer::OnItemStateChanged::kEventName); 422 this, developer::OnItemStateChanged::kEventName);
424 } 423 }
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 update.extension_id, update.command_name, *update.keybinding); 1450 update.extension_id, update.command_name, *update.keybinding);
1452 } 1451 }
1453 1452
1454 return RespondNow(NoArguments()); 1453 return RespondNow(NoArguments());
1455 } 1454 }
1456 1455
1457 1456
1458 } // namespace api 1457 } // namespace api
1459 1458
1460 } // namespace extensions 1459 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698