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

Side by Side Diff: chrome/renderer/searchbox/searchbox.cc

Issue 14646034: Add onfocuschange to the Extended Search API, with associated isFocused attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 unified diff | Download patch
OLDNEW
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/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/omnibox_focus_state.h" 10 #include "chrome/common/omnibox_focus_state.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 : content::RenderViewObserver(render_view), 60 : content::RenderViewObserver(render_view),
61 content::RenderViewObserverTracker<SearchBox>(render_view), 61 content::RenderViewObserverTracker<SearchBox>(render_view),
62 verbatim_(false), 62 verbatim_(false),
63 query_is_restricted_(false), 63 query_is_restricted_(false),
64 selection_start_(0), 64 selection_start_(0),
65 selection_end_(0), 65 selection_end_(0),
66 start_margin_(0), 66 start_margin_(0),
67 is_key_capture_enabled_(false), 67 is_key_capture_enabled_(false),
68 display_instant_results_(false), 68 display_instant_results_(false),
69 omnibox_font_size_(0), 69 omnibox_font_size_(0),
70 is_focused_(false),
70 autocomplete_results_cache_(kMaxInstantAutocompleteResultItemCacheSize), 71 autocomplete_results_cache_(kMaxInstantAutocompleteResultItemCacheSize),
71 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize) { 72 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize) {
72 } 73 }
73 74
74 SearchBox::~SearchBox() { 75 SearchBox::~SearchBox() {
75 } 76 }
76 77
77 void SearchBox::SetSuggestions( 78 void SearchBox::SetSuggestions(
78 const std::vector<InstantSuggestion>& suggestions) { 79 const std::vector<InstantSuggestion>& suggestions) {
79 if (!suggestions.empty() && 80 if (!suggestions.empty() &&
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, 203 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults,
203 OnSetDisplayInstantResults) 204 OnSetDisplayInstantResults)
204 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged, 205 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged,
205 OnKeyCaptureChange) 206 OnKeyCaptureChange)
206 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, 207 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged,
207 OnThemeChanged) 208 OnThemeChanged)
208 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation, 209 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation,
209 OnFontInformationReceived) 210 OnFontInformationReceived)
210 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged, 211 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged,
211 OnMostVisitedChanged) 212 OnMostVisitedChanged)
213 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFocusChanged,
214 OnFocusChanged)
212 IPC_MESSAGE_UNHANDLED(handled = false) 215 IPC_MESSAGE_UNHANDLED(handled = false)
213 IPC_END_MESSAGE_MAP() 216 IPC_END_MESSAGE_MAP()
214 return handled; 217 return handled;
215 } 218 }
216 219
217 void SearchBox::DidClearWindowObject(WebKit::WebFrame* frame) { 220 void SearchBox::DidClearWindowObject(WebKit::WebFrame* frame) {
218 extensions_v8::SearchBoxExtension::DispatchOnWindowReady(frame); 221 extensions_v8::SearchBoxExtension::DispatchOnWindowReady(frame);
219 } 222 }
220 223
221 void SearchBox::OnChange(const string16& query, 224 void SearchBox::OnChange(const string16& query,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 std::vector<InstantMostVisitedItemIDPair>* items) const { 438 std::vector<InstantMostVisitedItemIDPair>* items) const {
436 return most_visited_items_cache_.GetCurrentItems(items); 439 return most_visited_items_cache_.GetCurrentItems(items);
437 } 440 }
438 441
439 bool SearchBox::GetMostVisitedItemWithID( 442 bool SearchBox::GetMostVisitedItemWithID(
440 InstantRestrictedID most_visited_item_id, 443 InstantRestrictedID most_visited_item_id,
441 InstantMostVisitedItem* item) const { 444 InstantMostVisitedItem* item) const {
442 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id, 445 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id,
443 item); 446 item);
444 } 447 }
448
449 void SearchBox::OnFocusChanged(bool is_focused) {
450 is_focused_ = is_focused;
451 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
452 extensions_v8::SearchBoxExtension::DispatchFocusChange(
453 render_view()->GetWebView()->mainFrame());
454 }
455 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698