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

Unified Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 10912054: Adding parsing for partition and persistence attributes to the <browser> tag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/browser_plugin/browser_plugin.cc
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 8ba5421f33aa700fe63e733024d9a5185ed74684..7b949c708ef716a452b77c5a8e1e6e491ce632bf 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -40,6 +40,8 @@ namespace {
const char kCrashEventName[] = "crash";
const char kNavigationEventName[] = "navigation";
const char* kSrcAttribute = "src";
+const char kPartitionAttribute[] = "partition";
+const char kPersistAttribute[] = "persist";
}
BrowserPlugin::BrowserPlugin(
@@ -54,13 +56,13 @@ BrowserPlugin::BrowserPlugin(
sad_guest_(NULL),
guest_crashed_(false),
resize_pending_(false),
- parent_frame_(frame->identifier()) {
+ parent_frame_(frame->identifier()),
+ has_navigated_(false),
+ persist_storage_(UNSET_VALUE) {
BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this);
bindings_.reset(new BrowserPluginBindings(this));
- std::string src;
- if (ParseSrcAttribute(params, &src))
- SetSrcAttribute(src);
+ ParseAttributes(params);
}
BrowserPlugin::~BrowserPlugin() {
@@ -97,23 +99,55 @@ void BrowserPlugin::SetSrcAttribute(const std::string& src) {
instance_id_,
parent_frame_,
src));
+ has_navigated_ = true;
}
src_ = src;
guest_crashed_ = false;
}
-bool BrowserPlugin::ParseSrcAttribute(
- const WebKit::WebPluginParams& params,
- std::string* src) {
- // Get the src attribute from the attributes vector
+std::string BrowserPlugin::GetPartitionAttribute() const {
+ return partition_id_;
+}
+
+bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id) {
+ if (has_navigated_ || !partition_id_.empty())
michaeln 2012/09/10 23:01:43 is there a reason to prevent setting to a differen
nasko 2012/09/10 23:16:08 We want to alert the developers that this is a one
+ return false;
+
+ partition_id_ = partition_id;
+ return true;
+}
+
+bool BrowserPlugin::GetPersistAttribute() const {
+ if (persist_storage_ == TRUE_VALUE)
+ return true;
+
+ return false;
+}
+
+bool BrowserPlugin::SetPersistAttribute(bool persist) {
+ if (has_navigated_ || persist_storage_ != UNSET_VALUE)
+ return false;
+
+ persist_storage_ = persist ? TRUE_VALUE : FALSE_VALUE;
+ return true;
+}
+
+void BrowserPlugin::ParseAttributes(const WebKit::WebPluginParams& params) {
+ std::string src;
for (unsigned i = 0; i < params.attributeNames.size(); ++i) {
std::string attributeName = params.attributeNames[i].utf8();
if (LowerCaseEqualsASCII(attributeName, kSrcAttribute)) {
- *src = params.attributeValues[i].utf8();
- return true;
+ src = params.attributeValues[i].utf8();
+ } else if (LowerCaseEqualsASCII(attributeName, kPartitionAttribute)) {
+ SetPartitionAttribute(params.attributeValues[i].utf8());
+ } else if (LowerCaseEqualsASCII(attributeName, kPersistAttribute)) {
+ SetPersistAttribute(true);
}
}
- return false;
+ // Set the 'src' attribute last, as it will set the has_navigated_ flag to
+ // true, which prevents changing the 'partition' and 'persist' attributes.
+ if (!src.empty())
+ SetSrcAttribute(src);
}
float BrowserPlugin::GetDeviceScaleFactor() const {

Powered by Google App Engine
This is Rietveld 408576698