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" |
11 #include "content/public/renderer/render_view.h" | 11 #include "content/public/renderer/render_view.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
Shishir
2013/03/20 21:35:52
Dont need this.
dhollowa
2013/03/20 22:15:08
Done.
| |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
14 | 14 |
15 SearchBox::SearchBox(content::RenderView* render_view) | 15 SearchBox::SearchBox(content::RenderView* render_view) |
16 : content::RenderViewObserver(render_view), | 16 : content::RenderViewObserver(render_view), |
17 content::RenderViewObserverTracker<SearchBox>(render_view), | 17 content::RenderViewObserverTracker<SearchBox>(render_view), |
18 verbatim_(false), | 18 verbatim_(false), |
19 selection_start_(0), | 19 selection_start_(0), |
20 selection_end_(0), | 20 selection_end_(0), |
21 results_base_(0), | 21 results_base_(0), |
22 start_margin_(0), | 22 start_margin_(0), |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection, | 157 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection, |
158 OnCancelSelection) | 158 OnCancelSelection) |
159 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, | 159 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, |
160 OnSetDisplayInstantResults) | 160 OnSetDisplayInstantResults) |
161 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged, | 161 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxKeyCaptureChanged, |
162 OnKeyCaptureChange) | 162 OnKeyCaptureChange) |
163 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, | 163 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, |
164 OnThemeChanged) | 164 OnThemeChanged) |
165 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation, | 165 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation, |
166 OnFontInformationReceived) | 166 OnFontInformationReceived) |
167 IPC_MESSAGE_HANDLER( | |
168 ChromeViewMsg_SearchBoxGrantChromeSearchAccessFromOrigin, | |
169 OnGrantChromeSearchAccessFromOrigin) | |
170 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged, | 167 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged, |
171 OnMostVisitedChanged) | 168 OnMostVisitedChanged) |
172 IPC_MESSAGE_UNHANDLED(handled = false) | 169 IPC_MESSAGE_UNHANDLED(handled = false) |
173 IPC_END_MESSAGE_MAP() | 170 IPC_END_MESSAGE_MAP() |
174 return handled; | 171 return handled; |
175 } | 172 } |
176 | 173 |
177 void SearchBox::DidClearWindowObject(WebKit::WebFrame* frame) { | 174 void SearchBox::DidClearWindowObject(WebKit::WebFrame* frame) { |
178 extensions_v8::SearchBoxExtension::DispatchOnWindowReady(frame); | 175 extensions_v8::SearchBoxExtension::DispatchOnWindowReady(frame); |
179 } | 176 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 render_view()->GetWebView()->mainFrame()); | 304 render_view()->GetWebView()->mainFrame()); |
308 } | 305 } |
309 } | 306 } |
310 | 307 |
311 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, | 308 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, |
312 size_t omnibox_font_size) { | 309 size_t omnibox_font_size) { |
313 omnibox_font_ = omnibox_font; | 310 omnibox_font_ = omnibox_font; |
314 omnibox_font_size_ = omnibox_font_size; | 311 omnibox_font_size_ = omnibox_font_size; |
315 } | 312 } |
316 | 313 |
317 void SearchBox::OnGrantChromeSearchAccessFromOrigin(const GURL& origin_url) { | |
318 string16 chrome_search_scheme(ASCIIToUTF16(chrome::kChromeSearchScheme)); | |
319 WebKit::WebSecurityPolicy::addOriginAccessWhitelistEntry( | |
320 origin_url, | |
321 chrome_search_scheme, | |
322 ASCIIToUTF16(chrome::kChromeUIFaviconHost), | |
323 false); | |
324 WebKit::WebSecurityPolicy::addOriginAccessWhitelistEntry( | |
325 origin_url, | |
326 chrome_search_scheme, | |
327 ASCIIToUTF16(chrome::kChromeUIThemeHost), | |
328 false); | |
329 WebKit::WebSecurityPolicy::addOriginAccessWhitelistEntry( | |
330 origin_url, | |
331 chrome_search_scheme, | |
332 ASCIIToUTF16(chrome::kChromeUIThumbnailHost), | |
333 false); | |
334 } | |
335 | |
336 double SearchBox::GetZoom() const { | 314 double SearchBox::GetZoom() const { |
337 WebKit::WebView* web_view = render_view()->GetWebView(); | 315 WebKit::WebView* web_view = render_view()->GetWebView(); |
338 if (web_view) { | 316 if (web_view) { |
339 double zoom = WebKit::WebView::zoomLevelToZoomFactor(web_view->zoomLevel()); | 317 double zoom = WebKit::WebView::zoomLevelToZoomFactor(web_view->zoomLevel()); |
340 if (zoom != 0) | 318 if (zoom != 0) |
341 return zoom; | 319 return zoom; |
342 } | 320 } |
343 return 1.0; | 321 return 1.0; |
344 } | 322 } |
345 | 323 |
(...skipping 22 matching lines...) Expand all Loading... | |
368 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 346 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
369 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( | 347 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( |
370 render_view()->GetWebView()->mainFrame()); | 348 render_view()->GetWebView()->mainFrame()); |
371 } | 349 } |
372 } | 350 } |
373 | 351 |
374 const std::vector<InstantMostVisitedItem>& | 352 const std::vector<InstantMostVisitedItem>& |
375 SearchBox::GetMostVisitedItems() const { | 353 SearchBox::GetMostVisitedItems() const { |
376 return most_visited_items_; | 354 return most_visited_items_; |
377 } | 355 } |
OLD | NEW |