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

Unified Diff: chrome/renderer/content_settings_observer.cc

Issue 1568073002: Reduce string copies in GURL creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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: chrome/renderer/content_settings_observer.cc
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
index 2a2ba4e6cf144eb5547e8a4c234bb805f0fafd17..b87083dc1a15f665f773c22a561201531f72cc7c 100644
--- a/chrome/renderer/content_settings_observer.cc
+++ b/chrome/renderer/content_settings_observer.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "components/content_settings/content/common/content_settings_messages.h"
+#include "content/public/child/url_conversion.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/render_frame.h"
@@ -122,7 +123,7 @@ GURL GetOriginOrURL(const WebFrame* frame) {
// URL is not replicated.
if (top_origin == "null")
return frame->top()->document().url();
- return GURL(top_origin);
+ return content::WebStringToGURL(top_origin);
}
ContentSetting GetContentSettingFromRules(
@@ -283,9 +284,10 @@ bool ContentSettingsObserver::allowDatabase(const WebString& name,
bool result = false;
Send(new ChromeViewHostMsg_AllowDatabase(
- routing_id(), GURL(frame->securityOrigin().toString()),
- GURL(frame->top()->securityOrigin().toString()), name, display_name,
- &result));
+ routing_id(),
+ content::WebStringToGURL(frame->securityOrigin().toString()),
+ content::WebStringToGURL(frame->top()->securityOrigin().toString()),
+ name, display_name, &result));
return result;
}
@@ -308,8 +310,8 @@ void ContentSettingsObserver::requestFileSystemAccessAsync(
Send(new ChromeViewHostMsg_RequestFileSystemAccessAsync(
routing_id(), current_request_id_,
- GURL(frame->securityOrigin().toString()),
- GURL(frame->top()->securityOrigin().toString())));
+ content::WebStringToGURL(frame->securityOrigin().toString()),
+ content::WebStringToGURL(frame->top()->securityOrigin().toString())));
}
bool ContentSettingsObserver::allowImage(bool enabled_per_settings,
@@ -344,8 +346,10 @@ bool ContentSettingsObserver::allowIndexedDB(const WebString& name,
bool result = false;
Send(new ChromeViewHostMsg_AllowIndexedDB(
- routing_id(), GURL(frame->securityOrigin().toString()),
- GURL(frame->top()->securityOrigin().toString()), name, &result));
+ routing_id(),
+ content::WebStringToGURL(frame->securityOrigin().toString()),
+ content::WebStringToGURL(frame->top()->securityOrigin().toString()),
+ name, &result));
return result;
}
@@ -373,7 +377,8 @@ bool ContentSettingsObserver::allowScript(bool enabled_per_settings) {
ContentSetting setting = GetContentSettingFromRules(
content_setting_rules_->script_rules,
frame,
- GURL(frame->document().securityOrigin().toString()));
+ content::WebStringToGURL(
+ frame->document().securityOrigin().toString()));
allow = setting != CONTENT_SETTING_BLOCK;
}
allow = allow || IsWhitelistedForContentSettings();
@@ -409,15 +414,18 @@ bool ContentSettingsObserver::allowStorage(bool local) {
bool result = false;
StoragePermissionsKey key(
- GURL(frame->document().securityOrigin().toString()), local);
+ content::WebStringToGURL(frame->document().securityOrigin().toString()),
+ local);
std::map<StoragePermissionsKey, bool>::const_iterator permissions =
cached_storage_permissions_.find(key);
if (permissions != cached_storage_permissions_.end())
return permissions->second;
Send(new ChromeViewHostMsg_AllowDOMStorage(
- routing_id(), GURL(frame->securityOrigin().toString()),
- GURL(frame->top()->securityOrigin().toString()), local, &result));
+ routing_id(),
+ content::WebStringToGURL(frame->securityOrigin().toString()),
+ content::WebStringToGURL(frame->top()->securityOrigin().toString()),
+ local, &result));
cached_storage_permissions_[key] = result;
return result;
}
@@ -597,7 +605,7 @@ void ContentSettingsObserver::didUseKeygen() {
WebFrame* frame = render_frame()->GetWebFrame();
Send(new ChromeViewHostMsg_DidUseKeygen(
routing_id(),
- GURL(frame->securityOrigin().toString())));
+ content::WebStringToGURL(frame->securityOrigin().toString())));
}
void ContentSettingsObserver::didNotAllowPlugins() {

Powered by Google App Engine
This is Rietveld 408576698