Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
index 7b85a4966d49428235d8d3bef2403f87a70e34f7..89d8fba6aa983dadd59321ee63ec3c2b337d60c3 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
@@ -17,6 +17,8 @@ |
#include "chrome/app/chrome_command_ids.h" |
#include "chrome/browser/alternate_nav_url_fetcher.h" |
#include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
+#include "chrome/browser/chrome_to_mobile_service.h" |
+#include "chrome/browser/chrome_to_mobile_service_factory.h" |
#include "chrome/browser/defaults.h" |
#include "chrome/browser/extensions/extension_browser_event_router.h" |
#include "chrome/browser/extensions/extension_service.h" |
@@ -37,6 +39,7 @@ |
#include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
#include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
#include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
+#include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" |
#include "chrome/browser/ui/views/location_bar/star_view.h" |
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
#include "chrome/common/chrome_notification_types.h" |
@@ -135,6 +138,7 @@ LocationBarView::LocationBarView(Browser* browser, |
#endif |
keyword_hint_view_(NULL), |
star_view_(NULL), |
+ chrome_to_mobile_view_(NULL), |
mode_(mode), |
show_focus_rect_(false), |
template_url_service_(NULL), |
@@ -223,11 +227,18 @@ void LocationBarView::Init() { |
content_blocked_view->SetVisible(false); |
} |
- // The star is not visible in popups and in the app launcher. |
+ // Hide the star and Chrome To Mobile icons in popups and in the app launcher. |
if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
star_view_ = new StarView(browser_->command_updater()); |
AddChildView(star_view_); |
star_view_->SetVisible(true); |
+ |
+ chrome_to_mobile_view_ = |
+ new ChromeToMobileView(this, browser_->command_updater()); |
+ AddChildView(chrome_to_mobile_view_); |
+ if (browser_->profile()->IsSyncAccessible()) |
+ ChromeToMobileServiceFactory::GetForProfile(browser_->profile())-> |
+ RequestMobileListUpdate(); |
} |
// Initialize the location entry. We do this to avoid a black flash which is |
@@ -302,10 +313,18 @@ void LocationBarView::SetAnimationOffset(int offset) { |
void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
bool star_enabled = star_view_ && !model_->input_in_progress() && |
edit_bookmarks_enabled_.GetValue(); |
- browser_->command_updater()->UpdateCommandEnabled( |
- IDC_BOOKMARK_PAGE, star_enabled); |
+ CommandUpdater* command_updater = browser_->command_updater(); |
+ command_updater->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
if (star_view_) |
star_view_->SetVisible(star_enabled); |
+ |
+ Profile* profile = browser_->profile(); |
+ bool chrome_to_mobile_enabled = chrome_to_mobile_view_ && |
+ !model_->input_in_progress() && profile->IsSyncAccessible() && |
+ !ChromeToMobileServiceFactory::GetForProfile(profile)->mobiles().empty(); |
+ command_updater->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, |
+ chrome_to_mobile_enabled); |
+ |
RefreshContentSettingViews(); |
RefreshPageActionViews(); |
// Don't Update in app launcher mode so that the location entry does not show |
@@ -402,6 +421,13 @@ void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
newly_bookmarked); |
} |
+void LocationBarView::ShowChromeToMobileBubble() { |
+ ChromeToMobileServiceFactory::GetForProfile(browser_->profile())-> |
+ RequestMobileListUpdate(); |
+ browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, |
+ browser_->profile()); |
+} |
+ |
gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
gfx::Point origin(location_entry_view_->bounds().origin()); |
// If the UI layout is RTL, the coordinate system is not transformed and |
@@ -526,6 +552,9 @@ void LocationBarView::Layout() { |
if (star_view_ && star_view_->visible()) |
entry_width -= star_view_->GetPreferredSize().width() + kItemPadding; |
+ if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) |
+ entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + |
+ kItemPadding; |
for (PageActionViews::const_iterator i(page_action_views_.begin()); |
i != page_action_views_.end(); ++i) { |
if ((*i)->visible()) |
@@ -539,7 +568,7 @@ void LocationBarView::Layout() { |
// The gap between the edit and whatever is to its right is shortened. |
entry_width += kEditInternalSpace; |
- // Size the EV bubble. We do this after taking the star/page actions/content |
+ // Size the EV bubble after taking star/ChromeToMobile/page actions/content |
// settings out of |entry_width| so we won't take too much space. |
if (ev_bubble_width) { |
// Try to elide the bubble to be no larger than half the total available |
@@ -593,6 +622,14 @@ void LocationBarView::Layout() { |
offset -= kItemPadding; |
} |
+ if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { |
+ int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); |
+ offset -= icon_width; |
+ chrome_to_mobile_view_->SetBounds(offset, location_y, |
+ icon_width, location_height); |
+ offset -= kItemPadding; |
+ } |
+ |
for (PageActionViews::const_iterator i(page_action_views_.begin()); |
i != page_action_views_.end(); ++i) { |
if ((*i)->visible()) { |
@@ -958,6 +995,8 @@ void LocationBarView::RefreshPageActionViews() { |
DeletePageActionViews(); // Delete the old views (if any). |
page_action_views_.resize(page_actions.size()); |
+ View* view = chrome_to_mobile_view_ ? chrome_to_mobile_view_ : |
+ static_cast<View*>(star_view_); |
// Add the page actions in reverse order, so that the child views are |
// inserted in left-to-right order for accessibility. |
@@ -965,7 +1004,7 @@ void LocationBarView::RefreshPageActionViews() { |
page_action_views_[i] = new PageActionWithBadgeView( |
new PageActionImageView(this, page_actions[i])); |
page_action_views_[i]->SetVisible(false); |
- AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); |
+ AddChildViewAt(page_action_views_[i], GetIndexOf(view)); |
} |
} |