Chromium Code Reviews| Index: chrome/browser/ui/webui/big_icon_source.h |
| diff --git a/chrome/browser/ui/webui/big_icon_source.h b/chrome/browser/ui/webui/big_icon_source.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4106b48d639e5cf61bb1b5cf9d434902b3b0d2dc |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/big_icon_source.h |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_WEBUI_BIG_ICON_SOURCE_H_ |
| +#define CHROME_BROWSER_UI_WEBUI_BIG_ICON_SOURCE_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/task/cancelable_task_tracker.h" |
| +#include "components/favicon_base/fallback_icon_service.h" |
| +#include "components/favicon_base/favicon_types.h" |
| +#include "content/public/browser/url_data_source.h" |
| + |
| +class Profile; |
| + |
| +// BigIconSource services explicit chrome:// requests for big icons. |
| +// |
| +// Format: |
| +// chrome://big-icon/size/url |
| +// All of the parameters except for the url are optional. However, the order of |
| +// |
| +// Parameter: |
| +// 'size' |
| +// Positive integer to specify the big icon's size in pixels. |
| +// 'url' |
| +// String to specify the page URL of the big icon. |
| +// |
| +// Example: chrome://big-icon/48/http://www.google.com/ |
| +// This requests a 48x48 big icon for http://www.google.com. |
| +class BigIconSource : public content::URLDataSource { |
|
Roger McFarlane (Chromium)
2015/03/16 19:00:59
nit: I prefer "large" over "big" in the nomenclatu
huangs
2015/03/17 01:43:52
Done.
|
| + public: |
| + explicit BigIconSource(Profile* profile); |
| + |
| + ~BigIconSource() override; |
| + |
| + // content::URLDataSource implementation. |
| + std::string GetSource() const override; |
| + void StartDataRequest( |
| + const std::string& path, |
| + int render_process_id, |
| + int render_frame_id, |
| + const content::URLDataSource::GotDataCallback& callback) override; |
| + std::string GetMimeType(const std::string&) const override; |
| + bool ShouldReplaceExistingSource() const override; |
| + bool ShouldServiceRequest(const net::URLRequest* request) const override; |
| + |
| + protected: |
| + struct IconRequest { |
| + IconRequest(); |
| + IconRequest(const content::URLDataSource::GotDataCallback& callback_in, |
| + const GURL& path_in, |
| + int size_in); |
| + ~IconRequest(); |
| + |
| + content::URLDataSource::GotDataCallback callback; |
| + GURL path; |
| + int size; |
| + }; |
| + |
| + private: |
| + bool HandleMissingResource(const IconRequest& request); |
| + |
| + void OnBigIconDataAvailable( |
| + IconRequest request, |
| + const favicon_base::FaviconRawBitmapResult& bitmap_result); |
| + |
| + void SendFallbackIcon( |
| + const GURL& url, |
| + const content::URLDataSource::GotDataCallback& callback); |
| + |
| + void SendDefaultResponse( |
| + const content::URLDataSource::GotDataCallback& callback); |
| + |
| + Profile* profile_; |
| + |
| + base::CancelableTaskTracker cancelable_task_tracker_; |
| + |
| + scoped_ptr<favicon_base::FallbackIconService> fallback_icon_service_; |
| + |
| + bool render_fallback_on_failure_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BigIconSource); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_WEBUI_BIG_ICON_SOURCE_H_ |