| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/renderer/searchbox/searchbox_extension.h" | 10 #include "chrome/renderer/searchbox/searchbox_extension.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 render_view()->Send(new ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion( | 84 render_view()->Send(new ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion( |
| 85 render_view()->GetRoutingID(), most_visited_item_id)); | 85 render_view()->GetRoutingID(), most_visited_item_id)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void SearchBox::UndoAllMostVisitedDeletions() { | 88 void SearchBox::UndoAllMostVisitedDeletions() { |
| 89 render_view()->Send( | 89 render_view()->Send( |
| 90 new ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( | 90 new ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( |
| 91 render_view()->GetRoutingID())); | 91 render_view()->GetRoutingID())); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SearchBox::ShowBars() { |
| 95 DVLOG(1) << render_view() << " ShowBars"; |
| 96 render_view()->Send(new ChromeViewHostMsg_SearchBoxShowBars( |
| 97 render_view()->GetRoutingID(), render_view()->GetPageId())); |
| 98 } |
| 99 |
| 100 void SearchBox::HideBars() { |
| 101 DVLOG(1) << render_view() << " HideBars"; |
| 102 render_view()->Send(new ChromeViewHostMsg_SearchBoxHideBars( |
| 103 render_view()->GetRoutingID(), render_view()->GetPageId())); |
| 104 } |
| 105 |
| 94 int SearchBox::GetStartMargin() const { | 106 int SearchBox::GetStartMargin() const { |
| 95 return static_cast<int>(start_margin_ / GetZoom()); | 107 return static_cast<int>(start_margin_ / GetZoom()); |
| 96 } | 108 } |
| 97 | 109 |
| 98 gfx::Rect SearchBox::GetPopupBounds() const { | 110 gfx::Rect SearchBox::GetPopupBounds() const { |
| 99 double zoom = GetZoom(); | 111 double zoom = GetZoom(); |
| 100 return gfx::Rect(static_cast<int>(popup_bounds_.x() / zoom), | 112 return gfx::Rect(static_cast<int>(popup_bounds_.x() / zoom), |
| 101 static_cast<int>(popup_bounds_.y() / zoom), | 113 static_cast<int>(popup_bounds_.y() / zoom), |
| 102 static_cast<int>(popup_bounds_.width() / zoom), | 114 static_cast<int>(popup_bounds_.width() / zoom), |
| 103 static_cast<int>(popup_bounds_.height() / zoom)); | 115 static_cast<int>(popup_bounds_.height() / zoom)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 128 } | 140 } |
| 129 | 141 |
| 130 bool SearchBox::OnMessageReceived(const IPC::Message& message) { | 142 bool SearchBox::OnMessageReceived(const IPC::Message& message) { |
| 131 bool handled = true; | 143 bool handled = true; |
| 132 IPC_BEGIN_MESSAGE_MAP(SearchBox, message) | 144 IPC_BEGIN_MESSAGE_MAP(SearchBox, message) |
| 133 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxChange, OnChange) | 145 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxChange, OnChange) |
| 134 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) | 146 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) |
| 135 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel) | 147 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel) |
| 136 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize) | 148 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize) |
| 137 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange) | 149 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange) |
| 150 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxBarsHidden, OnBarsHidden) |
| 138 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, | 151 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, |
| 139 OnDetermineIfPageSupportsInstant) | 152 OnDetermineIfPageSupportsInstant) |
| 140 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults, | 153 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults, |
| 141 OnAutocompleteResults) | 154 OnAutocompleteResults) |
| 142 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed, | 155 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed, |
| 143 OnUpOrDownKeyPressed) | 156 OnUpOrDownKeyPressed) |
| 144 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection, | 157 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection, |
| 145 OnCancelSelection) | 158 OnCancelSelection) |
| 146 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, | 159 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, |
| 147 OnSetDisplayInstantResults) | 160 OnSetDisplayInstantResults) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 231 |
| 219 // Override only the width parameter of the popup bounds. | 232 // Override only the width parameter of the popup bounds. |
| 220 popup_bounds_.set_width(width); | 233 popup_bounds_.set_width(width); |
| 221 | 234 |
| 222 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 235 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 223 extensions_v8::SearchBoxExtension::DispatchMarginChange( | 236 extensions_v8::SearchBoxExtension::DispatchMarginChange( |
| 224 render_view()->GetWebView()->mainFrame()); | 237 render_view()->GetWebView()->mainFrame()); |
| 225 } | 238 } |
| 226 } | 239 } |
| 227 | 240 |
| 241 void SearchBox::OnBarsHidden() { |
| 242 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 243 extensions_v8::SearchBoxExtension::DispatchBarsHidden( |
| 244 render_view()->GetWebView()->mainFrame()); |
| 245 } |
| 246 } |
| 247 |
| 228 void SearchBox::OnDetermineIfPageSupportsInstant() { | 248 void SearchBox::OnDetermineIfPageSupportsInstant() { |
| 229 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 249 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 230 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( | 250 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( |
| 231 render_view()->GetWebView()->mainFrame()); | 251 render_view()->GetWebView()->mainFrame()); |
| 232 DVLOG(1) << render_view() << " PageSupportsInstant: " << result; | 252 DVLOG(1) << render_view() << " PageSupportsInstant: " << result; |
| 233 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( | 253 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( |
| 234 render_view()->GetRoutingID(), render_view()->GetPageId(), result)); | 254 render_view()->GetRoutingID(), render_view()->GetPageId(), result)); |
| 235 } | 255 } |
| 236 } | 256 } |
| 237 | 257 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 368 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 349 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( | 369 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( |
| 350 render_view()->GetWebView()->mainFrame()); | 370 render_view()->GetWebView()->mainFrame()); |
| 351 } | 371 } |
| 352 } | 372 } |
| 353 | 373 |
| 354 const std::vector<InstantMostVisitedItem>& | 374 const std::vector<InstantMostVisitedItem>& |
| 355 SearchBox::GetMostVisitedItems() const { | 375 SearchBox::GetMostVisitedItems() const { |
| 356 return most_visited_items_; | 376 return most_visited_items_; |
| 357 } | 377 } |
| OLD | NEW |