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

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

Issue 2086223002: Convert instant search messages to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 2 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/instant.mojom.h"
19 #include "chrome/common/render_messages.h" 20 #include "chrome/common/render_messages.h"
20 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
21 #include "chrome/renderer/searchbox/searchbox_extension.h" 22 #include "chrome/renderer/searchbox/searchbox_extension.h"
22 #include "components/favicon_base/fallback_icon_url_parser.h" 23 #include "components/favicon_base/fallback_icon_url_parser.h"
23 #include "components/favicon_base/favicon_types.h" 24 #include "components/favicon_base/favicon_types.h"
24 #include "components/favicon_base/favicon_url_parser.h" 25 #include "components/favicon_base/favicon_url_parser.h"
25 #include "components/favicon_base/large_icon_url_parser.h" 26 #include "components/favicon_base/large_icon_url_parser.h"
26 #include "components/omnibox/common/omnibox_focus_state.h" 27 #include "components/omnibox/common/omnibox_focus_state.h"
28 #include "content/public/common/associated_interface_provider.h"
29 #include "content/public/common/associated_interface_registry.h"
27 #include "content/public/renderer/render_frame.h" 30 #include "content/public/renderer/render_frame.h"
28 #include "content/public/renderer/render_view.h" 31 #include "content/public/renderer/render_view.h"
29 #include "net/base/escape.h" 32 #include "net/base/escape.h"
30 #include "third_party/WebKit/public/web/WebDocument.h" 33 #include "third_party/WebKit/public/web/WebDocument.h"
31 #include "third_party/WebKit/public/web/WebFrame.h" 34 #include "third_party/WebKit/public/web/WebFrame.h"
32 #include "third_party/WebKit/public/web/WebLocalFrame.h" 35 #include "third_party/WebKit/public/web/WebLocalFrame.h"
33 #include "third_party/WebKit/public/web/WebPerformance.h" 36 #include "third_party/WebKit/public/web/WebPerformance.h"
34 #include "third_party/WebKit/public/web/WebView.h" 37 #include "third_party/WebKit/public/web/WebView.h"
35 #include "url/gurl.h" 38 #include "url/gurl.h"
36 39
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 230
228 SearchBox::IconURLHelper::IconURLHelper() { 231 SearchBox::IconURLHelper::IconURLHelper() {
229 } 232 }
230 233
231 SearchBox::IconURLHelper::~IconURLHelper() { 234 SearchBox::IconURLHelper::~IconURLHelper() {
232 } 235 }
233 236
234 SearchBox::SearchBox(content::RenderView* render_view) 237 SearchBox::SearchBox(content::RenderView* render_view)
235 : content::RenderViewObserver(render_view), 238 : content::RenderViewObserver(render_view),
236 content::RenderViewObserverTracker<SearchBox>(render_view), 239 content::RenderViewObserverTracker<SearchBox>(render_view),
237 page_seq_no_(0), 240 page_seq_no_(0),
238 is_focused_(false), 241 is_focused_(false),
239 is_input_in_progress_(false), 242 is_input_in_progress_(false),
240 is_key_capture_enabled_(false), 243 is_key_capture_enabled_(false),
241 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), 244 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize),
242 query_() { 245 query_(),
246 binding_(this) {
247 render_view->GetMainRenderFrame()
248 ->GetRemoteAssociatedInterfaces()
249 ->GetInterface(&instant_service_);
250 render_view->GetMainRenderFrame()
251 ->GetAssociatedInterfaceRegistry()
252 ->AddInterface(base::Bind(&SearchBox::Bind, base::Unretained(this)));
243 } 253 }
244 254
245 SearchBox::~SearchBox() { 255 SearchBox::~SearchBox() {
246 } 256 }
247 257
248 void SearchBox::LogEvent(NTPLoggingEventType event) { 258 void SearchBox::LogEvent(NTPLoggingEventType event) {
249 // The main frame for the current RenderView may be out-of-process, in which 259 // The main frame for the current RenderView may be out-of-process, in which
250 // case it won't have performance(). Use the default delta of 0 in this 260 // case it won't have performance(). Use the default delta of 0 in this
251 // case. 261 // case.
252 base::TimeDelta delta; 262 base::TimeDelta delta;
253 if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame()) { 263 if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame()) {
254 // navigation_start in ms. 264 // navigation_start in ms.
255 uint64_t start = 1000 * (render_view() 265 uint64_t start = 1000 * (render_view()
256 ->GetMainRenderFrame() 266 ->GetMainRenderFrame()
257 ->GetWebFrame() 267 ->GetWebFrame()
258 ->performance() 268 ->performance()
259 .navigationStart()); 269 .navigationStart());
260 uint64_t now = (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()) 270 uint64_t now = (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch())
261 .InMilliseconds(); 271 .InMilliseconds();
262 DCHECK(now >= start); 272 DCHECK(now >= start);
263 delta = base::TimeDelta::FromMilliseconds(now - start); 273 delta = base::TimeDelta::FromMilliseconds(now - start);
264 } 274 }
265 render_view()->Send(new ChromeViewHostMsg_LogEvent( 275 instant_service_->LogEvent(page_seq_no_, event, delta);
266 render_view()->GetRoutingID(), page_seq_no_, event, delta));
267 } 276 }
268 277
269 void SearchBox::LogMostVisitedImpression(int position, 278 void SearchBox::LogMostVisitedImpression(int position,
270 NTPLoggingTileSource tile_source) { 279 NTPLoggingTileSource tile_source) {
271 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( 280 instant_service_->LogMostVisitedImpression(page_seq_no_, position,
272 render_view()->GetRoutingID(), page_seq_no_, position, tile_source)); 281 tile_source);
273 } 282 }
274 283
275 void SearchBox::LogMostVisitedNavigation(int position, 284 void SearchBox::LogMostVisitedNavigation(int position,
276 NTPLoggingTileSource tile_source) { 285 NTPLoggingTileSource tile_source) {
277 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedNavigation( 286 instant_service_->LogMostVisitedNavigation(page_seq_no_, position,
278 render_view()->GetRoutingID(), page_seq_no_, position, tile_source)); 287 tile_source);
279 } 288 }
280 289
281 void SearchBox::CheckIsUserSignedInToChromeAs(const base::string16& identity) { 290 void SearchBox::CheckIsUserSignedInToChromeAs(const base::string16& identity) {
282 render_view()->Send(new ChromeViewHostMsg_ChromeIdentityCheck( 291 instant_service_->ChromeIdentityCheck(page_seq_no_, identity);
283 render_view()->GetRoutingID(), page_seq_no_, identity));
284 } 292 }
285 293
286 void SearchBox::CheckIsUserSyncingHistory() { 294 void SearchBox::CheckIsUserSyncingHistory() {
287 render_view()->Send(new ChromeViewHostMsg_HistorySyncCheck( 295 instant_service_->HistorySyncCheck(page_seq_no_);
288 render_view()->GetRoutingID(), page_seq_no_));
289 } 296 }
290 297
291 void SearchBox::DeleteMostVisitedItem( 298 void SearchBox::DeleteMostVisitedItem(
292 InstantRestrictedID most_visited_item_id) { 299 InstantRestrictedID most_visited_item_id) {
293 render_view()->Send(new ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem( 300 instant_service_->SearchBoxDeleteMostVisitedItem(
294 render_view()->GetRoutingID(), 301 page_seq_no_, GetURLForMostVisitedItem(most_visited_item_id));
295 page_seq_no_,
296 GetURLForMostVisitedItem(most_visited_item_id)));
297 } 302 }
298 303
299 bool SearchBox::GenerateImageURLFromTransientURL(const GURL& transient_url, 304 bool SearchBox::GenerateImageURLFromTransientURL(const GURL& transient_url,
300 ImageSourceType type, 305 ImageSourceType type,
301 GURL* url) const { 306 GURL* url) const {
302 SearchBoxIconURLHelper helper(this); 307 SearchBoxIconURLHelper helper(this);
303 return internal::TranslateIconRestrictedUrl(transient_url, type, helper, url); 308 return internal::TranslateIconRestrictedUrl(transient_url, type, helper, url);
304 } 309 }
305 310
306 void SearchBox::GetMostVisitedItems( 311 void SearchBox::GetMostVisitedItems(
(...skipping 10 matching lines...) Expand all
317 322
318 const ThemeBackgroundInfo& SearchBox::GetThemeBackgroundInfo() { 323 const ThemeBackgroundInfo& SearchBox::GetThemeBackgroundInfo() {
319 return theme_info_; 324 return theme_info_;
320 } 325 }
321 326
322 const EmbeddedSearchRequestParams& SearchBox::GetEmbeddedSearchRequestParams() { 327 const EmbeddedSearchRequestParams& SearchBox::GetEmbeddedSearchRequestParams() {
323 return embedded_search_request_params_; 328 return embedded_search_request_params_;
324 } 329 }
325 330
326 void SearchBox::Paste(const base::string16& text) { 331 void SearchBox::Paste(const base::string16& text) {
327 render_view()->Send(new ChromeViewHostMsg_PasteAndOpenDropdown( 332 instant_service_->PasteAndOpenDropdown(page_seq_no_, text);
328 render_view()->GetRoutingID(), page_seq_no_, text));
329 } 333 }
330 334
331 void SearchBox::StartCapturingKeyStrokes() { 335 void SearchBox::StartCapturingKeyStrokes() {
332 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox( 336 instant_service_->FocusOmnibox(page_seq_no_, OMNIBOX_FOCUS_INVISIBLE);
333 render_view()->GetRoutingID(), page_seq_no_, OMNIBOX_FOCUS_INVISIBLE));
334 } 337 }
335 338
336 void SearchBox::StopCapturingKeyStrokes() { 339 void SearchBox::StopCapturingKeyStrokes() {
337 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox( 340 instant_service_->FocusOmnibox(page_seq_no_, OMNIBOX_FOCUS_NONE);
338 render_view()->GetRoutingID(), page_seq_no_, OMNIBOX_FOCUS_NONE));
339 } 341 }
340 342
341 void SearchBox::UndoAllMostVisitedDeletions() { 343 void SearchBox::UndoAllMostVisitedDeletions() {
342 render_view()->Send( 344 instant_service_->SearchBoxUndoAllMostVisitedDeletions(page_seq_no_);
343 new ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
344 render_view()->GetRoutingID(), page_seq_no_));
345 } 345 }
346 346
347 void SearchBox::UndoMostVisitedDeletion( 347 void SearchBox::UndoMostVisitedDeletion(
348 InstantRestrictedID most_visited_item_id) { 348 InstantRestrictedID most_visited_item_id) {
349 render_view()->Send(new ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion( 349 instant_service_->SearchBoxUndoMostVisitedDeletion(
350 render_view()->GetRoutingID(), page_seq_no_, 350 page_seq_no_, GetURLForMostVisitedItem(most_visited_item_id));
351 GetURLForMostVisitedItem(most_visited_item_id)));
352 } 351 }
353 352
354 bool SearchBox::OnMessageReceived(const IPC::Message& message) { 353 void SearchBox::SetPageSequenceNumber(int page_seq_no) {
355 bool handled = true;
356 IPC_BEGIN_MESSAGE_MAP(SearchBox, message)
357 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetPageSequenceNumber,
358 OnSetPageSequenceNumber)
359 IPC_MESSAGE_HANDLER(ChromeViewMsg_ChromeIdentityCheckResult,
360 OnChromeIdentityCheckResult)
361 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant,
362 OnDetermineIfPageSupportsInstant)
363 IPC_MESSAGE_HANDLER(ChromeViewMsg_HistorySyncCheckResult,
364 OnHistorySyncCheckResult)
365 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFocusChanged, OnFocusChanged)
366 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged,
367 OnMostVisitedChanged)
368 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetInputInProgress,
369 OnSetInputInProgress)
370 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetSuggestionToPrefetch,
371 OnSetSuggestionToPrefetch)
372 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit)
373 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged,
374 OnThemeChanged)
375 IPC_MESSAGE_UNHANDLED(handled = false)
376 IPC_END_MESSAGE_MAP()
377 return handled;
378 }
379
380 void SearchBox::OnSetPageSequenceNumber(int page_seq_no) {
381 page_seq_no_ = page_seq_no; 354 page_seq_no_ = page_seq_no;
382 } 355 }
383 356
384 void SearchBox::OnChromeIdentityCheckResult(const base::string16& identity, 357 void SearchBox::ChromeIdentityCheckResult(const base::string16& identity,
385 bool identity_match) { 358 bool identity_match) {
386 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 359 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
387 extensions_v8::SearchBoxExtension::DispatchChromeIdentityCheckResult( 360 extensions_v8::SearchBoxExtension::DispatchChromeIdentityCheckResult(
388 render_view()->GetWebView()->mainFrame(), identity, identity_match); 361 render_view()->GetWebView()->mainFrame(), identity, identity_match);
389 } 362 }
390 } 363 }
391 364
392 void SearchBox::OnDetermineIfPageSupportsInstant() { 365 void SearchBox::DetermineIfPageSupportsInstant() {
393 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 366 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
394 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( 367 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant(
395 render_view()->GetWebView()->mainFrame()); 368 render_view()->GetWebView()->mainFrame());
396 DVLOG(1) << render_view() << " PageSupportsInstant: " << result; 369 DVLOG(1) << render_view() << " PageSupportsInstant: " << result;
397 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( 370 instant_service_->InstantSupportDetermined(page_seq_no_, result);
398 render_view()->GetRoutingID(), page_seq_no_, result));
399 } 371 }
400 } 372 }
401 373
402 void SearchBox::OnFocusChanged(OmniboxFocusState new_focus_state, 374 void SearchBox::FocusChanged(OmniboxFocusState new_focus_state,
403 OmniboxFocusChangeReason reason) { 375 OmniboxFocusChangeReason reason) {
404 bool key_capture_enabled = new_focus_state == OMNIBOX_FOCUS_INVISIBLE; 376 bool key_capture_enabled = new_focus_state == OMNIBOX_FOCUS_INVISIBLE;
405 if (key_capture_enabled != is_key_capture_enabled_) { 377 if (key_capture_enabled != is_key_capture_enabled_) {
406 // Tell the page if the key capture mode changed unless the focus state 378 // Tell the page if the key capture mode changed unless the focus state
407 // changed because of TYPING. This is because in that case, the browser 379 // changed because of TYPING. This is because in that case, the browser
408 // hasn't really stopped capturing key strokes. 380 // hasn't really stopped capturing key strokes.
409 // 381 //
410 // (More practically, if we don't do this check, the page would receive 382 // (More practically, if we don't do this check, the page would receive
411 // onkeycapturechange before the corresponding onchange, and the page would 383 // onkeycapturechange before the corresponding onchange, and the page would
412 // have no way of telling whether the keycapturechange happened because of 384 // have no way of telling whether the keycapturechange happened because of
413 // some actual user action or just because they started typing.) 385 // some actual user action or just because they started typing.)
414 if (reason != OMNIBOX_FOCUS_CHANGE_TYPING && 386 if (reason != OMNIBOX_FOCUS_CHANGE_TYPING &&
415 render_view()->GetWebView() && 387 render_view()->GetWebView() &&
416 render_view()->GetWebView()->mainFrame()) { 388 render_view()->GetWebView()->mainFrame()) {
417 is_key_capture_enabled_ = key_capture_enabled; 389 is_key_capture_enabled_ = key_capture_enabled;
418 DVLOG(1) << render_view() << " OnKeyCaptureChange"; 390 DVLOG(1) << render_view() << " KeyCaptureChange";
419 extensions_v8::SearchBoxExtension::DispatchKeyCaptureChange( 391 extensions_v8::SearchBoxExtension::DispatchKeyCaptureChange(
420 render_view()->GetWebView()->mainFrame()); 392 render_view()->GetWebView()->mainFrame());
421 } 393 }
422 } 394 }
423 bool is_focused = new_focus_state == OMNIBOX_FOCUS_VISIBLE; 395 bool is_focused = new_focus_state == OMNIBOX_FOCUS_VISIBLE;
424 if (is_focused != is_focused_) { 396 if (is_focused != is_focused_) {
425 is_focused_ = is_focused; 397 is_focused_ = is_focused;
426 DVLOG(1) << render_view() << " OnFocusChange"; 398 DVLOG(1) << render_view() << " FocusChange";
427 if (render_view()->GetWebView() && 399 if (render_view()->GetWebView() &&
428 render_view()->GetWebView()->mainFrame()) { 400 render_view()->GetWebView()->mainFrame()) {
429 extensions_v8::SearchBoxExtension::DispatchFocusChange( 401 extensions_v8::SearchBoxExtension::DispatchFocusChange(
430 render_view()->GetWebView()->mainFrame()); 402 render_view()->GetWebView()->mainFrame());
431 } 403 }
432 } 404 }
433 } 405 }
434 406
435 void SearchBox::OnHistorySyncCheckResult(bool sync_history) { 407 void SearchBox::HistorySyncCheckResult(bool sync_history) {
436 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 408 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
437 extensions_v8::SearchBoxExtension::DispatchHistorySyncCheckResult( 409 extensions_v8::SearchBoxExtension::DispatchHistorySyncCheckResult(
438 render_view()->GetWebView()->mainFrame(), sync_history); 410 render_view()->GetWebView()->mainFrame(), sync_history);
439 } 411 }
440 } 412 }
441 413
442 void SearchBox::OnMostVisitedChanged( 414 void SearchBox::MostVisitedChanged(
443 const std::vector<InstantMostVisitedItem>& items) { 415 const std::vector<InstantMostVisitedItem>& items) {
444 std::vector<InstantMostVisitedItemIDPair> last_known_items; 416 std::vector<InstantMostVisitedItemIDPair> last_known_items;
445 GetMostVisitedItems(&last_known_items); 417 GetMostVisitedItems(&last_known_items);
446 418
447 if (AreMostVisitedItemsEqual(last_known_items, items)) 419 if (AreMostVisitedItemsEqual(last_known_items, items))
448 return; // Do not send duplicate onmostvisitedchange events. 420 return; // Do not send duplicate onmostvisitedchange events.
449 421
450 most_visited_items_cache_.AddItems(items); 422 most_visited_items_cache_.AddItems(items);
451 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 423 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
452 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( 424 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged(
453 render_view()->GetWebView()->mainFrame()); 425 render_view()->GetWebView()->mainFrame());
454 } 426 }
455 } 427 }
456 428
457 void SearchBox::OnSetInputInProgress(bool is_input_in_progress) { 429 void SearchBox::SetInputInProgress(bool is_input_in_progress) {
458 if (is_input_in_progress_ != is_input_in_progress) { 430 if (is_input_in_progress_ != is_input_in_progress) {
459 is_input_in_progress_ = is_input_in_progress; 431 is_input_in_progress_ = is_input_in_progress;
460 DVLOG(1) << render_view() << " OnSetInputInProgress"; 432 DVLOG(1) << render_view() << " SetInputInProgress";
461 if (render_view()->GetWebView() && 433 if (render_view()->GetWebView() &&
462 render_view()->GetWebView()->mainFrame()) { 434 render_view()->GetWebView()->mainFrame()) {
463 if (is_input_in_progress_) { 435 if (is_input_in_progress_) {
464 extensions_v8::SearchBoxExtension::DispatchInputStart( 436 extensions_v8::SearchBoxExtension::DispatchInputStart(
465 render_view()->GetWebView()->mainFrame()); 437 render_view()->GetWebView()->mainFrame());
466 } else { 438 } else {
467 extensions_v8::SearchBoxExtension::DispatchInputCancel( 439 extensions_v8::SearchBoxExtension::DispatchInputCancel(
468 render_view()->GetWebView()->mainFrame()); 440 render_view()->GetWebView()->mainFrame());
469 } 441 }
470 } 442 }
471 } 443 }
472 } 444 }
473 445
474 void SearchBox::OnSetSuggestionToPrefetch(const InstantSuggestion& suggestion) { 446 void SearchBox::SetSuggestionToPrefetch(const InstantSuggestion& suggestion) {
475 suggestion_ = suggestion; 447 suggestion_ = suggestion;
476 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 448 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
477 DVLOG(1) << render_view() << " OnSetSuggestionToPrefetch"; 449 DVLOG(1) << render_view() << " SetSuggestionToPrefetch";
478 extensions_v8::SearchBoxExtension::DispatchSuggestionChange( 450 extensions_v8::SearchBoxExtension::DispatchSuggestionChange(
479 render_view()->GetWebView()->mainFrame()); 451 render_view()->GetWebView()->mainFrame());
480 } 452 }
481 } 453 }
482 454
483 void SearchBox::OnSubmit(const base::string16& query, 455 void SearchBox::Submit(const base::string16& query,
484 const EmbeddedSearchRequestParams& params) { 456 const EmbeddedSearchRequestParams& params) {
485 query_ = query; 457 query_ = query;
486 embedded_search_request_params_ = params; 458 embedded_search_request_params_ = params;
487 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 459 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
488 DVLOG(1) << render_view() << " OnSubmit"; 460 DVLOG(1) << render_view() << " Submit";
489 extensions_v8::SearchBoxExtension::DispatchSubmit( 461 extensions_v8::SearchBoxExtension::DispatchSubmit(
490 render_view()->GetWebView()->mainFrame()); 462 render_view()->GetWebView()->mainFrame());
491 } 463 }
492 if (!query.empty()) 464 if (!query.empty())
493 Reset(); 465 Reset();
494 } 466 }
495 467
496 void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) { 468 void SearchBox::ThemeChanged(const ThemeBackgroundInfo& theme_info) {
497 // Do not send duplicate notifications. 469 // Do not send duplicate notifications.
498 if (theme_info_ == theme_info) 470 if (theme_info_ == theme_info)
499 return; 471 return;
500 472
501 theme_info_ = theme_info; 473 theme_info_ = theme_info;
502 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 474 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
503 extensions_v8::SearchBoxExtension::DispatchThemeChange( 475 extensions_v8::SearchBoxExtension::DispatchThemeChange(
504 render_view()->GetWebView()->mainFrame()); 476 render_view()->GetWebView()->mainFrame());
505 } 477 }
506 } 478 }
507 479
508 GURL SearchBox::GetURLForMostVisitedItem(InstantRestrictedID item_id) const { 480 GURL SearchBox::GetURLForMostVisitedItem(InstantRestrictedID item_id) const {
509 InstantMostVisitedItem item; 481 InstantMostVisitedItem item;
510 return GetMostVisitedItemWithID(item_id, &item) ? item.url : GURL(); 482 return GetMostVisitedItemWithID(item_id, &item) ? item.url : GURL();
511 } 483 }
512 484
485 void SearchBox::Bind(chrome::mojom::SearchBoxAssociatedRequest request) {
486 binding_.Bind(std::move(request));
487 }
488
513 void SearchBox::Reset() { 489 void SearchBox::Reset() {
514 query_.clear(); 490 query_.clear();
515 embedded_search_request_params_ = EmbeddedSearchRequestParams(); 491 embedded_search_request_params_ = EmbeddedSearchRequestParams();
516 suggestion_ = InstantSuggestion(); 492 suggestion_ = InstantSuggestion();
517 is_focused_ = false; 493 is_focused_ = false;
518 is_key_capture_enabled_ = false; 494 is_key_capture_enabled_ = false;
519 theme_info_ = ThemeBackgroundInfo(); 495 theme_info_ = ThemeBackgroundInfo();
520 } 496 }
521 497
522 void SearchBox::OnDestruct() { 498 void SearchBox::OnDestruct() {
523 delete this; 499 delete this;
524 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698