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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_controller.cc

Issue 10823424: Make sure controller is properly reset when the picker is closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/intents/web_intent_picker_controller.h" 5 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 683 }
684 684
685 void WebIntentPickerController::OnIntentDataArrived() { 685 void WebIntentPickerController::OnIntentDataArrived() {
686 DCHECK(picker_model_.get()); 686 DCHECK(picker_model_.get());
687 687
688 if (!pending_cws_request_ && 688 if (!pending_cws_request_ &&
689 pending_registry_calls_count_ == 0) 689 pending_registry_calls_count_ == 0)
690 OnPickerEvent(kPickerEventAsyncDataComplete); 690 OnPickerEvent(kPickerEventAsyncDataComplete);
691 } 691 }
692 692
693 void WebIntentPickerController::Reset() {
694 // Can only be invoked when picker is hidden
695 DCHECK(dialog_state_ == kPickerHidden);
sky 2012/08/20 23:08:20 DCHECK_EQ
groby-ooo-7-16 2012/08/21 03:40:30 Done.
696
697 // Abandon all callbacks.
698 weak_ptr_factory_.InvalidateWeakPtrs();
699 timer_factory_.InvalidateWeakPtrs();
700
701 // Reset state associated with callbacks.
702 pending_async_count_ = 0;
703 pending_registry_calls_count_ = 0;
704 pending_cws_request_ = false;
705
706 // Reset picker.
707 picker_model_.reset(new WebIntentPickerModel());
708 picker_shown_ = false;
709
710 DCHECK(tab_contents_);
711 tab_contents_->constrained_window_tab_helper()->BlockTabContent(false);
712 }
713
693 // static 714 // static
694 void WebIntentPickerController::DecodeExtensionIconAndResize( 715 void WebIntentPickerController::DecodeExtensionIconAndResize(
695 scoped_ptr<std::string> icon_response, 716 scoped_ptr<std::string> icon_response,
696 const ExtensionIconAvailableCallback& callback, 717 const ExtensionIconAvailableCallback& callback,
697 const base::Closure& unavailable_callback) { 718 const base::Closure& unavailable_callback) {
698 SkBitmap icon_bitmap; 719 SkBitmap icon_bitmap;
699 if (gfx::PNGCodec::Decode( 720 if (gfx::PNGCodec::Decode(
700 reinterpret_cast<const unsigned char*>(icon_response->data()), 721 reinterpret_cast<const unsigned char*>(icon_response->data()),
701 icon_response->length(), 722 icon_response->length(),
702 &icon_bitmap)) { 723 &icon_bitmap)) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 DCHECK(dialog_state_ == kPickerWaiting); 876 DCHECK(dialog_state_ == kPickerWaiting);
856 break; 877 break;
857 878
858 case kPickerMain: 879 case kPickerMain:
859 // No DCHECK - main state can be reached from any state. 880 // No DCHECK - main state can be reached from any state.
860 // Ready to display data. 881 // Ready to display data.
861 picker_model_->SetWaitingForSuggestions(false); 882 picker_model_->SetWaitingForSuggestions(false);
862 break; 883 break;
863 884
864 case kPickerHidden: 885 case kPickerHidden:
886 Reset();
865 break; 887 break;
866 888
867 default: 889 default:
868 NOTREACHED(); 890 NOTREACHED();
869 break; 891 break;
870 892
871 } 893 }
872 894
873 dialog_state_ = state; 895 dialog_state_ = state;
874 896
(...skipping 10 matching lines...) Expand all
885 picker_->SetActionString(GetIntentActionString( 907 picker_->SetActionString(GetIntentActionString(
886 UTF16ToUTF8(picker_model_->action()))); 908 UTF16ToUTF8(picker_model_->action())));
887 picker_shown_ = true; 909 picker_shown_ = true;
888 } 910 }
889 911
890 void WebIntentPickerController::ClosePicker() { 912 void WebIntentPickerController::ClosePicker() {
891 SetDialogState(kPickerHidden); 913 SetDialogState(kPickerHidden);
892 if (picker_) 914 if (picker_)
893 picker_->Close(); 915 picker_->Close();
894 } 916 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698