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

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

Issue 264933005: Add remote_install flag to extension sync data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
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/extension_sync_data.h" 5 #include "chrome/browser/extensions/extension_sync_data.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/extensions/app_sync_data.h" 8 #include "chrome/browser/extensions/app_sync_data.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/common/extensions/manifest_url_handler.h" 10 #include "chrome/common/extensions/manifest_url_handler.h"
11 #include "extensions/common/extension.h" 11 #include "extensions/common/extension.h"
12 #include "sync/api/sync_data.h" 12 #include "sync/api/sync_data.h"
13 #include "sync/protocol/extension_specifics.pb.h" 13 #include "sync/protocol/extension_specifics.pb.h"
14 #include "sync/protocol/sync.pb.h" 14 #include "sync/protocol/sync.pb.h"
15 15
16 namespace extensions { 16 namespace extensions {
17 17
18 ExtensionSyncData::ExtensionSyncData() 18 ExtensionSyncData::ExtensionSyncData()
19 : uninstalled_(false), 19 : uninstalled_(false),
20 enabled_(false), 20 enabled_(false),
21 incognito_enabled_(false) { 21 incognito_enabled_(false),
22 remote_install_(false) {
22 } 23 }
23 24
24 ExtensionSyncData::ExtensionSyncData(const syncer::SyncData& sync_data) 25 ExtensionSyncData::ExtensionSyncData(const syncer::SyncData& sync_data)
25 : uninstalled_(false), 26 : uninstalled_(false),
26 enabled_(false), 27 enabled_(false),
27 incognito_enabled_(false) { 28 incognito_enabled_(false),
29 remote_install_(false) {
28 PopulateFromSyncData(sync_data); 30 PopulateFromSyncData(sync_data);
29 } 31 }
30 32
31 ExtensionSyncData::ExtensionSyncData(const syncer::SyncChange& sync_change) 33 ExtensionSyncData::ExtensionSyncData(const syncer::SyncChange& sync_change)
32 : uninstalled_( 34 : uninstalled_(
33 sync_change.change_type() == syncer::SyncChange::ACTION_DELETE), 35 sync_change.change_type() == syncer::SyncChange::ACTION_DELETE),
34 enabled_(false), 36 enabled_(false),
35 incognito_enabled_(false) { 37 incognito_enabled_(false),
38 remote_install_(false) {
36 PopulateFromSyncData(sync_change.sync_data()); 39 PopulateFromSyncData(sync_change.sync_data());
37 } 40 }
38 41
39 ExtensionSyncData::ExtensionSyncData(const Extension& extension, 42 ExtensionSyncData::ExtensionSyncData(const Extension& extension,
40 bool enabled, 43 bool enabled,
41 bool incognito_enabled) 44 bool incognito_enabled)
42 : id_(extension.id()), 45 : id_(extension.id()),
43 uninstalled_(false), 46 uninstalled_(false),
44 enabled_(enabled), 47 enabled_(enabled),
45 incognito_enabled_(incognito_enabled), 48 incognito_enabled_(incognito_enabled),
49 remote_install_(false),
46 version_(extension.from_bookmark() ? base::Version("0") 50 version_(extension.from_bookmark() ? base::Version("0")
47 : *extension.version()), 51 : *extension.version()),
48 update_url_(ManifestURL::GetUpdateURL(&extension)), 52 update_url_(ManifestURL::GetUpdateURL(&extension)),
49 name_(extension.non_localized_name()) { 53 name_(extension.non_localized_name()) {
50 } 54 }
51 55
52 ExtensionSyncData::~ExtensionSyncData() {} 56 ExtensionSyncData::~ExtensionSyncData() {}
53 57
54 syncer::SyncData ExtensionSyncData::GetSyncData() const { 58 syncer::SyncData ExtensionSyncData::GetSyncData() const {
55 sync_pb::EntitySpecifics specifics; 59 sync_pb::EntitySpecifics specifics;
56 PopulateExtensionSpecifics(specifics.mutable_extension()); 60 PopulateExtensionSpecifics(specifics.mutable_extension());
57 61
58 return syncer::SyncData::CreateLocalData(id_, name_, specifics); 62 return syncer::SyncData::CreateLocalData(id_, name_, specifics);
59 } 63 }
60 64
61 syncer::SyncChange ExtensionSyncData::GetSyncChange( 65 syncer::SyncChange ExtensionSyncData::GetSyncChange(
62 syncer::SyncChange::SyncChangeType change_type) const { 66 syncer::SyncChange::SyncChangeType change_type) const {
63 return syncer::SyncChange(FROM_HERE, change_type, GetSyncData()); 67 return syncer::SyncChange(FROM_HERE, change_type, GetSyncData());
64 } 68 }
65 69
66 void ExtensionSyncData::PopulateExtensionSpecifics( 70 void ExtensionSyncData::PopulateExtensionSpecifics(
67 sync_pb::ExtensionSpecifics* specifics) const { 71 sync_pb::ExtensionSpecifics* specifics) const {
68 DCHECK(Extension::IdIsValid(id_)); 72 DCHECK(Extension::IdIsValid(id_));
69 specifics->set_id(id_); 73 specifics->set_id(id_);
70 specifics->set_update_url(update_url_.spec()); 74 specifics->set_update_url(update_url_.spec());
71 specifics->set_version(version_.GetString()); 75 specifics->set_version(version_.GetString());
72 specifics->set_enabled(enabled_); 76 specifics->set_enabled(enabled_);
73 specifics->set_incognito_enabled(incognito_enabled_); 77 specifics->set_incognito_enabled(incognito_enabled_);
78 specifics->set_remote_install(remote_install_);
74 specifics->set_name(name_); 79 specifics->set_name(name_);
75 } 80 }
76 81
77 void ExtensionSyncData::PopulateFromExtensionSpecifics( 82 void ExtensionSyncData::PopulateFromExtensionSpecifics(
78 const sync_pb::ExtensionSpecifics& specifics) { 83 const sync_pb::ExtensionSpecifics& specifics) {
79 if (!Extension::IdIsValid(specifics.id())) { 84 if (!Extension::IdIsValid(specifics.id())) {
80 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; 85 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics.";
81 } 86 }
82 87
83 Version specifics_version(specifics.version()); 88 Version specifics_version(specifics.version());
84 if (!specifics_version.IsValid()) 89 if (!specifics_version.IsValid())
85 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; 90 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics.";
86 91
87 // The update URL must be either empty or valid. 92 // The update URL must be either empty or valid.
88 GURL specifics_update_url(specifics.update_url()); 93 GURL specifics_update_url(specifics.update_url());
89 if (!specifics_update_url.is_empty() && !specifics_update_url.is_valid()) { 94 if (!specifics_update_url.is_empty() && !specifics_update_url.is_valid()) {
90 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; 95 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics.";
91 } 96 }
92 97
93 id_ = specifics.id(); 98 id_ = specifics.id();
94 update_url_ = specifics_update_url; 99 update_url_ = specifics_update_url;
95 version_ = specifics_version; 100 version_ = specifics_version;
96 enabled_ = specifics.enabled(); 101 enabled_ = specifics.enabled();
97 incognito_enabled_ = specifics.incognito_enabled(); 102 incognito_enabled_ = specifics.incognito_enabled();
103 remote_install_ = specifics.remote_install();
98 name_ = specifics.name(); 104 name_ = specifics.name();
99 } 105 }
100 106
101 void ExtensionSyncData::set_uninstalled(bool uninstalled) { 107 void ExtensionSyncData::set_uninstalled(bool uninstalled) {
102 uninstalled_ = uninstalled; 108 uninstalled_ = uninstalled;
103 } 109 }
104 110
105 void ExtensionSyncData::PopulateFromSyncData( 111 void ExtensionSyncData::PopulateFromSyncData(
106 const syncer::SyncData& sync_data) { 112 const syncer::SyncData& sync_data) {
107 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); 113 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics();
108 114
109 if (entity_specifics.has_extension()) { 115 if (entity_specifics.has_extension()) {
110 PopulateFromExtensionSpecifics(entity_specifics.extension()); 116 PopulateFromExtensionSpecifics(entity_specifics.extension());
111 } else { 117 } else {
112 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; 118 LOG(FATAL) << "Attempt to sync bad EntitySpecifics.";
113 } 119 }
114 } 120 }
115 121
116 } // namespace extensions 122 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698