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

Side by Side Diff: chrome/browser/sync/sessions/page_revisit_broadcaster.cc

Issue 1399053004: [Sync] Adding revisit logic for typed URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated for Stan's comments. Created 5 years, 2 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
« no previous file with comments | « no previous file | components/components_tests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/sync/sessions/page_revisit_broadcaster.h" 5 #include "chrome/browser/sync/sessions/page_revisit_broadcaster.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/glue/synced_session_util.h" 13 #include "chrome/browser/sync/glue/synced_session_util.h"
12 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" 14 #include "chrome/browser/sync/sessions/sessions_sync_manager.h"
15 #include "components/history/core/browser/history_service.h"
13 #include "components/sync_sessions/revisit/sessions_page_revisit_observer.h" 16 #include "components/sync_sessions/revisit/sessions_page_revisit_observer.h"
17 #include "components/sync_sessions/revisit/typed_url_page_revisit_observer.h"
14 18
15 namespace browser_sync { 19 namespace browser_sync {
16 20
17 namespace { 21 namespace {
18 22
19 // Simple implementation of ForeignSessionsProvider that delegates to 23 // Simple implementation of ForeignSessionsProvider that delegates to
20 // SessionsSyncManager. It holds onto a non-owning pointer, with the assumption 24 // SessionsSyncManager. It holds onto a non-owning pointer, with the assumption
21 // that this class is only used by classes owned by SessionsSyncManager itself. 25 // that this class is only used by classes owned by SessionsSyncManager itself.
22 class SessionsSyncManagerWrapper 26 class SessionsSyncManagerWrapper
23 : public sync_sessions::ForeignSessionsProvider { 27 : public sync_sessions::ForeignSessionsProvider {
(...skipping 16 matching lines...) Expand all
40 PageRevisitBroadcaster::PageRevisitBroadcaster(SessionsSyncManager* manager, 44 PageRevisitBroadcaster::PageRevisitBroadcaster(SessionsSyncManager* manager,
41 Profile* profile) { 45 Profile* profile) {
42 const std::string group_name = 46 const std::string group_name =
43 base::FieldTrialList::FindFullName("PageRevisitInstrumentation"); 47 base::FieldTrialList::FindFullName("PageRevisitInstrumentation");
44 bool shouldInstrument = group_name == "Enabled"; 48 bool shouldInstrument = group_name == "Enabled";
45 if (shouldInstrument) { 49 if (shouldInstrument) {
46 revisit_observers_.push_back(new sync_sessions::SessionsPageRevisitObserver( 50 revisit_observers_.push_back(new sync_sessions::SessionsPageRevisitObserver(
47 scoped_ptr<sync_sessions::ForeignSessionsProvider>( 51 scoped_ptr<sync_sessions::ForeignSessionsProvider>(
48 new SessionsSyncManagerWrapper(manager)))); 52 new SessionsSyncManagerWrapper(manager))));
49 53
54 history::HistoryService* history =
55 HistoryServiceFactory::GetForProfileWithoutCreating(profile);
56 if (history) {
57 revisit_observers_.push_back(
58 new sync_sessions::TypedUrlPageRevisitObserver(history));
59 }
50 // TODO(skym): Add bookmarks observer. 60 // TODO(skym): Add bookmarks observer.
51 // TODO(skym): Add typed URL observer.
52 } 61 }
53 } 62 }
54 63
55 PageRevisitBroadcaster::~PageRevisitBroadcaster() {} 64 PageRevisitBroadcaster::~PageRevisitBroadcaster() {}
56 65
57 void PageRevisitBroadcaster::OnPageVisit(const GURL& url, 66 void PageRevisitBroadcaster::OnPageVisit(const GURL& url,
58 const ui::PageTransition transition) { 67 const ui::PageTransition transition) {
59 if (ShouldSyncURL(url)) { 68 if (ShouldSyncURL(url)) {
60 sync_sessions::PageVisitObserver::TransitionType converted( 69 sync_sessions::PageVisitObserver::TransitionType converted(
61 ConvertTransitionEnum(transition)); 70 ConvertTransitionEnum(transition));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 case ui::PAGE_TRANSITION_KEYWORD: 117 case ui::PAGE_TRANSITION_KEYWORD:
109 case ui::PAGE_TRANSITION_KEYWORD_GENERATED: 118 case ui::PAGE_TRANSITION_KEYWORD_GENERATED:
110 return sync_sessions::PageVisitObserver::kTransitionOmniboxTemplateSearch; 119 return sync_sessions::PageVisitObserver::kTransitionOmniboxTemplateSearch;
111 120
112 default: 121 default:
113 return sync_sessions::PageVisitObserver::kTransitionUnknown; 122 return sync_sessions::PageVisitObserver::kTransitionUnknown;
114 } 123 }
115 } 124 }
116 125
117 } // namespace browser_sync 126 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698