| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/searchbox/searchbox.h" | 5 #include "chrome/renderer/searchbox/searchbox.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/common/omnibox_focus_state.h" |
| 9 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 11 #include "chrome/renderer/searchbox/searchbox_extension.h" | 12 #include "chrome/renderer/searchbox/searchbox_extension.h" |
| 12 #include "content/public/renderer/render_view.h" | 13 #include "content/public/renderer/render_view.h" |
| 13 #include "grit/renderer_resources.h" | 14 #include "grit/renderer_resources.h" |
| 14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 91 } |
| 91 | 92 |
| 92 void SearchBox::ShowInstantOverlay(int height, InstantSizeUnits units) { | 93 void SearchBox::ShowInstantOverlay(int height, InstantSizeUnits units) { |
| 93 render_view()->Send(new ChromeViewHostMsg_ShowInstantOverlay( | 94 render_view()->Send(new ChromeViewHostMsg_ShowInstantOverlay( |
| 94 render_view()->GetRoutingID(), render_view()->GetPageId(), height, | 95 render_view()->GetRoutingID(), render_view()->GetPageId(), height, |
| 95 units)); | 96 units)); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void SearchBox::FocusOmnibox() { | 99 void SearchBox::FocusOmnibox() { |
| 99 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox( | 100 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox( |
| 100 render_view()->GetRoutingID(), render_view()->GetPageId())); | 101 render_view()->GetRoutingID(), render_view()->GetPageId(), |
| 102 OMNIBOX_FOCUS_VISIBLE)); |
| 101 } | 103 } |
| 102 | 104 |
| 103 void SearchBox::StartCapturingKeyStrokes() { | 105 void SearchBox::StartCapturingKeyStrokes() { |
| 104 render_view()->Send(new ChromeViewHostMsg_StartCapturingKeyStrokes( | 106 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox( |
| 105 render_view()->GetRoutingID(), render_view()->GetPageId())); | 107 render_view()->GetRoutingID(), render_view()->GetPageId(), |
| 108 OMNIBOX_FOCUS_INVISIBLE)); |
| 106 } | 109 } |
| 107 | 110 |
| 108 void SearchBox::StopCapturingKeyStrokes() { | 111 void SearchBox::StopCapturingKeyStrokes() { |
| 109 render_view()->Send(new ChromeViewHostMsg_StopCapturingKeyStrokes( | 112 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox( |
| 110 render_view()->GetRoutingID(), render_view()->GetPageId())); | 113 render_view()->GetRoutingID(), render_view()->GetPageId(), |
| 114 OMNIBOX_FOCUS_NONE)); |
| 111 } | 115 } |
| 112 | 116 |
| 113 void SearchBox::NavigateToURL(const GURL& url, | 117 void SearchBox::NavigateToURL(const GURL& url, |
| 114 content::PageTransition transition, | 118 content::PageTransition transition, |
| 115 WindowOpenDisposition disposition) { | 119 WindowOpenDisposition disposition) { |
| 116 render_view()->Send(new ChromeViewHostMsg_SearchBoxNavigate( | 120 render_view()->Send(new ChromeViewHostMsg_SearchBoxNavigate( |
| 117 render_view()->GetRoutingID(), render_view()->GetPageId(), | 121 render_view()->GetRoutingID(), render_view()->GetPageId(), |
| 118 url, transition, disposition)); | 122 url, transition, disposition)); |
| 119 } | 123 } |
| 120 | 124 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 468 |
| 465 string16 trimmedUserInput; | 469 string16 trimmedUserInput; |
| 466 TrimWhitespace(query(), TRIM_LEADING, &trimmedUserInput); | 470 TrimWhitespace(query(), TRIM_LEADING, &trimmedUserInput); |
| 467 if (EndsWith(*url, trimmedUserInput, true)) | 471 if (EndsWith(*url, trimmedUserInput, true)) |
| 468 return; | 472 return; |
| 469 | 473 |
| 470 // Strip a lone trailing slash. | 474 // Strip a lone trailing slash. |
| 471 if (EndsWith(*url, ASCIIToUTF16("/"), true)) | 475 if (EndsWith(*url, ASCIIToUTF16("/"), true)) |
| 472 url->erase(url->length() - 1, 1); | 476 url->erase(url->length() - 1, 1); |
| 473 } | 477 } |
| OLD | NEW |