| 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/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 void AddRedirectChainWithTransitionAndTime( | 245 void AddRedirectChainWithTransitionAndTime( |
| 246 const char* sequence[], | 246 const char* sequence[], |
| 247 int page_id, | 247 int page_id, |
| 248 content::PageTransition transition, | 248 content::PageTransition transition, |
| 249 base::Time time) { | 249 base::Time time) { |
| 250 history::RedirectList redirects; | 250 history::RedirectList redirects; |
| 251 for (int i = 0; sequence[i] != NULL; ++i) | 251 for (int i = 0; sequence[i] != NULL; ++i) |
| 252 redirects.push_back(GURL(sequence[i])); | 252 redirects.push_back(GURL(sequence[i])); |
| 253 | 253 |
| 254 int int_scope = 1; | 254 ContextID context_id = reinterpret_cast<ContextID>(1); |
| 255 void* scope = 0; | |
| 256 memcpy(&scope, &int_scope, sizeof(int_scope)); | |
| 257 history::HistoryAddPageArgs request( | 255 history::HistoryAddPageArgs request( |
| 258 redirects.back(), time, scope, page_id, GURL(), | 256 redirects.back(), time, context_id, page_id, GURL(), |
| 259 redirects, transition, history::SOURCE_BROWSED, | 257 redirects, transition, history::SOURCE_BROWSED, |
| 260 true); | 258 true); |
| 261 backend_->AddPage(request); | 259 backend_->AddPage(request); |
| 262 } | 260 } |
| 263 | 261 |
| 264 // Adds CLIENT_REDIRECT page transition. | 262 // Adds CLIENT_REDIRECT page transition. |
| 265 // |url1| is the source URL and |url2| is the destination. | 263 // |url1| is the source URL and |url2| is the destination. |
| 266 // |did_replace| is true if the transition is non-user initiated and the | 264 // |did_replace| is true if the transition is non-user initiated and the |
| 267 // navigation entry for |url2| has replaced that for |url1|. The possibly | 265 // navigation entry for |url2| has replaced that for |url1|. The possibly |
| 268 // updated transition code of the visit records for |url1| and |url2| is | 266 // updated transition code of the visit records for |url1| and |url2| is |
| 269 // returned by filling in |*transition1| and |*transition2|, respectively. | 267 // returned by filling in |*transition1| and |*transition2|, respectively. |
| 270 // |time| is a time of the redirect. | 268 // |time| is a time of the redirect. |
| 271 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace, | 269 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace, |
| 272 base::Time time, | 270 base::Time time, |
| 273 int* transition1, int* transition2) { | 271 int* transition1, int* transition2) { |
| 274 void* const dummy_scope = reinterpret_cast<void*>(0x87654321); | 272 ContextID dummy_context_id = reinterpret_cast<ContextID>(0x87654321); |
| 275 history::RedirectList redirects; | 273 history::RedirectList redirects; |
| 276 if (url1.is_valid()) | 274 if (url1.is_valid()) |
| 277 redirects.push_back(url1); | 275 redirects.push_back(url1); |
| 278 if (url2.is_valid()) | 276 if (url2.is_valid()) |
| 279 redirects.push_back(url2); | 277 redirects.push_back(url2); |
| 280 HistoryAddPageArgs request( | 278 HistoryAddPageArgs request( |
| 281 url2, time, dummy_scope, 0, url1, | 279 url2, time, dummy_context_id, 0, url1, |
| 282 redirects, content::PAGE_TRANSITION_CLIENT_REDIRECT, | 280 redirects, content::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 283 history::SOURCE_BROWSED, did_replace); | 281 history::SOURCE_BROWSED, did_replace); |
| 284 backend_->AddPage(request); | 282 backend_->AddPage(request); |
| 285 | 283 |
| 286 *transition1 = GetTransition(url1); | 284 *transition1 = GetTransition(url1); |
| 287 *transition2 = GetTransition(url2); | 285 *transition2 = GetTransition(url2); |
| 288 } | 286 } |
| 289 | 287 |
| 290 int GetTransition(const GURL& url) { | 288 int GetTransition(const GURL& url) { |
| 291 if (!url.is_valid()) | 289 if (!url.is_valid()) |
| (...skipping 3059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3351 // Verify that the second term is no longer returned as result, and also check | 3349 // Verify that the second term is no longer returned as result, and also check |
| 3352 // at the low level that it is gone for good. The term corresponding to the | 3350 // at the low level that it is gone for good. The term corresponding to the |
| 3353 // first URLRow should not be affected. | 3351 // first URLRow should not be affected. |
| 3354 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3352 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
| 3355 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3353 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
| 3356 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3354 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
| 3357 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3355 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
| 3358 } | 3356 } |
| 3359 | 3357 |
| 3360 } // namespace history | 3358 } // namespace history |
| OLD | NEW |