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

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

Issue 10810062: Moving common code into OmniboxView from OmniboxView* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: public destructor Created 8 years, 5 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.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_view.cc b/chrome/browser/ui/omnibox/omnibox_view.cc
index a7ead88ae454aec011e2e2f6da1929650fffe828..f5b15651ac527667a8dc438d8e9fb8aaa783f40c 100644
--- a/chrome/browser/ui/omnibox/omnibox_view.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/browser_process.h"
#include "ui/base/clipboard/clipboard.h"
+// static
string16 OmniboxView::StripJavascriptSchemas(const string16& text) {
const string16 kJsPrefix(ASCIIToUTF16(chrome::kJavaScriptScheme) +
ASCIIToUTF16(":"));
@@ -66,3 +67,73 @@ string16 OmniboxView::GetClipboardText() {
return string16();
}
+
+OmniboxView::~OmniboxView() {
+ // Explicitly tear down objects with references to this.
+ model_.reset();
+}
+
+void OmniboxView::OpenMatch(const AutocompleteMatch& match,
+ WindowOpenDisposition disposition,
+ const GURL& alternate_nav_url,
+ size_t selected_line) {
+ // TODO(shess): Why is the caller passing an invalid url in the
+ // first place? Make sure that case isn't being dropped on the
+ // floor.
+ if (!match.destination_url.is_valid()) {
+ CHECK(false);
Peter Kasting 2012/07/26 23:03:24 Nit: Don't handle checkfailures -- if this really
dominich 2012/07/27 20:33:54 Confirmed that we don't get a hit here when typing
+ return;
+ }
+
+ model_->OpenMatch(match, disposition, alternate_nav_url, selected_line);
+}
+
+bool OmniboxView::IsEditingOrEmpty() const {
+ return model_->user_input_in_progress() || (GetOmniboxTextLength() == 0);
+}
+
+int OmniboxView::GetIcon() const {
+ return IsEditingOrEmpty() ?
+ AutocompleteMatch::TypeToIcon(model_->CurrentTextType()) :
+ toolbar_model_->GetIcon();
+}
+
+void OmniboxView::SetUserText(const string16& text) {
+ SetUserText(text, text, true);
+}
+
+void OmniboxView::SetUserText(const string16& text,
+ const string16& display_text,
+ bool update_popup) {
+ model_->SetUserText(text);
+ // TODO(deanm): something about selection / focus change here.
+ SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
+ true);
+}
+
+void OmniboxView::RevertAll() {
+ ClosePopup();
+ model_->Revert();
+ TextChanged();
+}
+
+void OmniboxView::ClosePopup() {
+ model_->StopAutocomplete();
+}
+
+OmniboxView::OmniboxView(Profile* profile,
+ OmniboxEditController* controller,
+ ToolbarModel* toolbar_model,
+ CommandUpdater* command_updater)
+ : controller_(controller),
+ toolbar_model_(toolbar_model),
+ command_updater_(command_updater) {
+ // |profile| can be NULL in tests.
+ if (profile)
+ model_.reset(new OmniboxEditModel(this, controller, profile));
+}
+
+void OmniboxView::TextChanged() {
+ EmphasizeURLComponents();
+ model_->OnChanged();
+}

Powered by Google App Engine
This is Rietveld 408576698