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

Side by Side Diff: chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.cc

Issue 200493006: Move the ShortcutsBackend from history to autocomplete so that it can fully (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/omnibox/alternate_nav_infobar_delegate.h" 5 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/shortcuts_backend.h"
9 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
8 #include "chrome/browser/history/history_service.h" 10 #include "chrome/browser/history/history_service.h"
9 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
10 #include "chrome/browser/history/shortcuts_backend.h"
11 #include "chrome/browser/history/shortcuts_backend_factory.h"
12 #include "chrome/browser/infobars/infobar.h" 12 #include "chrome/browser/infobars/infobar.h"
13 #include "chrome/browser/infobars/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 19
20 20
21 AlternateNavInfoBarDelegate::~AlternateNavInfoBarDelegate() { 21 AlternateNavInfoBarDelegate::~AlternateNavInfoBarDelegate() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 base::string16 AlternateNavInfoBarDelegate::GetLinkText() const { 62 base::string16 AlternateNavInfoBarDelegate::GetLinkText() const {
63 return base::UTF8ToUTF16(match_.destination_url.spec()); 63 return base::UTF8ToUTF16(match_.destination_url.spec());
64 } 64 }
65 65
66 bool AlternateNavInfoBarDelegate::LinkClicked( 66 bool AlternateNavInfoBarDelegate::LinkClicked(
67 WindowOpenDisposition disposition) { 67 WindowOpenDisposition disposition) {
68 // Tell the shortcuts backend to remove the shortcut it added for the original 68 // Tell the shortcuts backend to remove the shortcut it added for the original
69 // search and instead add one reflecting this navigation. 69 // search and instead add one reflecting this navigation.
70 scoped_refptr<history::ShortcutsBackend> shortcuts_backend( 70 scoped_refptr<ShortcutsBackend> shortcuts_backend(
71 ShortcutsBackendFactory::GetForProfile(profile_)); 71 ShortcutsBackendFactory::GetForProfile(profile_));
72 if (shortcuts_backend) { // May be NULL in incognito. 72 if (shortcuts_backend) { // May be NULL in incognito.
73 shortcuts_backend->DeleteShortcutsWithUrl(search_url_); 73 shortcuts_backend->DeleteShortcutsWithURL(search_url_);
74 shortcuts_backend->AddOrUpdateShortcut(text_, match_); 74 shortcuts_backend->AddOrUpdateShortcut(text_, match_);
75 } 75 }
76 76
77 // Tell the history system to remove any saved search term for the search. 77 // Tell the history system to remove any saved search term for the search.
78 HistoryService* const history_service = 78 HistoryService* const history_service =
79 HistoryServiceFactory::GetForProfile(profile_, Profile::IMPLICIT_ACCESS); 79 HistoryServiceFactory::GetForProfile(profile_, Profile::IMPLICIT_ACCESS);
80 if (history_service) 80 if (history_service)
81 history_service->DeleteKeywordSearchTermForURL(search_url_); 81 history_service->DeleteKeywordSearchTermForURL(search_url_);
82 82
83 // Pretend the user typed this URL, so that navigating to it will be the 83 // Pretend the user typed this URL, so that navigating to it will be the
84 // default action when it's typed again in the future. 84 // default action when it's typed again in the future.
85 web_contents()->OpenURL(content::OpenURLParams( 85 web_contents()->OpenURL(content::OpenURLParams(
86 match_.destination_url, content::Referrer(), disposition, 86 match_.destination_url, content::Referrer(), disposition,
87 content::PAGE_TRANSITION_TYPED, false)); 87 content::PAGE_TRANSITION_TYPED, false));
88 88
89 // We should always close, even if the navigation did not occur within this 89 // We should always close, even if the navigation did not occur within this
90 // WebContents. 90 // WebContents.
91 return true; 91 return true;
92 } 92 }
93 93
94 int AlternateNavInfoBarDelegate::GetIconID() const { 94 int AlternateNavInfoBarDelegate::GetIconID() const {
95 return IDR_INFOBAR_ALT_NAV_URL; 95 return IDR_INFOBAR_ALT_NAV_URL;
96 } 96 }
97 97
98 InfoBarDelegate::Type AlternateNavInfoBarDelegate::GetInfoBarType() const { 98 InfoBarDelegate::Type AlternateNavInfoBarDelegate::GetInfoBarType() const {
99 return PAGE_ACTION_TYPE; 99 return PAGE_ACTION_TYPE;
100 } 100 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | chrome/browser/ui/omnibox/omnibox_navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698