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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 8727024: Save the oauth client id used in App Notification setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 // Extract the data we need for sync now, but don't actually sync until we've 670 // Extract the data we need for sync now, but don't actually sync until we've
671 // completed the uninstallation. 671 // completed the uninstallation.
672 SyncBundle* sync_bundle = GetSyncBundleForExtension(*extension); 672 SyncBundle* sync_bundle = GetSyncBundleForExtension(*extension);
673 673
674 SyncChange sync_change; 674 SyncChange sync_change;
675 if (sync_bundle) { 675 if (sync_bundle) {
676 ExtensionSyncData extension_sync_data( 676 ExtensionSyncData extension_sync_data(
677 *extension, 677 *extension,
678 IsExtensionEnabled(extension_id), 678 IsExtensionEnabled(extension_id),
679 IsIncognitoEnabled(extension_id), 679 IsIncognitoEnabled(extension_id),
680 extension_prefs_->IsAppNotificationSetupDone(extension_id), 680 extension_prefs_->GetAppNotificationClientId(extension_id),
681 extension_prefs_->IsAppNotificationDisabled(extension_id)); 681 extension_prefs_->IsAppNotificationDisabled(extension_id));
682 sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE); 682 sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE);
683 } 683 }
684 684
685 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", 685 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType",
686 extension->GetType(), 100); 686 extension->GetType(), 100);
687 RecordPermissionMessagesHistogram( 687 RecordPermissionMessagesHistogram(
688 extension, "Extensions.Permissions_Uninstall"); 688 extension, "Extensions.Permissions_Uninstall");
689 689
690 TemplateURLService* url_service = 690 TemplateURLService* url_service =
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 return pending_sync_data.find(id) != pending_sync_data.end(); 1200 return pending_sync_data.find(id) != pending_sync_data.end();
1201 } 1201 }
1202 1202
1203 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 1203 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
1204 SyncBundle* sync_bundle = GetSyncBundleForExtension(extension); 1204 SyncBundle* sync_bundle = GetSyncBundleForExtension(extension);
1205 if (sync_bundle) { 1205 if (sync_bundle) {
1206 ExtensionSyncData extension_sync_data( 1206 ExtensionSyncData extension_sync_data(
1207 extension, 1207 extension,
1208 IsExtensionEnabled(extension.id()), 1208 IsExtensionEnabled(extension.id()),
1209 IsIncognitoEnabled(extension.id()), 1209 IsIncognitoEnabled(extension.id()),
1210 extension_prefs_->IsAppNotificationSetupDone(extension.id()), 1210 extension_prefs_->GetAppNotificationClientId(extension.id()),
1211 extension_prefs_->IsAppNotificationDisabled(extension.id())); 1211 extension_prefs_->IsAppNotificationDisabled(extension.id()));
1212 1212
1213 SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange( 1213 SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange(
1214 sync_bundle->HasExtensionId(extension.id()) ? 1214 sync_bundle->HasExtensionId(extension.id()) ?
1215 SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD)); 1215 SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD));
1216 sync_bundle->sync_processor->ProcessSyncChanges( 1216 sync_bundle->sync_processor->ProcessSyncChanges(
1217 FROM_HERE, sync_change_list); 1217 FROM_HERE, sync_change_list);
1218 sync_bundle->synced_extensions.insert(extension.id()); 1218 sync_bundle->synced_extensions.insert(extension.id());
1219 sync_bundle->pending_sync_data.erase(extension.id()); 1219 sync_bundle->pending_sync_data.erase(extension.id());
1220 } 1220 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 const Extension& extension = **it; 1365 const Extension& extension = **it;
1366 if (bundle.filter(extension) && 1366 if (bundle.filter(extension) &&
1367 // If we have pending extension data for this extension, then this 1367 // If we have pending extension data for this extension, then this
1368 // version is out of date. We'll sync back the version we got from 1368 // version is out of date. We'll sync back the version we got from
1369 // sync. 1369 // sync.
1370 !bundle.HasPendingExtensionId(extension.id())) { 1370 !bundle.HasPendingExtensionId(extension.id())) {
1371 sync_data_list->push_back(ExtensionSyncData( 1371 sync_data_list->push_back(ExtensionSyncData(
1372 extension, 1372 extension,
1373 IsExtensionEnabled(extension.id()), 1373 IsExtensionEnabled(extension.id()),
1374 IsIncognitoEnabled(extension.id()), 1374 IsIncognitoEnabled(extension.id()),
1375 extension_prefs_->IsAppNotificationSetupDone(extension.id()), 1375 extension_prefs_->GetAppNotificationClientId(extension.id()),
1376 extension_prefs_->IsAppNotificationDisabled(extension.id()))); 1376 extension_prefs_->IsAppNotificationDisabled(extension.id())));
1377 } 1377 }
1378 } 1378 }
1379 } 1379 }
1380 1380
1381 std::vector<ExtensionSyncData> ExtensionService::GetSyncDataList( 1381 std::vector<ExtensionSyncData> ExtensionService::GetSyncDataList(
1382 const SyncBundle& bundle) const { 1382 const SyncBundle& bundle) const {
1383 std::vector<ExtensionSyncData> extension_sync_list; 1383 std::vector<ExtensionSyncData> extension_sync_list;
1384 GetSyncDataListHelper(extensions_, bundle, &extension_sync_list); 1384 GetSyncDataListHelper(extensions_, bundle, &extension_sync_list);
1385 GetSyncDataListHelper(disabled_extensions_, bundle, &extension_sync_list); 1385 GetSyncDataListHelper(disabled_extensions_, bundle, &extension_sync_list);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 ReloadExtension(extension->id()); 1501 ReloadExtension(extension->id());
1502 1502
1503 // Reloading the extension invalidates the |extension| pointer. 1503 // Reloading the extension invalidates the |extension| pointer.
1504 extension = GetInstalledExtension(id); 1504 extension = GetInstalledExtension(id);
1505 if (extension) 1505 if (extension)
1506 SyncExtensionChangeIfNeeded(*extension); 1506 SyncExtensionChangeIfNeeded(*extension);
1507 } 1507 }
1508 1508
1509 void ExtensionService::SetAppNotificationSetupDone( 1509 void ExtensionService::SetAppNotificationSetupDone(
1510 const std::string& extension_id, 1510 const std::string& extension_id,
1511 bool value) { 1511 const std::string& oauth_client_id) {
1512 const Extension* extension = GetInstalledExtension(extension_id); 1512 const Extension* extension = GetInstalledExtension(extension_id);
1513 // This method is called when the user sets up app notifications. 1513 // This method is called when the user sets up app notifications.
1514 // So it is not expected to be called until the extension is installed. 1514 // So it is not expected to be called until the extension is installed.
1515 if (!extension) { 1515 if (!extension) {
1516 NOTREACHED(); 1516 NOTREACHED();
1517 return; 1517 return;
1518 } 1518 }
1519 extension_prefs_->SetAppNotificationSetupDone(extension_id, value); 1519 extension_prefs_->SetAppNotificationClientId(extension_id, oauth_client_id);
1520 SyncExtensionChangeIfNeeded(*extension); 1520 SyncExtensionChangeIfNeeded(*extension);
1521 } 1521 }
1522 1522
1523 void ExtensionService::SetAppNotificationDisabled( 1523 void ExtensionService::SetAppNotificationDisabled(
1524 const std::string& extension_id, 1524 const std::string& extension_id,
1525 bool value) { 1525 bool value) {
1526 const Extension* extension = GetInstalledExtension(extension_id); 1526 const Extension* extension = GetInstalledExtension(extension_id);
1527 // This method is called when the user enables/disables app notifications. 1527 // This method is called when the user enables/disables app notifications.
1528 // So it is not expected to be called until the extension is installed. 1528 // So it is not expected to be called until the extension is installed.
1529 if (!extension) { 1529 if (!extension) {
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 2518
2519 ExtensionService::NaClModuleInfoList::iterator 2519 ExtensionService::NaClModuleInfoList::iterator
2520 ExtensionService::FindNaClModule(const GURL& url) { 2520 ExtensionService::FindNaClModule(const GURL& url) {
2521 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2521 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2522 iter != nacl_module_list_.end(); ++iter) { 2522 iter != nacl_module_list_.end(); ++iter) {
2523 if (iter->url == url) 2523 if (iter->url == url)
2524 return iter; 2524 return iter;
2525 } 2525 }
2526 return nacl_module_list_.end(); 2526 return nacl_module_list_.end();
2527 } 2527 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_sync_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698