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

Side by Side Diff: chrome/browser/intents/register_intent_handler_infobar_delegate.cc

Issue 8469018: Provide assumed favicon for intents if service provider page was never visited. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/intents/register_intent_handler_infobar_delegate.h" 5 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/favicon/favicon_service.h"
9 #include "chrome/browser/intents/web_intents_registry.h" 10 #include "chrome/browser/intents/web_intents_registry.h"
10 #include "chrome/browser/intents/web_intents_registry_factory.h" 11 #include "chrome/browser/intents/web_intents_registry_factory.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
14 15
15 RegisterIntentHandlerInfoBarDelegate::RegisterIntentHandlerInfoBarDelegate( 16 RegisterIntentHandlerInfoBarDelegate::RegisterIntentHandlerInfoBarDelegate(
16 InfoBarTabHelper* infobar_helper, 17 InfoBarTabHelper* infobar_helper,
17 WebIntentsRegistry* registry, 18 WebIntentsRegistry* registry,
18 const webkit_glue::WebIntentServiceData& service) 19 const webkit_glue::WebIntentServiceData& service,
20 FaviconService* favicon_service,
21 const GURL& origin_url)
19 : ConfirmInfoBarDelegate(infobar_helper), 22 : ConfirmInfoBarDelegate(infobar_helper),
20 registry_(registry), 23 registry_(registry),
21 service_(service) { 24 service_(service),
25 favicon_service_(favicon_service),
26 origin_url_(origin_url) {
22 } 27 }
23 28
24 InfoBarDelegate::Type 29 InfoBarDelegate::Type
25 RegisterIntentHandlerInfoBarDelegate::GetInfoBarType() const { 30 RegisterIntentHandlerInfoBarDelegate::GetInfoBarType() const {
26 return PAGE_ACTION_TYPE; 31 return PAGE_ACTION_TYPE;
27 } 32 }
28 33
29 string16 RegisterIntentHandlerInfoBarDelegate::GetMessageText() const { 34 string16 RegisterIntentHandlerInfoBarDelegate::GetMessageText() const {
30 return l10n_util::GetStringFUTF16( 35 return l10n_util::GetStringFUTF16(
31 IDS_REGISTER_INTENT_HANDLER_CONFIRM, 36 IDS_REGISTER_INTENT_HANDLER_CONFIRM,
32 service_.title, 37 service_.title,
33 UTF8ToUTF16(service_.service_url.host())); 38 UTF8ToUTF16(service_.service_url.host()));
34 } 39 }
35 40
36 string16 RegisterIntentHandlerInfoBarDelegate::GetButtonLabel( 41 string16 RegisterIntentHandlerInfoBarDelegate::GetButtonLabel(
37 InfoBarButton button) const { 42 InfoBarButton button) const {
38 if (button == BUTTON_OK) { 43 if (button == BUTTON_OK) {
39 return l10n_util::GetStringFUTF16(IDS_REGISTER_INTENT_HANDLER_ACCEPT, 44 return l10n_util::GetStringFUTF16(IDS_REGISTER_INTENT_HANDLER_ACCEPT,
40 UTF8ToUTF16(service_.service_url.host())); 45 UTF8ToUTF16(service_.service_url.host()));
41 } 46 }
42 47
43 DCHECK(button == BUTTON_CANCEL); 48 DCHECK(button == BUTTON_CANCEL);
44 return l10n_util::GetStringUTF16(IDS_REGISTER_INTENT_HANDLER_DENY); 49 return l10n_util::GetStringUTF16(IDS_REGISTER_INTENT_HANDLER_DENY);
45 } 50 }
46 51
47 bool RegisterIntentHandlerInfoBarDelegate::Accept() { 52 bool RegisterIntentHandlerInfoBarDelegate::Accept() {
48 registry_->RegisterIntentProvider(service_); 53 registry_->RegisterIntentProvider(service_);
54
55 // Register a temporary FavIcon in case we never visited the provider page.
56 if (favicon_service_ && origin_url_ != service_.service_url)
57 favicon_service_->CloneFavicon(origin_url_, service_.service_url);
58
49 return true; 59 return true;
50 } 60 }
51 61
52 string16 RegisterIntentHandlerInfoBarDelegate::GetLinkText() const { 62 string16 RegisterIntentHandlerInfoBarDelegate::GetLinkText() const {
53 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 63 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
54 } 64 }
55 65
56 bool RegisterIntentHandlerInfoBarDelegate::LinkClicked( 66 bool RegisterIntentHandlerInfoBarDelegate::LinkClicked(
57 WindowOpenDisposition disposition) { 67 WindowOpenDisposition disposition) {
58 // TODO(jhawkins): Open the Web Intents Help Center article once it is 68 // TODO(jhawkins): Open the Web Intents Help Center article once it is
59 // written. 69 // written.
60 // TODO(jhawkins): Add associated bug for the article here. 70 // TODO(jhawkins): Add associated bug for the article here.
61 return false; 71 return false;
62 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698