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

Side by Side Diff: webkit/glue/plugins/plugin_group.cc

Issue 5918003: Bugfixes for recent PluginGroup refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 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
« no previous file with comments | « webkit/glue/plugins/plugin_group.h ('k') | webkit/glue/plugins/plugin_group_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/plugins/plugin_group.h" 5 #include "webkit/glue/plugins/plugin_group.h"
6 6
7 #include "base/linked_ptr.h" 7 #include "base/linked_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 version_(Version::GetVersionFromString("0")) { 102 version_(Version::GetVersionFromString("0")) {
103 } 103 }
104 104
105 void PluginGroup::InitFrom(const PluginGroup& other) { 105 void PluginGroup::InitFrom(const PluginGroup& other) {
106 identifier_ = other.identifier_; 106 identifier_ = other.identifier_;
107 group_name_ = other.group_name_; 107 group_name_ = other.group_name_;
108 name_matcher_ = other.name_matcher_; 108 name_matcher_ = other.name_matcher_;
109 description_ = other.description_; 109 description_ = other.description_;
110 update_url_ = other.update_url_; 110 update_url_ = other.update_url_;
111 enabled_ = other.enabled_; 111 enabled_ = other.enabled_;
112 for (size_t i = 0; i < other.version_ranges_.size(); ++i) 112 version_ranges_ = other.version_ranges_;
113 version_ranges_.push_back(other.version_ranges_[i]); 113 version_.reset(other.version_->Clone());
114 DCHECK_EQ(other.web_plugin_infos_.size(), other.web_plugin_positions_.size()); 114 web_plugin_infos_ = other.web_plugin_infos_;
115 for (size_t i = 0; i < other.web_plugin_infos_.size(); ++i) 115 web_plugin_positions_ = other.web_plugin_positions_;
116 AddPlugin(other.web_plugin_infos_[i], other.web_plugin_positions_[i]);
117 if (!version_.get())
118 version_.reset(Version::GetVersionFromString("0"));
119 } 116 }
120 117
121 PluginGroup::PluginGroup(const PluginGroup& other) { 118 PluginGroup::PluginGroup(const PluginGroup& other) {
122 InitFrom(other); 119 InitFrom(other);
123 } 120 }
124 121
125 PluginGroup& PluginGroup::operator=(const PluginGroup& other) { 122 PluginGroup& PluginGroup::operator=(const PluginGroup& other) {
126 version_ranges_.clear();
127 InitFrom(other); 123 InitFrom(other);
128 return *this; 124 return *this;
129 } 125 }
130 126
131 /*static*/ 127 /*static*/
132 PluginGroup* PluginGroup::FromPluginGroupDefinition( 128 PluginGroup* PluginGroup::FromPluginGroupDefinition(
133 const PluginGroupDefinition& definition) { 129 const PluginGroupDefinition& definition) {
134 PluginGroup* group = new PluginGroup(ASCIIToUTF16(definition.name), 130 PluginGroup* group = new PluginGroup(ASCIIToUTF16(definition.name),
135 ASCIIToUTF16(definition.name_matcher), 131 ASCIIToUTF16(definition.name_matcher),
136 definition.update_url, 132 definition.update_url,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 plugin.path.value())) { 241 plugin.path.value())) {
246 return; 242 return;
247 } 243 }
248 } 244 }
249 web_plugin_infos_.push_back(plugin); 245 web_plugin_infos_.push_back(plugin);
250 // The position of this plugin relative to the global list of plugins. 246 // The position of this plugin relative to the global list of plugins.
251 web_plugin_positions_.push_back(position); 247 web_plugin_positions_.push_back(position);
252 UpdateActivePlugin(plugin); 248 UpdateActivePlugin(plugin);
253 } 249 }
254 250
251 bool PluginGroup::IsEmpty() const {
252 return web_plugin_infos_.empty();
253 }
254
255 string16 PluginGroup::GetGroupName() const { 255 string16 PluginGroup::GetGroupName() const {
256 if (!group_name_.empty()) 256 if (!group_name_.empty())
257 return group_name_; 257 return group_name_;
258 DCHECK_EQ(1u, web_plugin_infos_.size()); 258 DCHECK_EQ(1u, web_plugin_infos_.size());
259 FilePath::StringType path = 259 FilePath::StringType path =
260 web_plugin_infos_[0].path.BaseName().RemoveExtension().value(); 260 web_plugin_infos_[0].path.BaseName().RemoveExtension().value();
261 #if defined(OS_POSIX) 261 #if defined(OS_POSIX)
262 return UTF8ToUTF16(path); 262 return UTF8ToUTF16(path);
263 #elif defined(OS_WIN) 263 #elif defined(OS_WIN)
264 return WideToUTF16(path); 264 return WideToUTF16(path);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 NPAPI::PluginList::Singleton()->EnablePlugin(it->path); 398 NPAPI::PluginList::Singleton()->EnablePlugin(it->path);
399 it->enabled = true; 399 it->enabled = true;
400 enabled_plugin_exists = true; 400 enabled_plugin_exists = true;
401 } else { 401 } else {
402 it->enabled = false; 402 it->enabled = false;
403 NPAPI::PluginList::Singleton()->DisablePlugin(it->path); 403 NPAPI::PluginList::Singleton()->DisablePlugin(it->path);
404 } 404 }
405 } 405 }
406 enabled_ = enabled_plugin_exists; 406 enabled_ = enabled_plugin_exists;
407 } 407 }
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_group.h ('k') | webkit/glue/plugins/plugin_group_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698