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

Unified Diff: chrome/browser/ui/omnibox/omnibox_view.h

Issue 6982011: Strip leading "javascript:" schemas from text pasted or dropped into the omnibox. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/omnibox/omnibox_view.h
===================================================================
--- chrome/browser/ui/omnibox/omnibox_view.h (revision 85569)
+++ chrome/browser/ui/omnibox/omnibox_view.h (working copy)
@@ -15,8 +15,11 @@
#include <string>
#include "base/string16.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "content/common/page_transition_types.h"
+#include "content/common/url_constants.h"
#include "ui/gfx/native_widget_types.h"
#include "webkit/glue/window_open_disposition.h"
@@ -187,4 +190,18 @@
virtual ~OmniboxView() {}
};
+// Strips any leading javascript schemas from a string.
+// Returns true if the output string differs from the input.
+static inline bool StripJavascriptSchema(const string16& text, string16* out) {
Peter Kasting 2011/05/20 22:04:14 Nit: Don't do this inline. It's not speed-critica
Cris Neckar 2011/05/24 00:10:06 Done.
+ const string16 kJsPrefix(UTF8ToUTF16(chrome::kJavaScriptScheme) +
+ UTF8ToUTF16(":"));
Peter Kasting 2011/05/20 22:04:14 Nit: I think both of these can be ASCIIToUTF16().
Cris Neckar 2011/05/24 00:10:06 Done.
+ bool changed = false;
+ *out = text;
Peter Kasting 2011/05/20 22:04:14 Nit: Shorter: for (*out = text; StartsWith(*out
Cris Neckar 2011/05/24 00:10:06 Done.
+ while (StartsWith(*out, kJsPrefix, false)) {
+ changed = true;
+ TrimWhitespace(out->substr(kJsPrefix.length()), TRIM_LEADING, out);
+ }
+ return changed;
+}
+
#endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_VIEW_H_
« no previous file with comments | « chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm ('k') | chrome/browser/ui/views/omnibox/omnibox_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698