Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: chrome/browser/ui/webui/cookies_tree_model_util.cc

Issue 10536017: Refactoring CookiesTreeModel to support multiple data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed all comments by Evan. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/webui/cookies_tree_model_util.h" 5 #include "chrome/browser/ui/webui/cookies_tree_model_util.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/cookies_tree_model.h" 12 #include "chrome/browser/cookies_tree_model.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/text/bytes_formatting.h" 15 #include "ui/base/text/bytes_formatting.h"
16 16
17 namespace { 17 namespace {
18 18
19 static const char kKeyId[] = "id"; 19 static const char kKeyId[] = "id";
20 static const char kKeyTitle[] = "title"; 20 static const char kKeyTitle[] = "title";
21 static const char kKeyIcon[] = "icon"; 21 static const char kKeyIcon[] = "icon";
22 static const char kKeyType[] = "type"; 22 static const char kKeyType[] = "type";
23 static const char kKeyHasChildren[] = "hasChildren"; 23 static const char kKeyHasChildren[] = "hasChildren";
24 24
25 static const char kKeyAppId[] = "appId";
26
25 static const char kKeyName[] = "name"; 27 static const char kKeyName[] = "name";
26 static const char kKeyContent[] = "content"; 28 static const char kKeyContent[] = "content";
27 static const char kKeyDomain[] = "domain"; 29 static const char kKeyDomain[] = "domain";
28 static const char kKeyPath[] = "path"; 30 static const char kKeyPath[] = "path";
29 static const char kKeySendFor[] = "sendfor"; 31 static const char kKeySendFor[] = "sendfor";
30 static const char kKeyAccessibleToScript[] = "accessibleToScript"; 32 static const char kKeyAccessibleToScript[] = "accessibleToScript";
31 static const char kKeyDesc[] = "desc"; 33 static const char kKeyDesc[] = "desc";
32 static const char kKeySize[] = "size"; 34 static const char kKeySize[] = "size";
33 static const char kKeyOrigin[] = "origin"; 35 static const char kKeyOrigin[] = "origin";
34 static const char kKeyManifest[] = "manifest"; 36 static const char kKeyManifest[] = "manifest";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 dict->SetBoolean(kKeyHasChildren, !node.empty()); 96 dict->SetBoolean(kKeyHasChildren, !node.empty());
95 97
96 switch (node.GetDetailedInfo().node_type) { 98 switch (node.GetDetailedInfo().node_type) {
97 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: { 99 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: {
98 dict->SetString(kKeyType, "origin"); 100 dict->SetString(kKeyType, "origin");
99 #if defined(OS_MACOSX) 101 #if defined(OS_MACOSX)
100 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); 102 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER");
101 #endif 103 #endif
102 break; 104 break;
103 } 105 }
106 case CookieTreeNode::DetailedInfo::TYPE_APP: {
107 dict->SetString(kKeyType, "app");
108 dict->SetString(kKeyName, node.GetDetailedInfo().app_name);
109 dict->SetString(kKeyAppId, node.GetDetailedInfo().app_id);
110 break;
111 }
104 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: { 112 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: {
105 dict->SetString(kKeyType, "cookie"); 113 dict->SetString(kKeyType, "cookie");
106 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON"); 114 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON");
107 115
108 const net::CookieMonster::CanonicalCookie& cookie = 116 const net::CookieMonster::CanonicalCookie& cookie =
109 *node.GetDetailedInfo().cookie; 117 *node.GetDetailedInfo().cookie;
110 118
111 dict->SetString(kKeyName, cookie.Name()); 119 dict->SetString(kKeyName, cookie.Name());
112 dict->SetString(kKeyContent, cookie.Value()); 120 dict->SetString(kKeyContent, cookie.Value());
113 dict->SetString(kKeyDomain, cookie.Domain()); 121 dict->SetString(kKeyDomain, cookie.Domain());
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (child_index == -1) 299 if (child_index == -1)
292 break; 300 break;
293 301
294 parent = child; 302 parent = child;
295 } 303 }
296 304
297 return child_index >= 0 ? child : NULL; 305 return child_index >= 0 ? child : NULL;
298 } 306 }
299 307
300 } // namespace cookies_tree_model_util 308 } // namespace cookies_tree_model_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698