summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-29 17:48:19 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-29 17:48:19 +0000
commit5bcd914fec14d5fd2d4925faad5ff45661b9a724 (patch)
treecaf37a9d095eb4f3f51fb9a48c03c8905ddd3486
parent2254b09bae84a62a621367dacd62ac32b0f441c4 (diff)
downloadchromium_src-5bcd914fec14d5fd2d4925faad5ff45661b9a724.zip
chromium_src-5bcd914fec14d5fd2d4925faad5ff45661b9a724.tar.gz
chromium_src-5bcd914fec14d5fd2d4925faad5ff45661b9a724.tar.bz2
browser: Delete possible_url_model.* now that native options are gone.
This was added at revision r19072. BUG=None TEST=None R=evan@chromium.org Review URL: http://codereview.chromium.org/7530014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94708 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/possible_url_model.cc207
-rw-r--r--chrome/browser/possible_url_model.h70
-rw-r--r--chrome/chrome_browser.gypi2
3 files changed, 0 insertions, 279 deletions
diff --git a/chrome/browser/possible_url_model.cc b/chrome/browser/possible_url_model.cc
deleted file mode 100644
index ca0ade6..0000000
--- a/chrome/browser/possible_url_model.cc
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "chrome/browser/possible_url_model.h"
-
-#include "base/callback.h"
-#include "base/i18n/rtl.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/favicon/favicon_service.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
-#include "content/browser/cancelable_request.h"
-#include "grit/generated_resources.h"
-#include "grit/ui_resources.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/models/table_model_observer.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/text/text_elider.h"
-#include "ui/gfx/codec/png_codec.h"
-
-using base::Time;
-using base::TimeDelta;
-
-namespace {
-
-// The default favicon.
-SkBitmap* default_favicon = NULL;
-
-// How long we query entry points for.
-const int kPossibleURLTimeScope = 30;
-
-} // anonymous namespace
-
-// Contains the data needed to show a result.
-struct PossibleURLModel::Result {
- Result() : index(0) {}
-
- GURL url;
- // Index of this Result in results_. This is used as the key into
- // favicon_map_ to lookup the favicon for the url, as well as the index
- // into results_ when the favicon is received.
- size_t index;
- ui::SortedDisplayURL display_url;
- std::wstring title;
-};
-
-
-PossibleURLModel::PossibleURLModel()
- : profile_(NULL),
- observer_(NULL) {
- if (!default_favicon) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- default_favicon = rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
- }
-}
-
-PossibleURLModel::~PossibleURLModel() {
-}
-
-void PossibleURLModel::Reload(Profile *profile) {
- profile_ = profile;
- consumer_.CancelAllRequests();
- HistoryService* hs =
- profile->GetHistoryService(Profile::EXPLICIT_ACCESS);
- if (hs) {
- history::QueryOptions options;
- options.end_time = Time::Now();
- options.begin_time =
- options.end_time - TimeDelta::FromDays(kPossibleURLTimeScope);
- options.max_count = 50;
-
- hs->QueryHistory(string16(), options, &consumer_,
- NewCallback(this, &PossibleURLModel::OnHistoryQueryComplete));
- }
-}
-
-void PossibleURLModel::OnHistoryQueryComplete(HistoryService::Handle h,
- history::QueryResults* result) {
- results_.resize(result->size());
- std::string languages = profile_ ?
- profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::string();
- for (size_t i = 0; i < result->size(); ++i) {
- results_[i].url = (*result)[i].url();
- results_[i].index = i;
- results_[i].display_url =
- ui::SortedDisplayURL((*result)[i].url(), languages);
- results_[i].title = UTF16ToWide((*result)[i].title());
- }
-
- // The old version of this code would filter out all but the most recent
- // visit to each host, plus all typed URLs and AUTO_BOOKMARK transitions. I
- // think this dialog has a lot of work, and I'm not sure those old
- // conditions are correct (the results look about equal quality for my
- // history with and without those conditions), so I'm not spending time
- // re-implementing them here. They used to be implemented in the history
- // service, but I think they should be implemented here because that was
- // pretty specific behavior that shouldn't be generally exposed.
-
- favicon_map_.clear();
- if (observer_)
- observer_->OnModelChanged();
-}
-
-int PossibleURLModel::RowCount() {
- return static_cast<int>(results_.size());
-}
-
-const GURL& PossibleURLModel::GetURL(int row) {
- if (row < 0 || row >= RowCount()) {
- NOTREACHED();
- return GURL::EmptyGURL();
- }
- return results_[row].url;
-}
-
-const std::wstring& PossibleURLModel::GetTitle(int row) {
- if (row < 0 || row >= RowCount()) {
- NOTREACHED();
- return EmptyWString();
- }
- return results_[row].title;
-}
-
-string16 PossibleURLModel::GetText(int row, int col_id) {
- if (row < 0 || row >= RowCount()) {
- NOTREACHED();
- return string16();
- }
-
- if (col_id == IDS_ASI_PAGE_COLUMN) {
- string16 title = WideToUTF16Hack(GetTitle(row));
- // TODO(xji): Consider adding a special case if the title text is a URL,
- // since those should always have LTR directionality. Please refer to
- // http://crbug.com/6726 for more information.
- base::i18n::AdjustStringForLocaleDirection(&title);
- return title;
- }
-
- // TODO(brettw): this should probably pass the GURL up so the URL elider
- // can be used at a higher level when we know the width.
- string16 url = results_[row].display_url.display_url();
- return base::i18n::GetDisplayStringInLTRDirectionality(url);
-}
-
-SkBitmap PossibleURLModel::GetIcon(int row) {
- if (row < 0 || row >= RowCount()) {
- NOTREACHED();
- return *default_favicon;
- }
-
- Result& result = results_[row];
- FaviconMap::iterator i = favicon_map_.find(result.index);
- if (i != favicon_map_.end()) {
- // We already requested the favicon, return it.
- if (!i->second.isNull())
- return i->second;
- } else if (profile_) {
- FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
- if (favicon_service) {
- CancelableRequestProvider::Handle h =
- favicon_service->GetFaviconForURL(
- result.url, history::FAVICON, &consumer_,
- NewCallback(this, &PossibleURLModel::OnFaviconAvailable));
- consumer_.SetClientData(favicon_service, h, result.index);
- // Add an entry to the map so that we don't attempt to request the
- // favicon again.
- favicon_map_[result.index] = SkBitmap();
- }
- }
- return *default_favicon;
-}
-
-int PossibleURLModel::CompareValues(int row1, int row2, int column_id) {
- if (column_id == IDS_ASI_URL_COLUMN) {
- return results_[row1].display_url.Compare(
- results_[row2].display_url, GetCollator());
- }
- return ui::TableModel::CompareValues(row1, row2, column_id);
-}
-
-void PossibleURLModel::OnFaviconAvailable(
- FaviconService::Handle h,
- history::FaviconData favicon) {
- if (profile_) {
- FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
- size_t index = consumer_.GetClientData(favicon_service, h);
- if (favicon.is_valid()) {
- // The decoder will leave our bitmap empty on error.
- gfx::PNGCodec::Decode(favicon.image_data->front(),
- favicon.image_data->size(),
- &(favicon_map_[index]));
-
- // Notify the observer.
- if (!favicon_map_[index].isNull() && observer_)
- observer_->OnItemsChanged(static_cast<int>(index), 1);
- }
- }
-}
-
-void PossibleURLModel::SetObserver(ui::TableModelObserver* observer) {
- observer_ = observer;
-}
diff --git a/chrome/browser/possible_url_model.h b/chrome/browser/possible_url_model.h
deleted file mode 100644
index e368bad..0000000
--- a/chrome/browser/possible_url_model.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2011 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_POSSIBLE_URL_MODEL_H_
-#define CHROME_BROWSER_POSSIBLE_URL_MODEL_H_
-#pragma once
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "chrome/browser/history/history.h"
-#include "ui/base/models/table_model.h"
-
-class SkBitmap;
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// A table model to represent the list of URLs that the user might want to
-// bookmark.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-class PossibleURLModel : public ui::TableModel {
- public:
- PossibleURLModel();
- virtual ~PossibleURLModel();
-
- void Reload(Profile *profile);
-
- void OnHistoryQueryComplete(HistoryService::Handle h,
- history::QueryResults* result);
-
- const GURL& GetURL(int row);
- const std::wstring& GetTitle(int row);
-
- virtual void OnFaviconAvailable(FaviconService::Handle h,
- history::FaviconData favicon);
-
- // TableModel overrides
- virtual int RowCount() OVERRIDE;
- virtual string16 GetText(int row, int col_id) OVERRIDE;
- virtual SkBitmap GetIcon(int row) OVERRIDE;
- virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE;
- virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE;
-
- private:
- // The current profile.
- Profile* profile_;
-
- // Our observer.
- ui::TableModelObserver* observer_;
-
- // Our consumer for favicon requests.
- CancelableRequestConsumerT<size_t, 0> consumer_;
-
- // The results we're showing.
- struct Result;
- std::vector<Result> results_;
-
- // Map Result::index -> Favicon.
- typedef std::map<size_t, SkBitmap> FaviconMap;
- FaviconMap favicon_map_;
-
- DISALLOW_COPY_AND_ASSIGN(PossibleURLModel);
-};
-
-#endif // CHROME_BROWSER_POSSIBLE_URL_MODEL_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index d384fbc..0eb221f 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1683,8 +1683,6 @@
'browser/policy/proto/device_management_constants.h',
'<(protoc_out_dir)/chrome/browser/policy/proto/device_management_local.pb.cc',
'<(protoc_out_dir)/chrome/browser/policy/proto/device_management_local.pb.h',
- 'browser/possible_url_model.cc',
- 'browser/possible_url_model.h',
'browser/preferences_mac.cc',
'browser/preferences_mac.h',
'browser/prefs/browser_prefs.cc',