15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include <vector> 9c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Browser; 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GlobalErrorBubbleViewBase; 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace gfx { 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Image; 1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This object describes a single global error. 220f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)class GlobalError { 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum Severity { 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SEVERITY_LOW, 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SEVERITY_MEDIUM, 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SEVERITY_HIGH, 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GlobalError(); 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~GlobalError(); 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the error's severity level. If there are multiple errors, 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the error with the highest severity will display in the menu. If not 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // overridden, this is based on the badge resource ID. 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual Severity GetSeverity(); 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if a menu item should be added to the wrench menu. 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool HasMenuItem() = 0; 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the command ID for the menu item. 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int MenuItemCommandID() = 0; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the label for the menu item. 43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual base::string16 MenuItemLabel() = 0; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the resource ID for the menu item icon. 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int MenuItemIconResourceID(); 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when the user clicks on the menu item. 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ExecuteMenuItem(Browser* browser) = 0; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if a bubble view should be shown. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool HasBubbleView() = 0; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the bubble view has been shown. 520f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual bool HasShownBubbleView() = 0; 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to show the bubble view. 540f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual void ShowBubbleView(Browser* browser) = 0; 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the bubble view. 560f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual GlobalErrorBubbleViewBase* GetBubbleView() = 0; 570f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)}; 580f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 590f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// This object describes a single global error that already comes with support 600f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// for showing a standard Bubble UI. Derived classes just need to supply the 610f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// content to be displayed in the bubble. 620f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)class GlobalErrorWithStandardBubble 630f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) : public GlobalError, 640f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) public base::SupportsWeakPtr<GlobalErrorWithStandardBubble> { 650f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) public: 660f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) GlobalErrorWithStandardBubble(); 670f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual ~GlobalErrorWithStandardBubble(); 680f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 6990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns an icon to use for the bubble view. 7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual gfx::Image GetBubbleViewIcon(); 71f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the title for the bubble view. 73a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual base::string16 GetBubbleViewTitle() = 0; 74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Returns the messages for the bubble view, one per line. Multiple messages 75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // are only supported on Views. 76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // TODO(yoz): Add multi-line support for GTK and Cocoa. 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual std::vector<base::string16> GetBubbleViewMessages() = 0; 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the accept button label for the bubble view. 79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual base::string16 GetBubbleViewAcceptButtonLabel() = 0; 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the cancel button label for the bubble view. To hide the cancel 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // button return an empty string. 82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual base::string16 GetBubbleViewCancelButtonLabel() = 0; 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when the bubble view is closed. |browser| is the Browser that the 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // bubble view was shown on. 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void BubbleViewDidClose(Browser* browser); 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies subclasses that the bubble view is closed. |browser| is the 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Browser that the bubble view was shown on. 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnBubbleViewDidClose(Browser* browser) = 0; 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when the user clicks on the accept button. |browser| is the 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Browser that the bubble view was shown on. 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void BubbleViewAcceptButtonPressed(Browser* browser) = 0; 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when the user clicks the cancel button. |browser| is the 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Browser that the bubble view was shown on. 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void BubbleViewCancelButtonPressed(Browser* browser) = 0; 95f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Returns true if the bubble should close when focus is lost. If false, the 96f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // bubble will stick around until the user explicitly acknowledges it. 97f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Defaults to true. 98f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual bool ShouldCloseOnDeactivate() const; 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1000f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) // GlobalError overrides: 1010f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual bool HasBubbleView() OVERRIDE; 1020f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual bool HasShownBubbleView() OVERRIDE; 1030f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual void ShowBubbleView(Browser* browser) OVERRIDE; 1040f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE; 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_shown_bubble_view_; 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GlobalErrorBubbleViewBase* bubble_view_; 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1100f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(GlobalErrorWithStandardBubble); 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_ 114