| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/translate/translate_service.h" | 32 #include "chrome/browser/translate/translate_service.h" |
| 33 #include "chrome/browser/translate/translate_tab_helper.h" | 33 #include "chrome/browser/translate/translate_tab_helper.h" |
| 34 #include "chrome/browser/ui/browser.h" | 34 #include "chrome/browser/ui/browser.h" |
| 35 #include "chrome/browser/ui/browser_finder.h" | 35 #include "chrome/browser/ui/browser_finder.h" |
| 36 #include "chrome/browser/ui/browser_instant_controller.h" | 36 #include "chrome/browser/ui/browser_instant_controller.h" |
| 37 #include "chrome/browser/ui/browser_window.h" | 37 #include "chrome/browser/ui/browser_window.h" |
| 38 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 38 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
| 39 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 39 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 40 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 40 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
| 41 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" | 41 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
| 42 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
| 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 43 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 43 #include "chrome/browser/ui/toolbar/origin_chip_info.h" | 44 #include "chrome/browser/ui/toolbar/origin_chip_info.h" |
| 44 #include "chrome/browser/ui/view_ids.h" | 45 #include "chrome/browser/ui/view_ids.h" |
| 45 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" | 46 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" |
| 46 #include "chrome/browser/ui/views/browser_dialogs.h" | 47 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 47 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 48 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 48 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 49 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 49 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" | 50 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" |
| 50 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 51 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 51 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" | 52 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 AddChildView(generated_credit_card_view_); | 372 AddChildView(generated_credit_card_view_); |
| 372 | 373 |
| 373 zoom_view_ = new ZoomView(delegate_); | 374 zoom_view_ = new ZoomView(delegate_); |
| 374 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); | 375 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); |
| 375 AddChildView(zoom_view_); | 376 AddChildView(zoom_view_); |
| 376 | 377 |
| 377 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); | 378 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); |
| 378 AddChildView(open_pdf_in_reader_view_); | 379 AddChildView(open_pdf_in_reader_view_); |
| 379 | 380 |
| 380 manage_passwords_icon_view_ = new ManagePasswordsIconView(delegate_); | 381 manage_passwords_icon_view_ = new ManagePasswordsIconView(delegate_); |
| 381 manage_passwords_icon_view_->set_id(VIEW_ID_MANAGE_PASSWORDS_ICON_BUTTON); | 382 manage_passwords_icon_view_->SetState(ManagePasswordsIcon::INACTIVE_STATE); |
| 382 AddChildView(manage_passwords_icon_view_); | 383 AddChildView(manage_passwords_icon_view_); |
| 383 | 384 |
| 384 translate_icon_view_ = new TranslateIconView(command_updater()); | 385 translate_icon_view_ = new TranslateIconView(command_updater()); |
| 385 translate_icon_view_->SetVisible(false); | 386 translate_icon_view_->SetVisible(false); |
| 386 AddChildView(translate_icon_view_); | 387 AddChildView(translate_icon_view_); |
| 387 | 388 |
| 388 star_view_ = new StarView(command_updater()); | 389 star_view_ = new StarView(command_updater()); |
| 389 star_view_->SetVisible(false); | 390 star_view_->SetVisible(false); |
| 390 AddChildView(star_view_); | 391 AddChildView(star_view_); |
| 391 | 392 |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 translate_icon_view_->SetVisible(enabled); | 1193 translate_icon_view_->SetVisible(enabled); |
| 1193 translate_icon_view_->SetToggled(language_state.IsPageTranslated()); | 1194 translate_icon_view_->SetToggled(language_state.IsPageTranslated()); |
| 1194 } | 1195 } |
| 1195 | 1196 |
| 1196 bool LocationBarView::RefreshManagePasswordsIconView() { | 1197 bool LocationBarView::RefreshManagePasswordsIconView() { |
| 1197 DCHECK(manage_passwords_icon_view_); | 1198 DCHECK(manage_passwords_icon_view_); |
| 1198 WebContents* web_contents = GetWebContents(); | 1199 WebContents* web_contents = GetWebContents(); |
| 1199 if (!web_contents) | 1200 if (!web_contents) |
| 1200 return false; | 1201 return false; |
| 1201 const bool was_visible = manage_passwords_icon_view_->visible(); | 1202 const bool was_visible = manage_passwords_icon_view_->visible(); |
| 1202 manage_passwords_icon_view_->Update( | 1203 ManagePasswordsBubbleUIController::FromWebContents( |
| 1203 ManagePasswordsBubbleUIController::FromWebContents(web_contents)); | 1204 web_contents)->UpdateIconAndBubbleState(manage_passwords_icon_view_); |
| 1204 return was_visible != manage_passwords_icon_view_->visible(); | 1205 return was_visible != manage_passwords_icon_view_->visible(); |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 void LocationBarView::ShowManagePasswordsBubbleIfNeeded() { | |
| 1208 DCHECK(manage_passwords_icon_view_); | |
| 1209 WebContents* web_contents = GetWebContents(); | |
| 1210 if (!web_contents) | |
| 1211 return; | |
| 1212 manage_passwords_icon_view_->ShowBubbleIfNeeded( | |
| 1213 ManagePasswordsBubbleUIController::FromWebContents(web_contents)); | |
| 1214 } | |
| 1215 | |
| 1216 void LocationBarView::ShowFirstRunBubbleInternal() { | 1208 void LocationBarView::ShowFirstRunBubbleInternal() { |
| 1217 #if !defined(OS_CHROMEOS) | 1209 #if !defined(OS_CHROMEOS) |
| 1218 // First run bubble doesn't make sense for Chrome OS. | 1210 // First run bubble doesn't make sense for Chrome OS. |
| 1219 Browser* browser = GetBrowserFromDelegate(delegate_); | 1211 Browser* browser = GetBrowserFromDelegate(delegate_); |
| 1220 if (!browser) | 1212 if (!browser) |
| 1221 return; // Possible when browser is shutting down. | 1213 return; // Possible when browser is shutting down. |
| 1222 | 1214 |
| 1223 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); | 1215 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); |
| 1224 #endif | 1216 #endif |
| 1225 } | 1217 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 Layout(); | 1287 Layout(); |
| 1296 SchedulePaint(); | 1288 SchedulePaint(); |
| 1297 } | 1289 } |
| 1298 } | 1290 } |
| 1299 | 1291 |
| 1300 void LocationBarView::UpdateManagePasswordsIconAndBubble() { | 1292 void LocationBarView::UpdateManagePasswordsIconAndBubble() { |
| 1301 if (RefreshManagePasswordsIconView()) { | 1293 if (RefreshManagePasswordsIconView()) { |
| 1302 Layout(); | 1294 Layout(); |
| 1303 SchedulePaint(); | 1295 SchedulePaint(); |
| 1304 } | 1296 } |
| 1305 ShowManagePasswordsBubbleIfNeeded(); | |
| 1306 } | 1297 } |
| 1307 | 1298 |
| 1308 void LocationBarView::UpdatePageActions() { | 1299 void LocationBarView::UpdatePageActions() { |
| 1309 size_t count_before = page_action_views_.size(); | 1300 size_t count_before = page_action_views_.size(); |
| 1310 bool changed = RefreshPageActionViews(); | 1301 bool changed = RefreshPageActionViews(); |
| 1311 if (page_action_views_.size() != count_before) { | 1302 if (page_action_views_.size() != count_before) { |
| 1312 content::NotificationService::current()->Notify( | 1303 content::NotificationService::current()->Notify( |
| 1313 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 1304 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 1314 content::Source<LocationBar>(this), | 1305 content::Source<LocationBar>(this), |
| 1315 content::NotificationService::NoDetails()); | 1306 content::NotificationService::NoDetails()); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1666 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1676 const SearchModel::State& new_state) { | 1667 const SearchModel::State& new_state) { |
| 1677 const bool visible = !GetToolbarModel()->input_in_progress() && | 1668 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1678 new_state.voice_search_supported; | 1669 new_state.voice_search_supported; |
| 1679 if (mic_search_view_->visible() != visible) { | 1670 if (mic_search_view_->visible() != visible) { |
| 1680 mic_search_view_->SetVisible(visible); | 1671 mic_search_view_->SetVisible(visible); |
| 1681 Layout(); | 1672 Layout(); |
| 1682 } | 1673 } |
| 1683 } | 1674 } |
| 1684 | 1675 |
| OLD | NEW |