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_extension.h" | 5 #include "chrome/renderer/searchbox/searchbox_extension.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/renderer/searchbox/searchbox.h" | 10 #include "chrome/renderer/searchbox/searchbox.h" |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 if (args[0]->IsNumber()) { | 587 if (args[0]->IsNumber()) { |
588 const InstantAutocompleteResult* result = SearchBox::Get(render_view)-> | 588 const InstantAutocompleteResult* result = SearchBox::Get(render_view)-> |
589 GetAutocompleteResultWithId(args[0]->Uint32Value()); | 589 GetAutocompleteResultWithId(args[0]->Uint32Value()); |
590 if (result) | 590 if (result) |
591 destination_url = GURL(result->destination_url); | 591 destination_url = GURL(result->destination_url); |
592 } else { | 592 } else { |
593 destination_url = GURL(V8ValueToUTF16(args[0])); | 593 destination_url = GURL(V8ValueToUTF16(args[0])); |
594 } | 594 } |
595 | 595 |
596 // Navigate the main frame. | 596 // Navigate the main frame. |
597 if (destination_url.is_valid()) { | 597 if (destination_url.is_valid()) |
598 WebKit::WebURLRequest request(destination_url); | 598 SearchBox::Get(render_view)->NavigateToURL(destination_url); |
599 render_view->GetWebView()->mainFrame()->loadRequest(request); | |
600 } | |
601 | 599 |
602 return v8::Undefined(); | 600 return v8::Undefined(); |
603 } | 601 } |
604 | 602 |
605 // static | 603 // static |
606 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestions( | 604 v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestions( |
607 const v8::Arguments& args) { | 605 const v8::Arguments& args) { |
608 content::RenderView* render_view = GetRenderView(); | 606 content::RenderView* render_view = GetRenderView(); |
609 if (!render_view || !args.Length()) return v8::Undefined(); | 607 if (!render_view || !args.Length()) return v8::Undefined(); |
610 | 608 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript); | 843 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript); |
846 } | 844 } |
847 | 845 |
848 // static | 846 // static |
849 v8::Extension* SearchBoxExtension::Get() { | 847 v8::Extension* SearchBoxExtension::Get() { |
850 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). | 848 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). |
851 GetRawDataResource(IDR_SEARCHBOX_API)); | 849 GetRawDataResource(IDR_SEARCHBOX_API)); |
852 } | 850 } |
853 | 851 |
854 } // namespace extensions_v8 | 852 } // namespace extensions_v8 |
OLD | NEW |