Chromium Code Reviews| 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..b733ea6c9f6e5efae50c440c28aedbc605c203a9 100644 |
| --- a/chrome/browser/ui/omnibox/omnibox_view.cc |
| +++ b/chrome/browser/ui/omnibox/omnibox_view.cc |
| @@ -13,6 +13,23 @@ |
| #include "chrome/browser/browser_process.h" |
| #include "ui/base/clipboard/clipboard.h" |
| +OmniboxEditModel* OmniboxView::GetModel() { |
| + return model_.get(); |
| +} |
| + |
| +const OmniboxEditModel* OmniboxView::GetModel() const { |
| + return model_.get(); |
| +} |
| + |
| +CommandUpdater* OmniboxView::GetCommandUpdater() { |
| + return command_updater_; |
| +} |
| + |
| +const CommandUpdater* OmniboxView::GetCommandUpdater() const { |
| + return command_updater_; |
| +} |
| + |
| +// static |
| string16 OmniboxView::StripJavascriptSchemas(const string16& text) { |
| const string16 kJsPrefix(ASCIIToUTF16(chrome::kJavaScriptScheme) + |
| ASCIIToUTF16(":")); |
| @@ -66,3 +83,70 @@ string16 OmniboxView::GetClipboardText() { |
| return string16(); |
| } |
| + |
| +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. |
|
Peter Kasting
2012/07/26 03:59:17
I think this can perhaps happen if for example you
|
| + if (!match.destination_url.is_valid()) { |
|
Peter Kasting
2012/07/26 03:59:17
Nit: No {}
dominich
2012/07/26 22:33:24
Done.
|
| + 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. |
|
Peter Kasting
2012/07/26 03:59:17
I don't know what this comment means, and I'm incl
Peter Kasting
2012/07/26 23:03:24
Note this is still outstanding.
dominich
2012/07/30 16:42:59
I'm tempted to just nuke it. We don't have any ope
|
| + SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, |
| + true); |
| +} |
| + |
| +void OmniboxView::RevertAll() { |
| + ClosePopup(); |
| + model_->Revert(); |
| + TextChanged(); |
| +} |
| + |
| +void OmniboxView::ClosePopup() { |
| + model_->StopAutocomplete(); |
| +} |
| + |
| +OmniboxView::~OmniboxView() { |
| +} |
| + |
| +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(); |
| +} |