| 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/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/json/string_escape.h" | 8 #include "base/json/string_escape.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/common/autocomplete_match_type.h" | 13 #include "chrome/common/autocomplete_match_type.h" |
| 14 #include "chrome/common/instant_types.h" | 14 #include "chrome/common/instant_types.h" |
| 15 #include "chrome/common/ntp_logging_events.h" | 15 #include "chrome/common/ntp_logging_events.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/renderer/searchbox/searchbox.h" | 17 #include "chrome/renderer/searchbox/searchbox.h" |
| 18 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
| 19 #include "content/public/renderer/render_view.h" | 19 #include "content/public/renderer/render_view.h" |
| 20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 21 #include "grit/renderer_resources.h" | 21 #include "grit/renderer_resources.h" |
| 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 23 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebScriptSource.h" | 25 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 26 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/base/window_open_disposition.h" | 28 #include "ui/base/window_open_disposition.h" |
| 29 #include "ui/events/keycodes/keyboard_codes.h" | 29 #include "ui/events/keycodes/keyboard_codes.h" |
| 30 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 31 #include "v8/include/v8.h" | 31 #include "v8/include/v8.h" |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 obj->Set(v8::String::NewFromUtf8(isolate, "url"), | 139 obj->Set(v8::String::NewFromUtf8(isolate, "url"), |
| 140 UTF8ToV8String(isolate, mv_item.url.spec())); | 140 UTF8ToV8String(isolate, mv_item.url.spec())); |
| 141 return obj; | 141 return obj; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Returns the render view for the current JS context if it matches |origin|, | 144 // Returns the render view for the current JS context if it matches |origin|, |
| 145 // otherwise returns NULL. Used to restrict methods that access suggestions and | 145 // otherwise returns NULL. Used to restrict methods that access suggestions and |
| 146 // most visited data to pages with origin chrome-search://most-visited and | 146 // most visited data to pages with origin chrome-search://most-visited and |
| 147 // chrome-search://suggestions. | 147 // chrome-search://suggestions. |
| 148 content::RenderView* GetRenderViewWithCheckedOrigin(const GURL& origin) { | 148 content::RenderView* GetRenderViewWithCheckedOrigin(const GURL& origin) { |
| 149 blink::WebFrame* webframe = blink::WebFrame::frameForCurrentContext(); | 149 blink::WebLocalFrame* webframe = |
| 150 blink::WebLocalFrame::frameForCurrentContext(); |
| 150 if (!webframe) | 151 if (!webframe) |
| 151 return NULL; | 152 return NULL; |
| 152 blink::WebView* webview = webframe->view(); | 153 blink::WebView* webview = webframe->view(); |
| 153 if (!webview) | 154 if (!webview) |
| 154 return NULL; // Can happen during closing. | 155 return NULL; // Can happen during closing. |
| 155 content::RenderView* render_view = content::RenderView::FromWebView(webview); | 156 content::RenderView* render_view = content::RenderView::FromWebView(webview); |
| 156 if (!render_view) | 157 if (!render_view) |
| 157 return NULL; | 158 return NULL; |
| 158 | 159 |
| 159 GURL url(webframe->document().url()); | 160 GURL url(webframe->document().url()); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 if (name->Equals(v8::String::NewFromUtf8(isolate, "UndoMostVisitedDeletion"))) | 601 if (name->Equals(v8::String::NewFromUtf8(isolate, "UndoMostVisitedDeletion"))) |
| 601 return v8::FunctionTemplate::New(isolate, UndoMostVisitedDeletion); | 602 return v8::FunctionTemplate::New(isolate, UndoMostVisitedDeletion); |
| 602 if (name->Equals( | 603 if (name->Equals( |
| 603 v8::String::NewFromUtf8(isolate, "GetDisplayInstantResults"))) | 604 v8::String::NewFromUtf8(isolate, "GetDisplayInstantResults"))) |
| 604 return v8::FunctionTemplate::New(isolate, GetDisplayInstantResults); | 605 return v8::FunctionTemplate::New(isolate, GetDisplayInstantResults); |
| 605 return v8::Handle<v8::FunctionTemplate>(); | 606 return v8::Handle<v8::FunctionTemplate>(); |
| 606 } | 607 } |
| 607 | 608 |
| 608 // static | 609 // static |
| 609 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() { | 610 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() { |
| 610 blink::WebFrame* webframe = blink::WebFrame::frameForCurrentContext(); | 611 blink::WebLocalFrame* webframe = |
| 612 blink::WebLocalFrame::frameForCurrentContext(); |
| 611 if (!webframe) return NULL; | 613 if (!webframe) return NULL; |
| 612 | 614 |
| 613 blink::WebView* webview = webframe->view(); | 615 blink::WebView* webview = webframe->view(); |
| 614 if (!webview) return NULL; // can happen during closing | 616 if (!webview) return NULL; // can happen during closing |
| 615 | 617 |
| 616 return content::RenderView::FromWebView(webview); | 618 return content::RenderView::FromWebView(webview); |
| 617 } | 619 } |
| 618 | 620 |
| 619 // static | 621 // static |
| 620 void SearchBoxExtensionWrapper::CheckIsUserSignedInToChromeAs( | 622 void SearchBoxExtensionWrapper::CheckIsUserSignedInToChromeAs( |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 if (!render_view) return; | 1119 if (!render_view) return; |
| 1118 | 1120 |
| 1119 bool display_instant_results = | 1121 bool display_instant_results = |
| 1120 SearchBox::Get(render_view)->display_instant_results(); | 1122 SearchBox::Get(render_view)->display_instant_results(); |
| 1121 DVLOG(1) << render_view << " GetDisplayInstantResults" << | 1123 DVLOG(1) << render_view << " GetDisplayInstantResults" << |
| 1122 display_instant_results; | 1124 display_instant_results; |
| 1123 args.GetReturnValue().Set(display_instant_results); | 1125 args.GetReturnValue().Set(display_instant_results); |
| 1124 } | 1126 } |
| 1125 | 1127 |
| 1126 } // namespace extensions_v8 | 1128 } // namespace extensions_v8 |
| OLD | NEW |