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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h"
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/search_engines/template_url.h"
10 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
11 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h"
12 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/notification_types.h"
14 #include "content/public/browser/web_contents.h"
16 using content::WebContents
;
18 TemplateURLFetcherUICallbacks::TemplateURLFetcherUICallbacks(
19 SearchEngineTabHelper
* tab_helper
,
20 WebContents
* web_contents
)
21 : source_(tab_helper
),
22 web_contents_(web_contents
) {
24 content::NOTIFICATION_WEB_CONTENTS_DESTROYED
,
25 content::Source
<WebContents
>(web_contents_
));
28 TemplateURLFetcherUICallbacks::~TemplateURLFetcherUICallbacks() {
31 void TemplateURLFetcherUICallbacks::ConfirmAddSearchProvider(
32 TemplateURL
* template_url
,
34 scoped_ptr
<TemplateURL
> owned_template_url(template_url
);
35 if (!source_
|| !source_
->delegate())
38 source_
->delegate()->ConfirmAddSearchProvider(owned_template_url
.release(),
42 void TemplateURLFetcherUICallbacks::Observe(
44 const content::NotificationSource
& source
,
45 const content::NotificationDetails
& details
) {
46 DCHECK(type
== content::NOTIFICATION_WEB_CONTENTS_DESTROYED
);
47 DCHECK(source
== content::Source
<WebContents
>(web_contents_
));