OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/ui/omnibox/chrome_omnibox_client.h" | 5 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 16 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 17 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
17 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" | 18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/bookmark_stats.h" | 20 #include "chrome/browser/bookmarks/bookmark_stats.h" |
20 #include "chrome/browser/command_updater.h" | 21 #include "chrome/browser/command_updater.h" |
21 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 22 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 scheme_classifier_(profile), | 127 scheme_classifier_(profile), |
127 request_id_(BitmapFetcherService::REQUEST_ID_INVALID) {} | 128 request_id_(BitmapFetcherService::REQUEST_ID_INVALID) {} |
128 | 129 |
129 ChromeOmniboxClient::~ChromeOmniboxClient() { | 130 ChromeOmniboxClient::~ChromeOmniboxClient() { |
130 BitmapFetcherService* image_service = | 131 BitmapFetcherService* image_service = |
131 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); | 132 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); |
132 if (image_service) | 133 if (image_service) |
133 image_service->CancelRequest(request_id_); | 134 image_service->CancelRequest(request_id_); |
134 } | 135 } |
135 | 136 |
136 scoped_ptr<AutocompleteProviderClient> | 137 std::unique_ptr<AutocompleteProviderClient> |
137 ChromeOmniboxClient::CreateAutocompleteProviderClient() { | 138 ChromeOmniboxClient::CreateAutocompleteProviderClient() { |
138 return make_scoped_ptr(new ChromeAutocompleteProviderClient(profile_)); | 139 return base::WrapUnique(new ChromeAutocompleteProviderClient(profile_)); |
139 } | 140 } |
140 | 141 |
141 scoped_ptr<OmniboxNavigationObserver> | 142 std::unique_ptr<OmniboxNavigationObserver> |
142 ChromeOmniboxClient::CreateOmniboxNavigationObserver( | 143 ChromeOmniboxClient::CreateOmniboxNavigationObserver( |
143 const base::string16& text, | 144 const base::string16& text, |
144 const AutocompleteMatch& match, | 145 const AutocompleteMatch& match, |
145 const AutocompleteMatch& alternate_nav_match) { | 146 const AutocompleteMatch& alternate_nav_match) { |
146 return make_scoped_ptr(new ChromeOmniboxNavigationObserver( | 147 return base::WrapUnique(new ChromeOmniboxNavigationObserver( |
147 profile_, text, match, alternate_nav_match)); | 148 profile_, text, match, alternate_nav_match)); |
148 } | 149 } |
149 | 150 |
150 bool ChromeOmniboxClient::CurrentPageExists() const { | 151 bool ChromeOmniboxClient::CurrentPageExists() const { |
151 return (controller_->GetWebContents() != NULL); | 152 return (controller_->GetWebContents() != NULL); |
152 } | 153 } |
153 | 154 |
154 const GURL& ChromeOmniboxClient::GetURL() const { | 155 const GURL& ChromeOmniboxClient::GetURL() const { |
155 return controller_->GetWebContents()->GetVisibleURL(); | 156 return controller_->GetWebContents()->GetVisibleURL(); |
156 } | 157 } |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 if (prerenderer) | 470 if (prerenderer) |
470 prerenderer->Prerender(suggestion); | 471 prerenderer->Prerender(suggestion); |
471 } | 472 } |
472 } | 473 } |
473 | 474 |
474 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, | 475 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, |
475 const SkBitmap& bitmap) { | 476 const SkBitmap& bitmap) { |
476 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; | 477 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; |
477 callback.Run(bitmap); | 478 callback.Run(bitmap); |
478 } | 479 } |
OLD | NEW |