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

Side by Side Diff: components/history/core/browser/url_row.h

Issue 1143183002: Proof of concept implementation of context based history filtering. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_URL_ROW_H_ 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_URL_ROW_H_
6 #define COMPONENTS_HISTORY_CORE_BROWSER_URL_ROW_H_ 6 #define COMPONENTS_HISTORY_CORE_BROWSER_URL_ROW_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "components/query_parser/snippet.h" 11 #include "components/query_parser/snippet.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace history { 14 namespace history {
15 15
16 typedef int64 URLID; 16 typedef int64 URLID;
17 17
18 // Holds all information globally associated with one URL (one row in the 18 // Holds all information globally associated with one URL (one row in the
19 // URL table). 19 // URL table).
20 // 20 //
21 // This keeps track of dirty bits, which are currently unused: 21 // This keeps track of dirty bits, which are currently unused:
22 // 22 //
23 // TODO(brettw) the dirty bits are broken in a number of respects. First, the 23 // TODO(brettw) the dirty bits are broken in a number of respects. First, the
24 // database will want to update them on a const object, so they need to be 24 // database will want to update them on a const object, so they need to be
25 // mutable. 25 // mutable.
26 // 26 //
27 // Second, there is a problem copying. If you make a copy of this structure 27 // Second, there is a problem copying. If you make a copy of this structure
28 // (as we allow since we put this into vectors in various places) then the 28 // (as we allow since we put this into vectors in various places) then the
29 // dirty bits will not be in sync for these copies. 29 // dirty bits will not be in sync for these copies.
30
31 enum HistoryContext {
32 CONTEXT_NONE = 0, // No distinctive context available.
33 CONTEXT_COPY = 1, // User copied some content.
34 CONTEXT_SAVE_IMAGE = 2, // User saved any image.
35 CONTEXT_PRINT = 3, // User printed the content.
36 CONTEXT_MEDIA_PLAY = 4, // User shares any link.
37 };
38
30 class URLRow { 39 class URLRow {
31 public: 40 public:
32 URLRow(); 41 URLRow();
33 42
34 explicit URLRow(const GURL& url); 43 explicit URLRow(const GURL& url);
35 44
36 // We need to be able to set the id of a URLRow that's being passed through 45 // We need to be able to set the id of a URLRow that's being passed through
37 // an IPC message. This constructor should probably not be used otherwise. 46 // an IPC message. This constructor should probably not be used otherwise.
38 URLRow(const GURL& url, URLID id); 47 URLRow(const GURL& url, URLID id);
39 48
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 101 }
93 102
94 // If this is set, we won't autocomplete this URL. 103 // If this is set, we won't autocomplete this URL.
95 bool hidden() const { 104 bool hidden() const {
96 return hidden_; 105 return hidden_;
97 } 106 }
98 void set_hidden(bool hidden) { 107 void set_hidden(bool hidden) {
99 hidden_ = hidden; 108 hidden_ = hidden;
100 } 109 }
101 110
111 HistoryContext context() const {
112 return context_;
113 }
114 void set_context(HistoryContext context) {
115 context_ = context;
116 }
117
102 // Helper functor that determines if an URLRow refers to a given URL. 118 // Helper functor that determines if an URLRow refers to a given URL.
103 class URLRowHasURL { 119 class URLRowHasURL {
104 public: 120 public:
105 explicit URLRowHasURL(const GURL& url) : url_(url) {} 121 explicit URLRowHasURL(const GURL& url) : url_(url) {}
106 122
107 bool operator()(const URLRow& row) { 123 bool operator()(const URLRow& row) {
108 return row.url() == url_; 124 return row.url() == url_;
109 } 125 }
110 126
111 private: 127 private:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 int typed_count_; 162 int typed_count_;
147 163
148 // The date of the last visit of this URL, which saves us from having to 164 // The date of the last visit of this URL, which saves us from having to
149 // loop up in the visit table for things like autocomplete and expiration. 165 // loop up in the visit table for things like autocomplete and expiration.
150 base::Time last_visit_; 166 base::Time last_visit_;
151 167
152 // Indicates this entry should now be shown in typical UI or queries, this 168 // Indicates this entry should now be shown in typical UI or queries, this
153 // is usually for subframes. 169 // is usually for subframes.
154 bool hidden_; 170 bool hidden_;
155 171
172 HistoryContext context_;
156 // We support the implicit copy constuctor and operator=. 173 // We support the implicit copy constuctor and operator=.
157 }; 174 };
158 typedef std::vector<URLRow> URLRows; 175 typedef std::vector<URLRow> URLRows;
159 176
160 177
161 class URLResult : public URLRow { 178 class URLResult : public URLRow {
162 public: 179 public:
163 URLResult(); 180 URLResult();
164 URLResult(const GURL& url, base::Time visit_time); 181 URLResult(const GURL& url, base::Time visit_time);
165 // Constructor that create a URLResult from the specified URL and title match 182 // Constructor that create a URLResult from the specified URL and title match
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 219
203 // Whether a managed user was blocked when attempting to visit this URL. 220 // Whether a managed user was blocked when attempting to visit this URL.
204 bool blocked_visit_; 221 bool blocked_visit_;
205 222
206 // We support the implicit copy constructor and operator=. 223 // We support the implicit copy constructor and operator=.
207 }; 224 };
208 225
209 } // namespace history 226 } // namespace history
210 227
211 #endif // COMPONENTS_HISTORY_CORE_BROWSER_URL_ROW_H_ 228 #endif // COMPONENTS_HISTORY_CORE_BROWSER_URL_ROW_H_
OLDNEW
« no previous file with comments | « components/history/core/browser/url_database.cc ('k') | components/history/core/browser/url_row.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698