| Index: chrome/browser/ui/metro_pin_tab_helper_win.cc
|
| ===================================================================
|
| --- chrome/browser/ui/metro_pin_tab_helper_win.cc (revision 168088)
|
| +++ chrome/browser/ui/metro_pin_tab_helper_win.cc (working copy)
|
| @@ -363,21 +363,31 @@
|
| }
|
|
|
| MetroPinTabHelper::MetroPinTabHelper(content::WebContents* web_contents)
|
| - : content::WebContentsObserver(web_contents),
|
| - is_pinned_(false) {}
|
| + : content::WebContentsObserver(web_contents) {}
|
|
|
| MetroPinTabHelper::~MetroPinTabHelper() {}
|
|
|
| -void MetroPinTabHelper::TogglePinnedToStartScreen() {
|
| - UpdatePinnedStateForCurrentURL();
|
| - bool was_pinned = is_pinned_;
|
| +bool MetroPinTabHelper::IsPinned() const {
|
| + HMODULE metro_module = base::win::GetMetroModule();
|
| + if (!metro_module)
|
| + return false;
|
|
|
| - // TODO(benwells): This will update the state incorrectly if the user
|
| - // cancels. To fix this some sort of callback needs to be introduced as
|
| - // the pinning happens on another thread.
|
| - is_pinned_ = !is_pinned_;
|
| + typedef BOOL (*MetroIsPinnedToStartScreen)(const string16&);
|
| + MetroIsPinnedToStartScreen metro_is_pinned_to_start_screen =
|
| + reinterpret_cast<MetroIsPinnedToStartScreen>(
|
| + ::GetProcAddress(metro_module, "MetroIsPinnedToStartScreen"));
|
| + if (!metro_is_pinned_to_start_screen) {
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
|
|
| - if (was_pinned) {
|
| + GURL url = web_contents()->GetURL();
|
| + string16 tile_id = GenerateTileId(UTF8ToUTF16(url.spec()));
|
| + return metro_is_pinned_to_start_screen(tile_id) != 0;
|
| +}
|
| +
|
| +void MetroPinTabHelper::TogglePinnedToStartScreen() {
|
| + if (IsPinned()) {
|
| UnPinPageFromStartScreen();
|
| return;
|
| }
|
| @@ -400,7 +410,6 @@
|
| void MetroPinTabHelper::DidNavigateMainFrame(
|
| const content::LoadCommittedDetails& /*details*/,
|
| const content::FrameNavigateParams& /*params*/) {
|
| - UpdatePinnedStateForCurrentURL();
|
| // Cancel any outstanding pin operations once the user navigates away from
|
| // the page.
|
| if (favicon_downloader_.get())
|
| @@ -436,25 +445,6 @@
|
| requested_size, bitmaps);
|
| }
|
|
|
| -void MetroPinTabHelper::UpdatePinnedStateForCurrentURL() {
|
| - HMODULE metro_module = base::win::GetMetroModule();
|
| - if (!metro_module)
|
| - return;
|
| -
|
| - typedef BOOL (*MetroIsPinnedToStartScreen)(const string16&);
|
| - MetroIsPinnedToStartScreen metro_is_pinned_to_start_screen =
|
| - reinterpret_cast<MetroIsPinnedToStartScreen>(
|
| - ::GetProcAddress(metro_module, "MetroIsPinnedToStartScreen"));
|
| - if (!metro_is_pinned_to_start_screen) {
|
| - NOTREACHED();
|
| - return;
|
| - }
|
| -
|
| - GURL url = web_contents()->GetURL();
|
| - string16 tile_id = GenerateTileId(UTF8ToUTF16(url.spec()));
|
| - is_pinned_ = metro_is_pinned_to_start_screen(tile_id) != 0;
|
| -}
|
| -
|
| void MetroPinTabHelper::UnPinPageFromStartScreen() {
|
| HMODULE metro_module = base::win::GetMetroModule();
|
| if (!metro_module)
|
|
|