| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/cookies_tree_model.h" | 5 #include "chrome/browser/cookies_tree_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browsing_data_cookie_helper.h" | 15 #include "chrome/browser/browsing_data_cookie_helper.h" |
| 16 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" | 16 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" |
| 17 #include "chrome/browser/content_settings/cookie_settings.h" | 17 #include "chrome/browser/content_settings/cookie_settings.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 20 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
| 21 #include "grit/ui_resources.h" | 21 #include "grit/ui_resources.h" |
| 22 #include "net/base/registry_controlled_domain.h" | 22 #include "net/base/registry_controlled_domain.h" |
| 23 #include "net/cookies/cookie_monster.h" | 23 #include "net/cookies/cookie_monster.h" |
| 24 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 25 #include "third_party/skia/include/core/SkBitmap.h" | |
| 26 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/gfx/image/image_skia.h" |
| 28 | 28 |
| 29 static const char kFileOriginNodeName[] = "file://"; | 29 static const char kFileOriginNodeName[] = "file://"; |
| 30 | 30 |
| 31 /////////////////////////////////////////////////////////////////////////////// | 31 /////////////////////////////////////////////////////////////////////////////// |
| 32 // CookieTreeNode, public: | 32 // CookieTreeNode, public: |
| 33 | 33 |
| 34 void CookieTreeNode::DeleteStoredObjects() { | 34 void CookieTreeNode::DeleteStoredObjects() { |
| 35 std::for_each(children().begin(), | 35 std::for_each(children().begin(), |
| 36 children().end(), | 36 children().end(), |
| 37 std::mem_fun(&CookieTreeNode::DeleteStoredObjects)); | 37 std::mem_fun(&CookieTreeNode::DeleteStoredObjects)); |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 } | 702 } |
| 703 | 703 |
| 704 CookiesTreeModel::~CookiesTreeModel() {} | 704 CookiesTreeModel::~CookiesTreeModel() {} |
| 705 | 705 |
| 706 /////////////////////////////////////////////////////////////////////////////// | 706 /////////////////////////////////////////////////////////////////////////////// |
| 707 // CookiesTreeModel, TreeModel methods (public): | 707 // CookiesTreeModel, TreeModel methods (public): |
| 708 | 708 |
| 709 // TreeModel methods: | 709 // TreeModel methods: |
| 710 // Returns the set of icons for the nodes in the tree. You only need override | 710 // Returns the set of icons for the nodes in the tree. You only need override |
| 711 // this if you don't want to use the default folder icons. | 711 // this if you don't want to use the default folder icons. |
| 712 void CookiesTreeModel::GetIcons(std::vector<SkBitmap>* icons) { | 712 void CookiesTreeModel::GetIcons(std::vector<gfx::ImageSkia>* icons) { |
| 713 icons->push_back(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | 713 icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 714 IDR_OMNIBOX_HTTP)); | 714 IDR_OMNIBOX_HTTP)); |
| 715 icons->push_back(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | 715 icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 716 IDR_COOKIE_ICON)); | 716 IDR_COOKIE_ICON)); |
| 717 icons->push_back(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | 717 icons->push_back(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 718 IDR_COOKIE_STORAGE_ICON)); | 718 IDR_COOKIE_STORAGE_ICON)); |
| 719 } | 719 } |
| 720 | 720 |
| 721 // Returns the index of the icon to use for |node|. Return -1 to use the | 721 // Returns the index of the icon to use for |node|. Return -1 to use the |
| 722 // default icon. The index is relative to the list of icons returned from | 722 // default icon. The index is relative to the list of icons returned from |
| 723 // GetIcons. | 723 // GetIcons. |
| 724 int CookiesTreeModel::GetIconIndex(ui::TreeModelNode* node) { | 724 int CookiesTreeModel::GetIconIndex(ui::TreeModelNode* node) { |
| 725 CookieTreeNode* ct_node = static_cast<CookieTreeNode*>(node); | 725 CookieTreeNode* ct_node = static_cast<CookieTreeNode*>(node); |
| 726 switch (ct_node->GetDetailedInfo().node_type) { | 726 switch (ct_node->GetDetailedInfo().node_type) { |
| 727 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: | 727 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 | 1138 |
| 1139 void CookiesTreeModel::NotifyObserverEndBatch() { | 1139 void CookiesTreeModel::NotifyObserverEndBatch() { |
| 1140 // Only notify the observers if this is the outermost call to EndBatch() if | 1140 // Only notify the observers if this is the outermost call to EndBatch() if |
| 1141 // called in a nested manner. | 1141 // called in a nested manner. |
| 1142 if (--batch_update_ == 0) { | 1142 if (--batch_update_ == 0) { |
| 1143 FOR_EACH_OBSERVER(Observer, | 1143 FOR_EACH_OBSERVER(Observer, |
| 1144 cookies_observer_list_, | 1144 cookies_observer_list_, |
| 1145 TreeModelEndBatch(this)); | 1145 TreeModelEndBatch(this)); |
| 1146 } | 1146 } |
| 1147 } | 1147 } |
| OLD | NEW |