Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1239)

Unified Diff: chrome/browser/ui/metro_pin_tab_helper_win.cc

Issue 11411023: Merge 165818 - [Win8] Fix pin / unpin status if the user cancels an action or pins / unpins from st… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/metro_pin_tab_helper_win.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « chrome/browser/ui/metro_pin_tab_helper_win.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698