Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 search_button_(NULL), | 177 search_button_(NULL), |
| 178 is_popup_mode_(is_popup_mode), | 178 is_popup_mode_(is_popup_mode), |
| 179 show_focus_rect_(false), | 179 show_focus_rect_(false), |
| 180 template_url_service_(NULL), | 180 template_url_service_(NULL), |
| 181 dropdown_animation_offset_(0), | 181 dropdown_animation_offset_(0), |
| 182 starting_omnibox_offset_(0), | 182 starting_omnibox_offset_(0), |
| 183 current_omnibox_offset_(0), | 183 current_omnibox_offset_(0), |
| 184 starting_omnibox_leading_inset_(0), | 184 starting_omnibox_leading_inset_(0), |
| 185 current_omnibox_leading_inset_(0), | 185 current_omnibox_leading_inset_(0), |
| 186 current_omnibox_width_(0), | 186 current_omnibox_width_(0), |
| 187 ending_omnibox_width_(0) { | 187 ending_omnibox_width_(0), |
| 188 web_contents_not_null_at_last_refresh_(false) { | |
| 188 edit_bookmarks_enabled_.Init( | 189 edit_bookmarks_enabled_.Init( |
| 189 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 190 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 190 base::Bind(&LocationBarView::Update, base::Unretained(this), | 191 base::Bind(&LocationBarView::Update, base::Unretained(this), |
| 191 static_cast<content::WebContents*>(NULL))); | 192 static_cast<content::WebContents*>(NULL))); |
| 192 | 193 |
| 193 if (browser_) | 194 if (browser_) |
| 194 browser_->search_model()->AddObserver(this); | 195 browser_->search_model()->AddObserver(this); |
| 195 } | 196 } |
| 196 | 197 |
| 197 LocationBarView::~LocationBarView() { | 198 LocationBarView::~LocationBarView() { |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1071 PageActions new_page_actions; | 1072 PageActions new_page_actions; |
| 1072 | 1073 |
| 1073 WebContents* web_contents = GetWebContents(); | 1074 WebContents* web_contents = GetWebContents(); |
| 1074 if (web_contents) { | 1075 if (web_contents) { |
| 1075 extensions::TabHelper* extensions_tab_helper = | 1076 extensions::TabHelper* extensions_tab_helper = |
| 1076 extensions::TabHelper::FromWebContents(web_contents); | 1077 extensions::TabHelper::FromWebContents(web_contents); |
| 1077 extensions::LocationBarController* controller = | 1078 extensions::LocationBarController* controller = |
| 1078 extensions_tab_helper->location_bar_controller(); | 1079 extensions_tab_helper->location_bar_controller(); |
| 1079 new_page_actions = controller->GetCurrentActions(); | 1080 new_page_actions = controller->GetCurrentActions(); |
| 1080 } | 1081 } |
| 1082 web_contents_not_null_at_last_refresh_ = web_contents != NULL; | |
|
Peter Kasting
2014/12/19 22:14:12
Super-tiny nit, but I'd change "not_null" to "null
| |
| 1081 | 1083 |
| 1082 // On startup we sometimes haven't loaded any extensions. This makes sure | 1084 // On startup we sometimes haven't loaded any extensions. This makes sure |
| 1083 // we catch up when the extensions (and any page actions) load. | 1085 // we catch up when the extensions (and any page actions) load. |
| 1084 if (page_actions_ != new_page_actions) { | 1086 if (page_actions_ != new_page_actions) { |
| 1085 changed = true; | 1087 changed = true; |
| 1086 | 1088 |
| 1087 page_actions_.swap(new_page_actions); | 1089 page_actions_.swap(new_page_actions); |
| 1088 DeletePageActionViews(); // Delete the old views (if any). | 1090 DeletePageActionViews(); // Delete the old views (if any). |
| 1089 | 1091 |
| 1090 // Create the page action views. | 1092 // Create the page action views. |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1308 | 1310 |
| 1309 bool LocationBarView::ShowPageActionPopup( | 1311 bool LocationBarView::ShowPageActionPopup( |
| 1310 const extensions::Extension* extension, | 1312 const extensions::Extension* extension, |
| 1311 bool grant_tab_permissions) { | 1313 bool grant_tab_permissions) { |
| 1312 ExtensionAction* extension_action = | 1314 ExtensionAction* extension_action = |
| 1313 extensions::ExtensionActionManager::Get(profile())->GetPageAction( | 1315 extensions::ExtensionActionManager::Get(profile())->GetPageAction( |
| 1314 *extension); | 1316 *extension); |
| 1315 CHECK(extension_action); | 1317 CHECK(extension_action); |
| 1316 PageActionWithBadgeView* page_action_view = | 1318 PageActionWithBadgeView* page_action_view = |
| 1317 GetPageActionView(extension_action); | 1319 GetPageActionView(extension_action); |
| 1318 CHECK(page_action_view); | 1320 if (!page_action_view) { |
| 1321 CHECK(web_contents_not_null_at_last_refresh_); | |
| 1322 CHECK(!is_popup_mode_); | |
| 1323 CHECK(!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()); | |
| 1324 CHECK(false); | |
| 1325 } | |
| 1319 PageActionImageView* page_action_image_view = page_action_view->image_view(); | 1326 PageActionImageView* page_action_image_view = page_action_view->image_view(); |
| 1320 CHECK(page_action_image_view); | 1327 CHECK(page_action_image_view); |
| 1321 ExtensionActionViewController* extension_action_view_controller = | 1328 ExtensionActionViewController* extension_action_view_controller = |
| 1322 page_action_image_view->view_controller(); | 1329 page_action_image_view->view_controller(); |
| 1323 CHECK(extension_action_view_controller); | 1330 CHECK(extension_action_view_controller); |
| 1324 return extension_action_view_controller->ExecuteAction(grant_tab_permissions); | 1331 return extension_action_view_controller->ExecuteAction(grant_tab_permissions); |
| 1325 } | 1332 } |
| 1326 | 1333 |
| 1327 void LocationBarView::UpdateOpenPDFInReaderPrompt() { | 1334 void LocationBarView::UpdateOpenPDFInReaderPrompt() { |
| 1328 open_pdf_in_reader_view_->Update( | 1335 open_pdf_in_reader_view_->Update( |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1665 | 1672 |
| 1666 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1673 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1667 const SearchModel::State& new_state) { | 1674 const SearchModel::State& new_state) { |
| 1668 const bool visible = !GetToolbarModel()->input_in_progress() && | 1675 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1669 new_state.voice_search_supported; | 1676 new_state.voice_search_supported; |
| 1670 if (mic_search_view_->visible() != visible) { | 1677 if (mic_search_view_->visible() != visible) { |
| 1671 mic_search_view_->SetVisible(visible); | 1678 mic_search_view_->SetVisible(visible); |
| 1672 Layout(); | 1679 Layout(); |
| 1673 } | 1680 } |
| 1674 } | 1681 } |
| OLD | NEW |