| 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/edit_search_engine_controller.h" | 5 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/net/url_fixer_upper.h" | 9 #include "chrome/browser/net/url_fixer_upper.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/search_engines/template_url.h" | 11 #include "chrome/browser/search_engines/template_url.h" |
| 12 #include "chrome/browser/search_engines/template_url_service.h" | 12 #include "chrome/browser/search_engines/template_url_service.h" |
| 13 #include "chrome/browser/search_engines/template_url_service_factory.h" | 13 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 14 #include "content/browser/user_metrics.h" | 14 #include "content/public/browser/user_metrics.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 | 16 |
| 17 using content::UserMetricsAction; |
| 18 |
| 17 EditSearchEngineController::EditSearchEngineController( | 19 EditSearchEngineController::EditSearchEngineController( |
| 18 const TemplateURL* template_url, | 20 const TemplateURL* template_url, |
| 19 EditSearchEngineControllerDelegate* edit_keyword_delegate, | 21 EditSearchEngineControllerDelegate* edit_keyword_delegate, |
| 20 Profile* profile) | 22 Profile* profile) |
| 21 : template_url_(template_url), | 23 : template_url_(template_url), |
| 22 edit_keyword_delegate_(edit_keyword_delegate), | 24 edit_keyword_delegate_(edit_keyword_delegate), |
| 23 profile_(profile) { | 25 profile_(profile) { |
| 24 DCHECK(profile_); | 26 DCHECK(profile_); |
| 25 } | 27 } |
| 26 | 28 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 DCHECK(template_url_); | 99 DCHECK(template_url_); |
| 98 // const_cast is ugly, but this is the same thing the TemplateURLService | 100 // const_cast is ugly, but this is the same thing the TemplateURLService |
| 99 // does in a similar situation (updating an existing TemplateURL with | 101 // does in a similar situation (updating an existing TemplateURL with |
| 100 // data from a new one). | 102 // data from a new one). |
| 101 TemplateURL* modifiable_url = const_cast<TemplateURL*>(template_url_); | 103 TemplateURL* modifiable_url = const_cast<TemplateURL*>(template_url_); |
| 102 modifiable_url->set_short_name(title_input); | 104 modifiable_url->set_short_name(title_input); |
| 103 modifiable_url->set_keyword(keyword_input); | 105 modifiable_url->set_keyword(keyword_input); |
| 104 modifiable_url->SetURL(url_string, 0, 0); | 106 modifiable_url->SetURL(url_string, 0, 0); |
| 105 // TemplateURLService takes ownership of template_url_. | 107 // TemplateURLService takes ownership of template_url_. |
| 106 template_url_service->Add(modifiable_url); | 108 template_url_service->Add(modifiable_url); |
| 107 UserMetrics::RecordAction(UserMetricsAction("KeywordEditor_AddKeywordJS")); | 109 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeywordJS")); |
| 108 } else { | 110 } else { |
| 109 // Adding or modifying an entry via the Delegate. | 111 // Adding or modifying an entry via the Delegate. |
| 110 edit_keyword_delegate_->OnEditedKeyword(template_url_, | 112 edit_keyword_delegate_->OnEditedKeyword(template_url_, |
| 111 title_input, | 113 title_input, |
| 112 keyword_input, | 114 keyword_input, |
| 113 url_string); | 115 url_string); |
| 114 } | 116 } |
| 115 } | 117 } |
| 116 | 118 |
| 117 void EditSearchEngineController::CleanUpCancelledAdd() { | 119 void EditSearchEngineController::CleanUpCancelledAdd() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 142 std::string scheme( | 144 std::string scheme( |
| 143 URLFixerUpper::SegmentURL(expanded_url, &parts)); | 145 URLFixerUpper::SegmentURL(expanded_url, &parts)); |
| 144 if (!parts.scheme.is_valid()) { | 146 if (!parts.scheme.is_valid()) { |
| 145 scheme.append("://"); | 147 scheme.append("://"); |
| 146 url.insert(0, scheme); | 148 url.insert(0, scheme); |
| 147 } | 149 } |
| 148 | 150 |
| 149 return url; | 151 return url; |
| 150 } | 152 } |
| 151 | 153 |
| OLD | NEW |