| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 registrar_.Add(this, | 21 registrar_.Add(this, |
| 22 content::NOTIFICATION_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 Profile* profile) { |
| 32 scoped_ptr<TemplateURL> owned_template_url(template_url); | 32 scoped_ptr<TemplateURL> owned_template_url(template_url); |
| 33 if (!source_ || !source_->delegate() || !tab_contents_) | 33 if (!source_ || !source_->delegate() || !tab_contents_) |
| 34 return; | 34 return; |
| 35 | 35 |
| 36 source_->delegate()->ConfirmSetDefaultSearchProvider( | 36 source_->delegate()->ConfirmSetDefaultSearchProvider(tab_contents_, |
| 37 tab_contents_, | 37 owned_template_url.release(), profile); |
| 38 owned_template_url.release(), | |
| 39 template_url_service); | |
| 40 } | 38 } |
| 41 | 39 |
| 42 void TemplateURLFetcherUICallbacks::ConfirmAddSearchProvider( | 40 void TemplateURLFetcherUICallbacks::ConfirmAddSearchProvider( |
| 43 TemplateURL* template_url, | 41 TemplateURL* template_url, |
| 44 Profile* profile) { | 42 Profile* profile) { |
| 45 scoped_ptr<TemplateURL> owned_template_url(template_url); | 43 scoped_ptr<TemplateURL> owned_template_url(template_url); |
| 46 if (!source_ || !source_->delegate()) | 44 if (!source_ || !source_->delegate()) |
| 47 return; | 45 return; |
| 48 | 46 |
| 49 source_->delegate()->ConfirmAddSearchProvider(owned_template_url.release(), | 47 source_->delegate()->ConfirmAddSearchProvider(owned_template_url.release(), |
| 50 profile); | 48 profile); |
| 51 } | 49 } |
| 52 | 50 |
| 53 void TemplateURLFetcherUICallbacks::Observe( | 51 void TemplateURLFetcherUICallbacks::Observe( |
| 54 int type, | 52 int type, |
| 55 const NotificationSource& source, | 53 const NotificationSource& source, |
| 56 const NotificationDetails& details) { | 54 const NotificationDetails& details) { |
| 57 DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); | 55 DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); |
| 58 DCHECK(source == Source<TabContents>(tab_contents_)); | 56 DCHECK(source == Source<TabContents>(tab_contents_)); |
| 59 source_ = NULL; | 57 source_ = NULL; |
| 60 tab_contents_ = NULL; | 58 tab_contents_ = NULL; |
| 61 } | 59 } |
| OLD | NEW |