summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/favicon.gypi2
-rw-r--r--components/favicon/core/BUILD.gn2
-rw-r--r--components/favicon/core/favicon_client.h4
-rw-r--r--components/favicon/core/favicon_driver.h6
-rw-r--r--components/favicon/core/favicon_driver_observer.h28
-rw-r--r--components/favicon/core/favicon_handler.cc7
-rw-r--r--components/favicon/core/favicon_handler.h17
-rw-r--r--components/favicon/core/favicon_service.cc49
-rw-r--r--components/favicon/core/favicon_service.h7
-rw-r--r--components/favicon/core/favicon_tab_helper_observer.h24
-rw-r--r--components/history/core/browser/history_service.h7
11 files changed, 86 insertions, 67 deletions
diff --git a/components/favicon.gypi b/components/favicon.gypi
index 8a9378b..d1aa277 100644
--- a/components/favicon.gypi
+++ b/components/favicon.gypi
@@ -24,11 +24,11 @@
'favicon/core/fallback_icon_service.h',
'favicon/core/favicon_client.h',
'favicon/core/favicon_driver.h',
+ 'favicon/core/favicon_driver_observer.h',
'favicon/core/favicon_handler.cc',
'favicon/core/favicon_handler.h',
'favicon/core/favicon_service.cc',
'favicon/core/favicon_service.h',
- 'favicon/core/favicon_tab_helper_observer.h',
'favicon/core/favicon_url.cc',
'favicon/core/favicon_url.h',
],
diff --git a/components/favicon/core/BUILD.gn b/components/favicon/core/BUILD.gn
index 8a4a0f7..4ac4750 100644
--- a/components/favicon/core/BUILD.gn
+++ b/components/favicon/core/BUILD.gn
@@ -9,11 +9,11 @@ static_library("core") {
"fallback_icon_service.h",
"favicon_client.h",
"favicon_driver.h",
+ "favicon_driver_observer.h",
"favicon_handler.cc",
"favicon_handler.h",
"favicon_service.cc",
"favicon_service.h",
- "favicon_tab_helper_observer.h",
"favicon_url.cc",
"favicon_url.h",
]
diff --git a/components/favicon/core/favicon_client.h b/components/favicon/core/favicon_client.h
index 913485e..c17f9a7 100644
--- a/components/favicon/core/favicon_client.h
+++ b/components/favicon/core/favicon_client.h
@@ -14,6 +14,8 @@
class GURL;
+namespace favicon {
+
// This class abstracts operations that depend on the embedder's environment,
// e.g. Chrome.
class FaviconClient : public KeyedService {
@@ -44,4 +46,6 @@ class FaviconClient : public KeyedService {
DISALLOW_COPY_AND_ASSIGN(FaviconClient);
};
+} // namespace favicon
+
#endif // COMPONENTS_FAVICON_CORE_FAVICON_CLIENT_H_
diff --git a/components/favicon/core/favicon_driver.h b/components/favicon/core/favicon_driver.h
index f06ca0d..de53125 100644
--- a/components/favicon/core/favicon_driver.h
+++ b/components/favicon/core/favicon_driver.h
@@ -5,12 +5,16 @@
#ifndef COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
#define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
+#include <base/macros.h>
+
class GURL;
namespace gfx {
class Image;
}
+namespace favicon {
+
// Interface that allows Favicon core code to interact with its driver (i.e.,
// obtain information from it and give information to it). A concrete
// implementation must be provided by the driver.
@@ -61,4 +65,6 @@ class FaviconDriver {
DISALLOW_COPY_AND_ASSIGN(FaviconDriver);
};
+} // namespace favicon
+
#endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
diff --git a/components/favicon/core/favicon_driver_observer.h b/components/favicon/core/favicon_driver_observer.h
new file mode 100644
index 0000000..fb64c1c
--- /dev/null
+++ b/components/favicon/core/favicon_driver_observer.h
@@ -0,0 +1,28 @@
+// Copyright 2014 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 COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_
+#define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_
+
+namespace gfx {
+class Image;
+}
+
+namespace favicon {
+
+// An observer implemented by classes which are interested in event from
+// FaviconDriver.
+class FaviconDriverObserver {
+ public:
+ // Called when favicon |image| is retrieved from either web site or cached
+ // storage.
+ virtual void OnFaviconAvailable(const gfx::Image& image) = 0;
+
+ protected:
+ virtual ~FaviconDriverObserver() {}
+};
+
+} // namespace favicon
+
+#endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_
diff --git a/components/favicon/core/favicon_handler.cc b/components/favicon/core/favicon_handler.cc
index 641b0f1..bcdff7c 100644
--- a/components/favicon/core/favicon_handler.cc
+++ b/components/favicon/core/favicon_handler.cc
@@ -22,8 +22,7 @@
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_util.h"
-using favicon::FaviconURL;
-
+namespace favicon {
namespace {
// Size (along each axis) of a touch icon. This currently corresponds to
@@ -691,7 +690,7 @@ int FaviconHandler::ScheduleDownload(const GURL& url,
void FaviconHandler::SortAndPruneImageUrls() {
// Not using const-reference since the loop mutates FaviconURL::icon_sizes.
- for (favicon::FaviconURL& image_url : image_urls_) {
+ for (FaviconURL& image_url : image_urls_) {
if (image_url.icon_sizes.empty())
continue;
@@ -703,3 +702,5 @@ void FaviconHandler::SortAndPruneImageUrls() {
std::stable_sort(image_urls_.begin(), image_urls_.end(),
CompareIconSize);
}
+
+} // namespace favicon
diff --git a/components/favicon/core/favicon_handler.h b/components/favicon/core/favicon_handler.h
index c7181c5..9e59e00 100644
--- a/components/favicon/core/favicon_handler.h
+++ b/components/favicon/core/favicon_handler.h
@@ -19,15 +19,20 @@
#include "ui/gfx/image/image.h"
#include "url/gurl.h"
-class FaviconClient;
-class FaviconDriver;
-class FaviconService;
+class FaviconTabHelperTest;
class SkBitmap;
+class TestFaviconHandler;
namespace base {
class RefCountedMemory;
}
+namespace favicon {
+
+class FaviconClient;
+class FaviconDriver;
+class FaviconService;
+
// FaviconHandler works with FaviconDriver to fetch the specific type of
// favicon.
//
@@ -152,8 +157,8 @@ class FaviconHandler {
private:
// For testing:
- friend class FaviconTabHelperTest;
- friend class TestFaviconHandler;
+ friend class ::FaviconTabHelperTest;
+ friend class ::TestFaviconHandler;
// Represents an in progress download of an image from the renderer.
struct DownloadRequest {
@@ -312,4 +317,6 @@ class FaviconHandler {
DISALLOW_COPY_AND_ASSIGN(FaviconHandler);
};
+} // namespace favicon
+
#endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
diff --git a/components/favicon/core/favicon_service.cc b/components/favicon/core/favicon_service.cc
index b455f1e..dd1ada4c 100644
--- a/components/favicon/core/favicon_service.cc
+++ b/components/favicon/core/favicon_service.cc
@@ -19,8 +19,7 @@
#include "ui/gfx/image/image_skia.h"
#include "url/gurl.h"
-using base::Bind;
-
+namespace favicon {
namespace {
// Helper to run callback with empty results if we cannot get the history
@@ -32,7 +31,8 @@ base::CancelableTaskTracker::TaskId RunWithEmptyResultAsync(
base::ThreadTaskRunnerHandle::Get());
return tracker->PostTask(
thread_runner.get(), FROM_HERE,
- Bind(callback, std::vector<favicon_base::FaviconRawBitmapResult>()));
+ base::Bind(callback,
+ std::vector<favicon_base::FaviconRawBitmapResult>()));
}
// Returns a vector of pixel edge sizes from |size_in_dip| and
@@ -68,8 +68,8 @@ base::CancelableTaskTracker::TaskId FaviconService::GetFaviconImage(
const favicon_base::FaviconImageCallback& callback,
base::CancelableTaskTracker* tracker) {
favicon_base::FaviconResultsCallback callback_runner =
- Bind(&FaviconService::RunFaviconImageCallbackWithBitmapResults,
- base::Unretained(this), callback, gfx::kFaviconSize);
+ base::Bind(&FaviconService::RunFaviconImageCallbackWithBitmapResults,
+ base::Unretained(this), callback, gfx::kFaviconSize);
if (history_service_) {
std::vector<GURL> icon_urls;
icon_urls.push_back(icon_url);
@@ -90,10 +90,8 @@ base::CancelableTaskTracker::TaskId FaviconService::GetRawFavicon(
const favicon_base::FaviconRawBitmapCallback& callback,
base::CancelableTaskTracker* tracker) {
favicon_base::FaviconResultsCallback callback_runner =
- Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
- base::Unretained(this),
- callback,
- desired_size_in_pixel);
+ base::Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
+ base::Unretained(this), callback, desired_size_in_pixel);
if (history_service_) {
std::vector<GURL> icon_urls;
@@ -131,13 +129,10 @@ base::CancelableTaskTracker::TaskId FaviconService::GetFaviconImageForPageURL(
const favicon_base::FaviconImageCallback& callback,
base::CancelableTaskTracker* tracker) {
return GetFaviconForPageURLImpl(
- page_url,
- favicon_base::FAVICON,
+ page_url, favicon_base::FAVICON,
GetPixelSizesForFaviconScales(gfx::kFaviconSize),
- Bind(&FaviconService::RunFaviconImageCallbackWithBitmapResults,
- base::Unretained(this),
- callback,
- gfx::kFaviconSize),
+ base::Bind(&FaviconService::RunFaviconImageCallbackWithBitmapResults,
+ base::Unretained(this), callback, gfx::kFaviconSize),
tracker);
}
@@ -150,13 +145,9 @@ base::CancelableTaskTracker::TaskId FaviconService::GetRawFaviconForPageURL(
std::vector<int> desired_sizes_in_pixel;
desired_sizes_in_pixel.push_back(desired_size_in_pixel);
return GetFaviconForPageURLImpl(
- page_url,
- icon_types,
- desired_sizes_in_pixel,
- Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
- base::Unretained(this),
- callback,
- desired_size_in_pixel),
+ page_url, icon_types, desired_sizes_in_pixel,
+ base::Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
+ base::Unretained(this), callback, desired_size_in_pixel),
tracker);
}
@@ -168,10 +159,8 @@ FaviconService::GetLargestRawFaviconForPageURL(
const favicon_base::FaviconRawBitmapCallback& callback,
base::CancelableTaskTracker* tracker) {
favicon_base::FaviconResultsCallback favicon_results_callback =
- Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
- base::Unretained(this),
- callback,
- 0);
+ base::Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
+ base::Unretained(this), callback, 0);
if (favicon_client_ && favicon_client_->IsNativeApplicationURL(page_url)) {
std::vector<int> desired_sizes_in_pixel;
desired_sizes_in_pixel.push_back(0);
@@ -227,10 +216,8 @@ base::CancelableTaskTracker::TaskId FaviconService::GetLargestRawFaviconForID(
// any resizing.
int desired_size = 0;
favicon_base::FaviconResultsCallback callback_runner =
- Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
- base::Unretained(this),
- callback,
- desired_size);
+ base::Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults,
+ base::Unretained(this), callback, desired_size);
if (history_service_) {
return history_service_->GetFaviconForID(
@@ -389,3 +376,5 @@ void FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults(
&resized_bitmap_data);
callback.Run(bitmap_result);
}
+
+} // namespace favicon
diff --git a/components/favicon/core/favicon_service.h b/components/favicon/core/favicon_service.h
index 9e45c55..d122e90 100644
--- a/components/favicon/core/favicon_service.h
+++ b/components/favicon/core/favicon_service.h
@@ -16,13 +16,16 @@
#include "components/favicon_base/favicon_usage_data.h"
#include "components/keyed_service/core/keyed_service.h"
-class FaviconClient;
class GURL;
namespace history {
class HistoryService;
}
+namespace favicon {
+
+class FaviconClient;
+
// The favicon service provides methods to access favicons. It calls the history
// backend behind the scenes. The callbacks are run asynchronously, even in the
// case of an error.
@@ -251,4 +254,6 @@ class FaviconService : public KeyedService {
DISALLOW_COPY_AND_ASSIGN(FaviconService);
};
+} // namespace favicon
+
#endif // COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_
diff --git a/components/favicon/core/favicon_tab_helper_observer.h b/components/favicon/core/favicon_tab_helper_observer.h
deleted file mode 100644
index bf8a053..0000000
--- a/components/favicon/core/favicon_tab_helper_observer.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2014 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 COMPONENTS_FAVICON_CORE_FAVICON_TAB_HELPER_OBSERVER_H_
-#define COMPONENTS_FAVICON_CORE_FAVICON_TAB_HELPER_OBSERVER_H_
-
-namespace gfx {
-class Image;
-}
-
-// An observer implemented by classes which are interested in envent in
-// FaviconTabHelper.
-class FaviconTabHelperObserver {
- public:
- // Called when favicon |image| is retrieved from either web site or history
- // backend.
- virtual void OnFaviconAvailable(const gfx::Image& image) = 0;
-
- protected:
- virtual ~FaviconTabHelperObserver() {}
-};
-
-#endif // COMPONENTS_FAVICON_CORE_FAVICON_TAB_HELPER_OBSERVER_H_
diff --git a/components/history/core/browser/history_service.h b/components/history/core/browser/history_service.h
index 5231a03..7d7b00c 100644
--- a/components/history/core/browser/history_service.h
+++ b/components/history/core/browser/history_service.h
@@ -33,7 +33,6 @@
#include "sync/api/syncable_service.h"
#include "ui/base/page_transition_types.h"
-class FaviconService;
class GURL;
class HistoryQuickProviderTest;
class HistoryURLProvider;
@@ -49,6 +48,10 @@ class FilePath;
class Thread;
}
+namespace favicon {
+class FaviconService;
+}
+
namespace history {
struct DownloadRow;
@@ -512,7 +515,7 @@ class HistoryService : public syncer::SyncableService, public KeyedService {
class BackendDelegate;
friend class base::RefCountedThreadSafe<HistoryService>;
friend class BackendDelegate;
- friend class ::FaviconService;
+ friend class favicon::FaviconService;
friend class HistoryBackend;
friend class HistoryQueryTest;
friend class HistoryOperation;