| OLD | NEW |
| 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/ui/search_engines/template_url_fetcher_ui_callbacks.h" | 5 #include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
| 10 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.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" | 11 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "content/common/content_notification_types.h" |
| 13 #include "content/common/notification_source.h" | 14 #include "content/common/notification_source.h" |
| 14 #include "content/common/notification_type.h" | |
| 15 | 15 |
| 16 TemplateURLFetcherUICallbacks::TemplateURLFetcherUICallbacks( | 16 TemplateURLFetcherUICallbacks::TemplateURLFetcherUICallbacks( |
| 17 SearchEngineTabHelper* tab_helper, | 17 SearchEngineTabHelper* tab_helper, |
| 18 TabContents* tab_contents) | 18 TabContents* tab_contents) |
| 19 : source_(tab_helper), | 19 : source_(tab_helper), |
| 20 tab_contents_(tab_contents) { | 20 tab_contents_(tab_contents) { |
| 21 registrar_.Add(this, | 21 registrar_.Add(this, |
| 22 NotificationType::TAB_CONTENTS_DESTROYED, | 22 content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 23 Source<TabContents>(tab_contents_)); | 23 Source<TabContents>(tab_contents_)); |
| 24 } | 24 } |
| 25 | 25 |
| 26 TemplateURLFetcherUICallbacks::~TemplateURLFetcherUICallbacks() { | 26 TemplateURLFetcherUICallbacks::~TemplateURLFetcherUICallbacks() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 void TemplateURLFetcherUICallbacks::ConfirmSetDefaultSearchProvider( | 29 void TemplateURLFetcherUICallbacks::ConfirmSetDefaultSearchProvider( |
| 30 TemplateURL* template_url, | 30 TemplateURL* template_url, |
| 31 TemplateURLService* template_url_service) { | 31 TemplateURLService* template_url_service) { |
| 32 scoped_ptr<TemplateURL> owned_template_url(template_url); | 32 scoped_ptr<TemplateURL> owned_template_url(template_url); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 44 Profile* profile) { | 44 Profile* profile) { |
| 45 scoped_ptr<TemplateURL> owned_template_url(template_url); | 45 scoped_ptr<TemplateURL> owned_template_url(template_url); |
| 46 if (!source_ || !source_->delegate()) | 46 if (!source_ || !source_->delegate()) |
| 47 return; | 47 return; |
| 48 | 48 |
| 49 source_->delegate()->ConfirmAddSearchProvider(owned_template_url.release(), | 49 source_->delegate()->ConfirmAddSearchProvider(owned_template_url.release(), |
| 50 profile); | 50 profile); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void TemplateURLFetcherUICallbacks::Observe( | 53 void TemplateURLFetcherUICallbacks::Observe( |
| 54 NotificationType type, | 54 int type, |
| 55 const NotificationSource& source, | 55 const NotificationSource& source, |
| 56 const NotificationDetails& details) { | 56 const NotificationDetails& details) { |
| 57 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); | 57 DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); |
| 58 DCHECK(source == Source<TabContents>(tab_contents_)); | 58 DCHECK(source == Source<TabContents>(tab_contents_)); |
| 59 source_ = NULL; | 59 source_ = NULL; |
| 60 tab_contents_ = NULL; | 60 tab_contents_ = NULL; |
| 61 } | 61 } |
| OLD | NEW |